Skip to content
Snippets Groups Projects
Commit 9ea3ba5b authored by srosse's avatar srosse
Browse files

OO-895: remove the tab and show the roles in the system tab of the personal settings

parent 82fa6809
No related branches found
No related tags found
No related merge requests found
......@@ -122,7 +122,7 @@ public class TabbedPaneRenderer implements ComponentRenderer {
public void renderHeaderIncludes(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderingState rstate) {
TabbedPane tp = (TabbedPane)source;
int cnt = tp.getTabCount();
if (cnt > 0) {
if (cnt > 0 && tp.getSelectedPane() < cnt) {
Component toRender = tp.getTabAt(tp.getSelectedPane());
// delegate header rendering to the selected pane
renderer.renderHeaderIncludes(sb, toRender, rstate);
......
......@@ -123,10 +123,6 @@ public class PersonalSettingsController extends BasicController implements Activ
userConfig.addTab(translate("tab.disclaimer"), disclaimerCtr.getInitialComponent());
}
Controller rolesCtrl = new UserRolesController(ureq, getWindowControl());
userConfig.addTab(translate("tab.roles"), rolesCtrl.getInitialComponent());
listenTo(rolesCtrl);
putInitialPanel(userConfig);
logDebug("PersonalSettingsController constructed, set velocity page to index.html", PersonalSettingsController.class.getSimpleName());
......
......@@ -23,8 +23,10 @@ import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import org.olat.admin.user.SystemRolesAndRightsController;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityManager;
import org.olat.basesecurity.Constants;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
......@@ -43,6 +45,7 @@ import org.olat.core.id.Preferences;
import org.olat.core.id.UserConstants;
import org.olat.core.util.ArrayHelper;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.core.util.i18n.I18nManager;
import org.olat.core.util.i18n.I18nModule;
import org.olat.core.util.mail.MailModule;
......@@ -77,7 +80,7 @@ public class PreferencesFormController extends FormBasicController {
* edited. Not necessarily the same as ureq.getIdentity()
*/
public PreferencesFormController(UserRequest ureq, WindowControl wControl, Identity tobeChangedIdentity) {
super(ureq, wControl);
super(ureq, wControl, Util.createPackageTranslator(SystemRolesAndRightsController.class, ureq.getLocale()));
this.tobeChangedIdentity = tobeChangedIdentity;
initForm(ureq);
}
......@@ -147,6 +150,39 @@ public class PreferencesFormController extends FormBasicController {
username.setElementCssClass("o_sel_home_settings_username");
username.setEnabled(false);
// Roles
final String[] roleKeys = new String[] {
Constants.GROUP_USERMANAGERS, Constants.GROUP_GROUPMANAGERS, Constants.GROUP_POOL_MANAGER,
Constants.GROUP_AUTHORS, Constants.GROUP_INST_ORES_MANAGER, Constants.GROUP_ADMIN
};
String iname = getIdentity().getUser().getProperty("institutionalName", null);
String ilabel = iname != null
? translate("rightsForm.isInstitutionalResourceManager.institution",iname)
: translate("rightsForm.isInstitutionalResourceManager");
final String[] roleValues = new String[]{
translate("rightsForm.isUsermanager"), translate("rightsForm.isGroupmanager"), translate("rightsForm.isPoolmanager"),
translate("rightsForm.isAuthor"), ilabel, translate("rightsForm.isAdmin")
};
final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
String userRoles = "";
List<String> roles = securityManager.getRolesAsString(tobeChangedIdentity);
for(String role:roles) {
for(int i=0; i<roleKeys.length; i++) {
if(roleKeys[i].equals(role)) {
userRoles = userRoles + roleValues[i] + ", ";
}
}
}
if (userRoles.equals("")) {
userRoles = translate("rightsForm.isAnonymous.false");
} else {
userRoles = userRoles.substring(0, userRoles.lastIndexOf(","));
}
uifactory.addStaticTextElement("rightsForm.roles", userRoles, formLayout);
username.setElementCssClass("o_sel_home_settings_username");
username.setEnabled(false);
// Language
Map<String, String> languages = I18nManager.getInstance().getEnabledLanguagesTranslated();
String[] langKeys = StringHelper.getMapKeysAsStringArray(languages);
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.user;
import java.util.List;
import org.olat.admin.user.SystemRolesAndRightsController;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.Constants;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.SelectionElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.Util;
/**
* Small controller which shows the roles of the current identity
*
* Initial date: 23.09.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class UserRolesController extends FormBasicController {
private static final String[] roleKeys = new String[] {
Constants.GROUP_USERMANAGERS, Constants.GROUP_GROUPMANAGERS, Constants.GROUP_POOL_MANAGER,
Constants.GROUP_AUTHORS, Constants.GROUP_INST_ORES_MANAGER, Constants.GROUP_ADMIN
};
private String[] roleValues;
private final BaseSecurity securityManager;
public UserRolesController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, Util.createPackageTranslator(SystemRolesAndRightsController.class, ureq.getLocale()));
securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
String iname = getIdentity().getUser().getProperty("institutionalName", null);
String ilabel = iname != null
? translate("rightsForm.isInstitutionalResourceManager.institution",iname)
: translate("rightsForm.isInstitutionalResourceManager");
roleValues = new String[]{
translate("rightsForm.isUsermanager"), translate("rightsForm.isGroupmanager"), translate("rightsForm.isPoolmanager"),
translate("rightsForm.isAuthor"), ilabel, translate("rightsForm.isAdmin")
};
initForm(ureq);
}
@Override
protected void formOK(UserRequest ureq) {
//
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
SelectionElement rolesEl = uifactory.addCheckboxesVertical("roles", "rightsForm.roles", formLayout, roleKeys, roleValues,null, 1);
rolesEl.setEnabled(false);
List<String> roles = securityManager.getRolesAsString(getIdentity());
for(String role:roles) {
for(String roleKey:roleKeys) {
if(roleKey.equals(role)) {
rolesEl.select(roleKey, true);
}
}
}
}
@Override
protected void doDispose() {
//
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment