diff --git a/src/main/java/org/olat/admin/user/UserAdminController.java b/src/main/java/org/olat/admin/user/UserAdminController.java index 85fdadf9391af2d750ecec01d3e863925f58db79..cc63c1ca0b931ba28186b466f934e28febabeeb3 100644 --- a/src/main/java/org/olat/admin/user/UserAdminController.java +++ b/src/main/java/org/olat/admin/user/UserAdminController.java @@ -70,6 +70,7 @@ import org.olat.resource.accesscontrol.ui.UserOrderController; import org.olat.user.ChangePrefsController; import org.olat.user.DisplayPortraitController; import org.olat.user.ProfileAndHomePageEditController; +import org.olat.user.ProfileFormController; import org.olat.user.PropFoundEvent; import org.olat.user.UserManager; import org.olat.user.UserPropertiesController; @@ -123,6 +124,7 @@ public class UserAdminController extends BasicController implements Activateable private UserAuthenticationsEditorController authenticationsCtr; private Link backLink; private Link exportDataButton; + private ProfileFormController profileCtr; private ProfileAndHomePageEditController userProfileCtr; private CourseOverviewController courseCtr; private GroupOverviewController grpCtr; @@ -289,7 +291,6 @@ public class UserAdminController extends BasicController implements Activateable true, title); listenTo(cmc); cmc.activate(); - } /** @@ -318,9 +319,11 @@ public class UserAdminController extends BasicController implements Activateable } return managerRoles.isSystemAdmin() || managerRoles.isManagerOf(OrganisationRoles.administrator, identityRoles) + || managerRoles.isManagerOf(OrganisationRoles.principal, identityRoles) || managerRoles.isManagerOf(OrganisationRoles.rolesmanager, identityRoles) || managerRoles.isManagerOf(OrganisationRoles.usermanager, identityRoles) || managerRoles.isMyInvitee(OrganisationRoles.administrator, identityRoles) + || managerRoles.isMyInvitee(OrganisationRoles.principal, identityRoles) || managerRoles.isMyInvitee(OrganisationRoles.rolesmanager, identityRoles) || managerRoles.isMyInvitee(OrganisationRoles.usermanager, identityRoles); } @@ -342,15 +345,23 @@ public class UserAdminController extends BasicController implements Activateable boolean isUserManagerOf = managerRoles.isManagerOf(OrganisationRoles.usermanager, editedRoles); boolean isRolesManagerOf = managerRoles.isManagerOf(OrganisationRoles.rolesmanager, editedRoles); - userProfileCtr = new ProfileAndHomePageEditController(ureq, getWindowControl(), identity, true); - listenTo(userProfileCtr); - userTabP.addTab(translate(NLS_EDIT_UPROFILE), userProfileCtr.getInitialComponent()); + if(isAdminOf || isSysAdmin || isUserManagerOf || isRolesManagerOf) { + userProfileCtr = new ProfileAndHomePageEditController(ureq, getWindowControl(), identity, true); + listenTo(userProfileCtr); + userTabP.addTab(translate(NLS_EDIT_UPROFILE), userProfileCtr.getInitialComponent()); + } else { + profileCtr = new ProfileFormController(ureq, getWindowControl(), identity, true, false); + listenTo(profileCtr); + userTabP.addTab(translate(NLS_EDIT_UPROFILE), profileCtr.getInitialComponent()); + } - userTabP.addTab(translate(NLS_EDIT_UPREFS), uureq -> { - prefsCtr = new ChangePrefsController(uureq, getWindowControl(), identity); - listenTo(prefsCtr); - return prefsCtr.getInitialComponent(); - }); + if(isAdminOf || isSysAdmin || isUserManagerOf || isRolesManagerOf) { + userTabP.addTab(translate(NLS_EDIT_UPREFS), uureq -> { + prefsCtr = new ChangePrefsController(uureq, getWindowControl(), identity); + listenTo(prefsCtr); + return prefsCtr.getInitialComponent(); + }); + } if (isPasswordChangesAllowed(identity)) { userTabP.addTab(translate(NLS_EDIT_UPCRED), uureq -> { @@ -376,13 +387,15 @@ public class UserAdminController extends BasicController implements Activateable if(isAdminOf || isPrincipalOf || isUserManagerOf || isRolesManagerOf) { userTabP.addTab(translate(NLS_VIEW_GROUPS), uureq -> { - grpCtr = new GroupOverviewController(uureq, getWindowControl(), identity, true); + boolean canModify = isAdminOf || isUserManagerOf || isRolesManagerOf; + grpCtr = new GroupOverviewController(uureq, getWindowControl(), identity, canModify); listenTo(grpCtr); return grpCtr.getInitialComponent(); }); userTabP.addTab(translate(NLS_VIEW_COURSES), uureq -> { - courseCtr = new CourseOverviewController(uureq, getWindowControl(), identity); + boolean canModify = isAdminOf || isUserManagerOf || isRolesManagerOf; + courseCtr = new CourseOverviewController(uureq, getWindowControl(), identity, canModify); listenTo(courseCtr); return courseCtr.getInitialComponent(); }); @@ -396,7 +409,9 @@ public class UserAdminController extends BasicController implements Activateable }); userTabP.addTab(translate(NLS_VIEW_EFF_STATEMENTS), uureq -> { - efficicencyCtrl = new CertificateAndEfficiencyStatementListController(uureq, getWindowControl(), identity, true); + boolean canModify = isAdminOf || isRolesManagerOf; + efficicencyCtrl = new CertificateAndEfficiencyStatementListController(uureq, getWindowControl(), + identity, true, canModify); listenTo(efficicencyCtrl); BreadcrumbedStackedPanel efficiencyPanel = new BreadcrumbedStackedPanel("statements", getTranslator(), efficicencyCtrl); efficiencyPanel.pushController(translate(NLS_VIEW_EFF_STATEMENTS), efficicencyCtrl); @@ -444,7 +459,8 @@ public class UserAdminController extends BasicController implements Activateable if(taxonomyModule.isEnabled() && (isUserManagerOf || isRolesManagerOf || isAdminOf || isPrincipalOf)) { userTabP.addTab(translate(NLS_VIEW_COMPETENCES), uureq -> { - competencesCtrl = new IdentityCompetencesController(uureq, getWindowControl(), identity); + boolean canModify = isUserManagerOf || isRolesManagerOf || isAdminOf; + competencesCtrl = new IdentityCompetencesController(uureq, getWindowControl(), identity, canModify); listenTo(competencesCtrl); BreadcrumbedStackedPanel competencePanel = new BreadcrumbedStackedPanel("competences", getTranslator(), competencesCtrl); competencePanel.pushController(translate(NLS_VIEW_COMPETENCES), competencesCtrl); diff --git a/src/main/java/org/olat/admin/user/course/CourseOverviewController.java b/src/main/java/org/olat/admin/user/course/CourseOverviewController.java index 8a7b26d55c569a59c65602512245596921faefcc..0f629b45bd749397d90828b5242ac3ba6b12e797 100644 --- a/src/main/java/org/olat/admin/user/course/CourseOverviewController.java +++ b/src/main/java/org/olat/admin/user/course/CourseOverviewController.java @@ -102,7 +102,9 @@ public class CourseOverviewController extends BasicController { private static final String TABLE_ACTION_UNSUBSCRIBE = "unsubscribe"; private final VelocityContainer vc; - private final Link addAsOwner, addAsTutor, addAsParticipant; + private Link addAsOwner; + private Link addAsTutor; + private Link addAsParticipant; private TableController courseListCtr; private MembershipDataModel tableDataModel; private final CourseMembershipComparator membershipComparator = new CourseMembershipComparator(); @@ -130,7 +132,7 @@ public class CourseOverviewController extends BasicController { @Autowired private BusinessGroupService businessGroupService; - public CourseOverviewController(UserRequest ureq, WindowControl wControl, Identity identity) { + public CourseOverviewController(UserRequest ureq, WindowControl wControl, Identity identity, boolean canModify) { super(ureq, wControl, Util.createPackageTranslator(CourseMembership.class, ureq.getLocale())); this.setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); @@ -177,19 +179,22 @@ public class CourseOverviewController extends BasicController { if(isLastVisitVisible) { courseListCtr.addColumnDescriptor(new DefaultColumnDescriptor(MSCols.lastTime.i18n(), MSCols.lastTime.ordinal(), null, getLocale())); } - courseListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_EDIT, "table.header.edit", translate("table.header.edit"))); - courseListCtr.addColumnDescriptor(new BooleanColumnDescriptor(MSCols.allowLeave.i18n(), MSCols.allowLeave.ordinal(), TABLE_ACTION_UNSUBSCRIBE, translate("table.header.leave"), null)); - - courseListCtr.setMultiSelect(true); - courseListCtr.addMultiSelectAction("table.leave", TABLE_ACTION_UNSUBSCRIBE); + if(canModify) { + courseListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_EDIT, "table.header.edit", translate("table.header.edit"))); + courseListCtr.addColumnDescriptor(new BooleanColumnDescriptor(MSCols.allowLeave.i18n(), MSCols.allowLeave.ordinal(), TABLE_ACTION_UNSUBSCRIBE, translate("table.header.leave"), null)); + courseListCtr.setMultiSelect(true); + courseListCtr.addMultiSelectAction("table.leave", TABLE_ACTION_UNSUBSCRIBE); + } tableDataModel = new MembershipDataModel(); courseListCtr.setTableDataModel(tableDataModel); updateModel(); - addAsOwner = LinkFactory.createButton("add.course.owner", vc, this); - addAsTutor = LinkFactory.createButton("add.course.tutor", vc, this); - addAsParticipant = LinkFactory.createButton("add.course.participant", vc, this); + if(canModify) { + addAsOwner = LinkFactory.createButton("add.course.owner", vc, this); + addAsTutor = LinkFactory.createButton("add.course.tutor", vc, this); + addAsParticipant = LinkFactory.createButton("add.course.participant", vc, this); + } vc.put("table.courses", courseListCtr.getInitialComponent()); putInitialPanel(vc); @@ -762,7 +767,7 @@ public class CourseOverviewController extends BasicController { } public void addGroup(BusinessGroupShort group) { - if(groups == null) groups = new ArrayList<BusinessGroupShort>(); + if(groups == null) groups = new ArrayList<>(); groups.add(group); } @@ -771,7 +776,7 @@ public class CourseOverviewController extends BasicController { } public List<BusinessGroupShort> getGroups() { - return groups == null ? Collections.<BusinessGroupShort>emptyList() : new ArrayList<BusinessGroupShort>(groups); + return groups == null ? Collections.<BusinessGroupShort>emptyList() : new ArrayList<>(groups); } public boolean isFullyManaged() { diff --git a/src/main/java/org/olat/admin/user/course/_content/courseoverview.html b/src/main/java/org/olat/admin/user/course/_content/courseoverview.html index 6ab9edabba6d85fc68e131869cc8962531561148..d1af87668decf95a4c086ebec1a5f7a8d3c33034 100644 --- a/src/main/java/org/olat/admin/user/course/_content/courseoverview.html +++ b/src/main/java/org/olat/admin/user/course/_content/courseoverview.html @@ -1,8 +1,18 @@ <fieldset> <legend><i class="o_icon o_CourseModule_icon"> </i> $r.translate("add.courses.title")</legend> + #if($r.available("add.course.owner") || $r.available("add.course.tutor") || $r.available("add.course.participant")) <div class="o_button_group o_button_group_right"> - $r.render("add.course.owner") $r.render("add.course.tutor") $r.render("add.course.participant") + #if($r.available("add.course.owner")) + $r.render("add.course.owner") + #end + #if($r.available("add.course.tutor")) + $r.render("add.course.tutor") + #end + #if($r.available("add.course.participant")) + $r.render("add.course.participant") + #end </div> + #end $r.render("table.courses") </fieldset> diff --git a/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java b/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java index 2f76122412dc7d25ec6cb324a77a563d39b7b41c..09d3ad990d3067ce2047783f43818d86e5e3d7b7 100644 --- a/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java +++ b/src/main/java/org/olat/admin/user/groups/GroupOverviewController.java @@ -78,9 +78,9 @@ public class GroupOverviewController extends BasicController { private static final String TABLE_ACTION_LAUNCH = "bgTblLaunch"; private static final String TABLE_ACTION_UNSUBSCRIBE = "unsubscribe"; - private VelocityContainer vc; - private TableController groupListCtr; - private BusinessGroupTableModelWithType tableDataModel; + private final VelocityContainer vc; + private final TableController groupListCtr; + private final BusinessGroupTableModelWithType tableDataModel; private Link addGroups; private DialogBoxController confirmSendMailBox; @@ -93,7 +93,7 @@ public class GroupOverviewController extends BasicController { private final Identity identity; - public GroupOverviewController(UserRequest ureq, WindowControl control, Identity identity, Boolean canStartGroups) { + public GroupOverviewController(UserRequest ureq, WindowControl control, Identity identity, boolean canEdit) { super(ureq, control, Util.createPackageTranslator(BusinessGroupTableModelWithType.class, ureq.getLocale())); setTranslator(Util.createPackageTranslator(BGRoleCellRenderer.class, getLocale(), getTranslator())); @@ -105,23 +105,25 @@ public class GroupOverviewController extends BasicController { groupListCtr = new TableController(null, ureq, control, getTranslator()); listenTo(groupListCtr); - groupListCtr.addColumnDescriptor(new BusinessGroupNameColumnDescriptor(canStartGroups ? TABLE_ACTION_LAUNCH : null, getLocale())); + groupListCtr.addColumnDescriptor(new BusinessGroupNameColumnDescriptor(TABLE_ACTION_LAUNCH, getLocale())); groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.key.i18n(), Cols.key.ordinal(), null, getLocale())); groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.firstTime.i18n(), Cols.firstTime.ordinal(), null, getLocale())); groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.lastTime.i18n(), Cols.lastTime.ordinal(), null, getLocale())); CustomCellRenderer roleRenderer = new BGRoleCellRenderer(getLocale()); groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.role.i18n(), Cols.role.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, roleRenderer)); - groupListCtr.addColumnDescriptor(new BooleanColumnDescriptor(Cols.allowLeave.i18n(), Cols.allowLeave.ordinal(), TABLE_ACTION_UNSUBSCRIBE, translate("table.header.leave"), null)); + if(canEdit) { + groupListCtr.addColumnDescriptor(new BooleanColumnDescriptor(Cols.allowLeave.i18n(), Cols.allowLeave.ordinal(), + TABLE_ACTION_UNSUBSCRIBE, translate("table.header.leave"), null)); + + groupListCtr.setMultiSelect(true); + groupListCtr.addMultiSelectAction("table.leave", TABLE_ACTION_UNSUBSCRIBE); + addGroups = LinkFactory.createButton("add.groups", vc, this); + } - groupListCtr.setMultiSelect(true); - groupListCtr.addMultiSelectAction("table.leave", TABLE_ACTION_UNSUBSCRIBE); tableDataModel = new BusinessGroupTableModelWithType(getTranslator(), 4); - groupListCtr.setTableDataModel(tableDataModel); - - updateModel(); - - addGroups = LinkFactory.createButton("add.groups", vc, this); + groupListCtr.setTableDataModel(tableDataModel); vc.put("table.groups", groupListCtr.getInitialComponent()); + updateModel(); putInitialPanel(vc); } @@ -165,17 +167,11 @@ public class GroupOverviewController extends BasicController { groupListCtr.modelChanged(); } - /** - * @see org.olat.core.gui.control.DefaultController#doDispose() - */ @Override protected void doDispose() { // } - /** - * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event) - */ @Override protected void event( UserRequest ureq, Component source, Event event) { if (source == addGroups){ @@ -187,10 +183,7 @@ public class GroupOverviewController extends BasicController { cmc.activate(); } } - - /** - * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event) - */ + @Override protected void event(UserRequest ureq, Controller source, Event event) { super.event(ureq, source, event); diff --git a/src/main/java/org/olat/admin/user/groups/_content/groupoverview.html b/src/main/java/org/olat/admin/user/groups/_content/groupoverview.html index 60d62107a5ce194a476ebee46223f2dab09d00a6..61974e03c9ece31cec69f19cc4542c993f022b35 100644 --- a/src/main/java/org/olat/admin/user/groups/_content/groupoverview.html +++ b/src/main/java/org/olat/admin/user/groups/_content/groupoverview.html @@ -1,7 +1,9 @@ <fieldset> <legend><i class="o_icon o_icon_group"> </i> $r.translate("add.groups.title")</legend> + #if($r.available("add.groups")) <div class="o_button_group o_button_group_right"> $r.render("add.groups") </div> + #end $r.render("table.groups") </fieldset> diff --git a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java index c3212552e9a03473adfbf50e7b42f8011ddc52b4..afc4008d6e11ca988e41f6dbe8806110c134dfdd 100644 --- a/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java +++ b/src/main/java/org/olat/course/certificate/ui/CertificateAndEfficiencyStatementListController.java @@ -110,8 +110,9 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo private DialogBoxController confirmDeleteCtr; private ArtefactWizzardStepsController ePFCollCtrl; + private final boolean canModify; private final boolean linkToCoachingTool; - private Identity assessedIdentity; + private final Identity assessedIdentity; @Autowired private EfficiencyStatementManager esm; @@ -129,13 +130,14 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo private EfficiencyStatementMediaHandler mediaHandler; public CertificateAndEfficiencyStatementListController(UserRequest ureq, WindowControl wControl) { - this(ureq, wControl, ureq.getUserSession().getIdentity(), false); + this(ureq, wControl, ureq.getUserSession().getIdentity(), false, true); } public CertificateAndEfficiencyStatementListController(UserRequest ureq, WindowControl wControl, - Identity assessedIdentity, boolean linkToCoachingTool) { + Identity assessedIdentity, boolean linkToCoachingTool, boolean canModify) { super(ureq, wControl, "cert_statement_list"); setTranslator(Util.createPackageTranslator(AssessmentModule.class, getLocale(), getTranslator())); + this.canModify = canModify; this.assessedIdentity = assessedIdentity; this.linkToCoachingTool = linkToCoachingTool; @@ -196,21 +198,25 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.launchcourse", translate("table.header.launchcourse"), CMD_LAUNCH_COURSE)); - DefaultFlexiColumnModel deleteColumn = new DefaultFlexiColumnModel(Cols.deleteEfficiencyStatement.i18nHeaderKey(), Cols.deleteEfficiencyStatement.ordinal(), CMD_DELETE, - new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("table.action.delete"), CMD_DELETE), null)); - tableColumnModel.addFlexiColumnModel(deleteColumn); + if(canModify) { + DefaultFlexiColumnModel deleteColumn = new DefaultFlexiColumnModel(Cols.deleteEfficiencyStatement.i18nHeaderKey(), Cols.deleteEfficiencyStatement.ordinal(), CMD_DELETE, + new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("table.action.delete"), CMD_DELETE), null)); + tableColumnModel.addFlexiColumnModel(deleteColumn); + } //artefact - if(portfolioV2Module.isEnabled()) { - tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.artefact", - Cols.efficiencyStatement.ordinal(), CMD_MEDIA, - new StaticFlexiCellRenderer(CMD_MEDIA, new AsArtefactCellRenderer()))); - } else { - EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE); - if(portfolioModule.isEnabled() && artHandler != null && artHandler.isEnabled() && assessedIdentity.equals(getIdentity())) { + if(assessedIdentity.equals(getIdentity())) { + if(portfolioV2Module.isEnabled()) { tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.artefact", - Cols.efficiencyStatement.ordinal(), CMD_ARTEFACT, - new StaticFlexiCellRenderer(CMD_ARTEFACT, new AsArtefactCellRenderer()))); + Cols.efficiencyStatement.ordinal(), CMD_MEDIA, + new StaticFlexiCellRenderer(CMD_MEDIA, new AsArtefactCellRenderer()))); + } else { + EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE); + if(portfolioModule.isEnabled() && artHandler != null && artHandler.isEnabled() && assessedIdentity.equals(getIdentity())) { + tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.artefact", + Cols.efficiencyStatement.ordinal(), CMD_ARTEFACT, + new StaticFlexiCellRenderer(CMD_ARTEFACT, new AsArtefactCellRenderer()))); + } } } diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/ItemSessionControlController.java b/src/main/java/org/olat/ims/qti21/ui/editor/ItemSessionControlController.java index 3848d9073e9f36b9550ad130f69066dbaacd46a8..379d4230a3591046004619e70ce610c38556c26e 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/ItemSessionControlController.java +++ b/src/main/java/org/olat/ims/qti21/ui/editor/ItemSessionControlController.java @@ -154,7 +154,7 @@ public abstract class ItemSessionControlController extends FormBasicController { showSolutionEl.select(key, true); } else { String key = allowInherit ? INHERIT : NO; - showSolutionEl.select(key, false); + showSolutionEl.select(key, true); } } diff --git a/src/main/java/org/olat/modules/coach/ui/CoachMainController.java b/src/main/java/org/olat/modules/coach/ui/CoachMainController.java index 8d80f0dd938357ac754157c95de9e2351ff62625..8de1b949492a1afe3574aba0269d3177b18aa9fe 100644 --- a/src/main/java/org/olat/modules/coach/ui/CoachMainController.java +++ b/src/main/java/org/olat/modules/coach/ui/CoachMainController.java @@ -69,16 +69,21 @@ public class CoachMainController extends MainLayoutBasicController implements Ac private LayoutMain3ColsController columnLayoutCtr; private LecturesSearchController lecturesSearchCtrl; + private final boolean userSearch; + @Autowired private LectureModule lectureModule; public CoachMainController(UserRequest ureq, WindowControl control) { super(ureq, control); + + Roles roles = ureq.getUserSession().getRoles(); + userSearch = roles.isUserManager() || roles.isRolesManager() || roles.isAdministrator() || roles.isPrincipal(); menu = new MenuTree(null, "coachMenu", this); menu.setExpandSelectedNode(false); menu.setRootVisible(false); - menu.setTreeModel(buildTreeModel(ureq)); + menu.setTreeModel(buildTreeModel()); content = new TooledStackedPanel("coaching-stack", getTranslator(), this); content.setNeverDisposeRootController(true); @@ -152,7 +157,7 @@ public class CoachMainController extends MainLayoutBasicController implements Ac listenTo(courseListCtrl); } selectedCtrl = courseListCtrl; - } else if("lectures".equalsIgnoreCase(cmd)) { + } else if("lectures".equalsIgnoreCase(cmd) && lectureModule.isEnabled()) { if(lecturesSearchCtrl == null) { OLATResourceable ores = OresHelper.createOLATResourceableInstance("Lectures", 0l); ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); @@ -161,7 +166,7 @@ public class CoachMainController extends MainLayoutBasicController implements Ac listenTo(lecturesSearchCtrl); } selectedCtrl = lecturesSearchCtrl; - } else if("search".equalsIgnoreCase(cmd)) { + } else if("search".equalsIgnoreCase(cmd) && userSearch) { if(userSearchCtrl == null) { OLATResourceable ores = OresHelper.createOLATResourceableInstance("Search", 0l); ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); @@ -173,18 +178,21 @@ public class CoachMainController extends MainLayoutBasicController implements Ac } if(selectedCtrl != null) { + String title = "Root"; TreeNode selTreeNode = TreeHelper.findNodeByUserObject(cmd, menu.getTreeModel().getRootNode()); - if (selTreeNode != null && !selTreeNode.getIdent().equals(menu.getSelectedNodeId())) { - menu.setSelectedNodeId(selTreeNode.getIdent()); + if (selTreeNode != null) { + title = selTreeNode.getTitle(); + if(!selTreeNode.getIdent().equals(menu.getSelectedNodeId())) { + menu.setSelectedNodeId(selTreeNode.getIdent()); + } } - - content.rootController(selTreeNode.getTitle(), selectedCtrl); + content.rootController(title, selectedCtrl); addToHistory(ureq, selectedCtrl); } return (Activateable2)selectedCtrl; } - private TreeModel buildTreeModel(UserRequest ureq) { + private TreeModel buildTreeModel() { GenericTreeModel gtm = new GenericTreeModel(); GenericTreeNode root = new GenericTreeNode(); gtm.setRootNode(root); @@ -215,8 +223,7 @@ public class CoachMainController extends MainLayoutBasicController implements Ac root.addChild(lectures); } - Roles roles = ureq.getUserSession().getRoles(); - if(roles.isUserManager() || roles.isRolesManager() || roles.isAdministrator()) { + if(userSearch) { GenericTreeNode search = new GenericTreeNode(); search.setUserObject("Search"); search.setTitle(translate("search.menu.title")); diff --git a/src/main/java/org/olat/modules/taxonomy/ui/IdentityCompetencesController.java b/src/main/java/org/olat/modules/taxonomy/ui/IdentityCompetencesController.java index dd2498f33600a8e4cf6d2458b3d19a2ab15bd271..d2e5661eff7eae8088f974f0c7d3d2a3dd67f69a 100644 --- a/src/main/java/org/olat/modules/taxonomy/ui/IdentityCompetencesController.java +++ b/src/main/java/org/olat/modules/taxonomy/ui/IdentityCompetencesController.java @@ -68,21 +68,26 @@ public class IdentityCompetencesController extends FormBasicController implement private FlexiTableElement tableEl; private IdentityCompetenceTableModel tableModel; - private FormLink addManageButton, addTeachButton, addHaveButton, addTargetButton; + private FormLink addManageButton; + private FormLink addTeachButton; + private FormLink addHaveButton; + private FormLink addTargetButton; private CloseableModalController cmc; private SelectTaxonomyLevelController levelsSearchCtrl; private DialogBoxController removeCompentenceConfirmationCtrl; - private Identity assessedIdentity; + private final boolean canModify; + private final Identity assessedIdentity; @Autowired private UserManager userManager; @Autowired private TaxonomyService taxonomyService; - public IdentityCompetencesController(UserRequest ureq, WindowControl wControl, Identity assessedIdentity) { + public IdentityCompetencesController(UserRequest ureq, WindowControl wControl, Identity assessedIdentity, boolean canModify) { super(ureq, wControl, "identity_competences"); + this.canModify = canModify; this.assessedIdentity = assessedIdentity; setTranslator(userManager.getPropertyHandlerTranslator(getTranslator())); @@ -92,17 +97,18 @@ public class IdentityCompetencesController extends FormBasicController implement @Override public void setBreadcrumbPanel(BreadcrumbPanel stackPanel) { - //this.stackPanel = stackPanel; + // } @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - addManageButton = uifactory.addFormLink("add.competence.manage", formLayout, Link.BUTTON); - addTeachButton = uifactory.addFormLink("add.competence.teach", formLayout, Link.BUTTON); - addHaveButton = uifactory.addFormLink("add.competence.have", formLayout, Link.BUTTON); - addTargetButton = uifactory.addFormLink("add.competence.target", formLayout, Link.BUTTON); + if(canModify) { + addManageButton = uifactory.addFormLink("add.competence.manage", formLayout, Link.BUTTON); + addTeachButton = uifactory.addFormLink("add.competence.teach", formLayout, Link.BUTTON); + addHaveButton = uifactory.addFormLink("add.competence.have", formLayout, Link.BUTTON); + addTargetButton = uifactory.addFormLink("add.competence.target", formLayout, Link.BUTTON); + } - // table FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel(); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, IdCompetenceCols.key)); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, IdCompetenceCols.taxonomyIdentifier)); @@ -114,9 +120,10 @@ public class IdentityCompetencesController extends FormBasicController implement columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdCompetenceCols.taxonomyLevelType)); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdCompetenceCols.type, new TaxonomyCompetenceTypeRenderer(getTranslator()))); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdCompetenceCols.expiration, new DateFlexiCellRenderer(getLocale()))); - columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("remove", IdCompetenceCols.remove.ordinal(), "remove", + if(canModify) { + columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("remove", IdCompetenceCols.remove.ordinal(), "remove", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("remove"), "remove"), null))); - + } tableModel = new IdentityCompetenceTableModel(columnsModel); tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout); tableEl.setCustomizeColumns(true); @@ -126,7 +133,7 @@ public class IdentityCompetencesController extends FormBasicController implement private void loadModel() { List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(assessedIdentity); List<IdentityCompetenceRow> rows = competences.stream() - .map(c -> new IdentityCompetenceRow(c)) + .map(IdentityCompetenceRow::new) .collect(Collectors.toList()); tableModel.setObjects(rows); tableEl.reset(false, true, true); diff --git a/src/main/java/org/olat/repository/ui/author/OverviewAuthoringController.java b/src/main/java/org/olat/repository/ui/author/OverviewAuthoringController.java index e77ac4dded21f73f2c9a598c1d198b89534120ae..494748e1c4bb1b44b08fab512c2d3f7b52743b35 100644 --- a/src/main/java/org/olat/repository/ui/author/OverviewAuthoringController.java +++ b/src/main/java/org/olat/repository/ui/author/OverviewAuthoringController.java @@ -35,11 +35,11 @@ import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.generic.dtabs.Activateable2; import org.olat.core.id.OLATResourceable; +import org.olat.core.id.Roles; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; -import org.olat.core.util.UserSession; import org.olat.core.util.Util; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.EventBus; @@ -63,8 +63,10 @@ public class OverviewAuthoringController extends BasicController implements Acti private MainPanel mainPanel; private final VelocityContainer mainVC; private final SegmentViewComponent segmentView; + private Link deletedLink; private Link favoriteLink; - private final Link myEntriesLink, searchLink, deletedLink; + private final Link searchLink; + private final Link myEntriesLink; private AuthorListController currentCtrl, markedCtrl, myEntriesCtrl, searchEntriesCtrl; private AuthorDeletedListController deletedEntriesCtrl; @@ -77,9 +79,9 @@ public class OverviewAuthoringController extends BasicController implements Acti super(ureq, wControl); setTranslator(Util.createPackageTranslator(RepositoryManager.class, getLocale(), getTranslator())); - UserSession usess = ureq.getUserSession(); - isGuestOnly = usess.getRoles().isGuestOnly(); - isAdministrator = usess.getRoles().isAdministrator() || usess.getRoles().isLearnResourceManager(); + Roles roles = ureq.getUserSession().getRoles(); + isGuestOnly = roles.isGuestOnly(); + isAdministrator = roles.isAdministrator() || roles.isLearnResourceManager(); mainPanel = new MainPanel("authoringMainPanel"); mainPanel.setDomReplaceable(false); @@ -97,8 +99,10 @@ public class OverviewAuthoringController extends BasicController implements Acti segmentView.addSegment(myEntriesLink, false); searchLink = LinkFactory.createLink("search.generic", mainVC, this); segmentView.addSegment(searchLink, false); - deletedLink = LinkFactory.createLink("search.deleted", mainVC, this); - segmentView.addSegment(deletedLink, false); + if(roles.isAuthor() || isAdministrator) { + deletedLink = LinkFactory.createLink("search.deleted", mainVC, this); + segmentView.addSegment(deletedLink, false); + } eventBus = ureq.getUserSession().getSingleUserEventCenter(); eventBus.registerFor(this, getIdentity(), RepositoryService.REPOSITORY_EVENT_ORES); @@ -192,7 +196,7 @@ public class OverviewAuthoringController extends BasicController implements Acti } else if("Search".equals(segment)) { doSearchEntries(ureq).activate(ureq, subEntries, entry.getTransientState()); segmentView.select(searchLink); - } else if("Deleted".equals(segment)) { + } else if("Deleted".equals(segment) && deletedLink != null) { doOpenDeletedEntries(ureq).activate(ureq, subEntries, entry.getTransientState()); segmentView.select(deletedLink); } else { diff --git a/src/main/java/org/olat/user/ProfileAndHomePageEditController.java b/src/main/java/org/olat/user/ProfileAndHomePageEditController.java index b5555879ff7256376a558820f1b73bf50b5eb5d9..69da5d3ef7230395b763e4d675a45a7e3a4e9a89 100644 --- a/src/main/java/org/olat/user/ProfileAndHomePageEditController.java +++ b/src/main/java/org/olat/user/ProfileAndHomePageEditController.java @@ -160,7 +160,8 @@ public class ProfileAndHomePageEditController extends BasicController implements private ProfileFormController doOpenProfile(UserRequest ureq) { if(profileFormController == null) { - profileFormController = new ProfileFormController(ureq, getWindowControl(), identityToModify, isAdministrativeUser); + profileFormController = new ProfileFormController(ureq, getWindowControl(), + identityToModify, isAdministrativeUser, true); listenTo(profileFormController); } diff --git a/src/main/java/org/olat/user/ProfileFormController.java b/src/main/java/org/olat/user/ProfileFormController.java index 450007b48ef2a044533e61c532e2fcf6837ed08f..867cd3351483fbef3e07d958b7a28a17276343f5 100644 --- a/src/main/java/org/olat/user/ProfileFormController.java +++ b/src/main/java/org/olat/user/ProfileFormController.java @@ -95,6 +95,7 @@ public class ProfileFormController extends FormBasicController { private FileElement logoUpload; private FileElement portraitUpload; + private final boolean canModify; private final boolean logoEnabled; private final boolean isAdministrativeUser; private final List<UserPropertyHandler> userPropertyHandlers; @@ -128,7 +129,7 @@ public class ProfileFormController extends FormBasicController { * @param wControl */ public ProfileFormController(UserRequest ureq, WindowControl wControl) { - this(ureq, wControl, ureq.getIdentity(), false); + this(ureq, wControl, ureq.getIdentity(), false, true); } /** @@ -143,11 +144,11 @@ public class ProfileFormController extends FormBasicController { * user manager; false: use is editing his own profile */ public ProfileFormController(UserRequest ureq, WindowControl wControl, - Identity identityToModify, boolean isAdministrativeUser) { + Identity identityToModify, boolean isAdministrativeUser, boolean canModify) { super(ureq, wControl, LAYOUT_BAREBONE); setTranslator(userManager.getPropertyHandlerTranslator(getTranslator())); setFormStyle("o_user_profile_form"); - + this.canModify = canModify; this.identityToModify = identityToModify; logoEnabled = userModule.isLogoByProfileEnabled(); @@ -194,6 +195,10 @@ public class ProfileFormController extends FormBasicController { // add input field to container FormItem formItem = userPropertyHandler.addFormItem(getLocale(), user, usageIdentifier, isAdministrativeUser, groupContainer); + if(formItem.isEnabled() && !canModify) { + formItem.setEnabled(canModify); + } + String propertyName = userPropertyHandler.getName(); formItems.put(propertyName, formItem); @@ -239,6 +244,7 @@ public class ProfileFormController extends FormBasicController { textAboutMe = uifactory.addRichTextElementForStringData("form.text", "form.text", conf.getTextAboutMe(), 10, -1, false, null, null, groupContainer, ureq.getUserSession(), getWindowControl()); + textAboutMe.setEnabled(canModify); textAboutMe.setMaxLength(10000); //upload image @@ -260,6 +266,7 @@ public class ProfileFormController extends FormBasicController { portraitUpload.addActionListener(FormEvent.ONCHANGE); portraitUpload.setHelpTextKey("ul.select.fhelp", null); portraitUpload.setDeleteEnabled(true); + portraitUpload.setEnabled(canModify); if(portraitFile != null) { portraitUpload.setInitialFile(portraitFile); } @@ -278,6 +285,7 @@ public class ProfileFormController extends FormBasicController { logoUpload.addActionListener(FormEvent.ONCHANGE); logoUpload.setHelpTextKey("ul.select.fhelp", null); logoUpload.setDeleteEnabled(true); + logoUpload.setEnabled(canModify); if(logoFile != null) { logoUpload.setInitialFile(logoFile); } @@ -289,7 +297,9 @@ public class ProfileFormController extends FormBasicController { formLayout.add(buttonLayoutWrappper); FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayoutInner", getTranslator()); buttonLayoutWrappper.add(buttonLayout); - uifactory.addFormSubmitButton("save", buttonLayout); + if(canModify) { + uifactory.addFormSubmitButton("save", buttonLayout); + } uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl()); } diff --git a/src/main/java/org/olat/user/propertyhandlers/UserInterestsRenderer.java b/src/main/java/org/olat/user/propertyhandlers/UserInterestsRenderer.java index c05982fd85548a1378132975e3f8e2da0a363f54..bbbb252abe62b280eecd08021cfe85f45a780b3d 100644 --- a/src/main/java/org/olat/user/propertyhandlers/UserInterestsRenderer.java +++ b/src/main/java/org/olat/user/propertyhandlers/UserInterestsRenderer.java @@ -44,7 +44,7 @@ class UserInterestsRenderer extends DefaultComponentRenderer { UserInterestsComponent uiCmp = (UserInterestsComponent)source; UserInterestsElement uiFte = uiCmp.getUserInterestsElement(); List<String> userInterests = uiFte.getUserInterests(); - if(userInterests.size() > 0) { + if(!userInterests.isEmpty()) { sb.append("<ul class='list-unstyled'>"); for(String userInterest:userInterests) { sb.append("<li>").append(userInterest).append("</li>"); @@ -52,10 +52,12 @@ class UserInterestsRenderer extends DefaultComponentRenderer { sb.append("</ul>"); } - FormLink editLink = uiFte.getEditLink(); - if(editLink != null && editLink.isVisible()) { - Component cmp = editLink.getComponent(); - cmp.getHTMLRendererSingleton().render(renderer, sb, cmp, ubu, translator, renderResult, args); + if(uiCmp.isEnabled()) { + FormLink editLink = uiFte.getEditLink(); + if(editLink != null && editLink.isVisible()) { + Component cmp = editLink.getComponent(); + cmp.getHTMLRendererSingleton().render(renderer, sb, cmp, ubu, translator, renderResult, args); + } } } } diff --git a/src/main/java/org/olat/user/propertyhandlers/ui/SmsPhoneComponentRenderer.java b/src/main/java/org/olat/user/propertyhandlers/ui/SmsPhoneComponentRenderer.java index d725db686ae685a63db690ef3901579aaf957080..e832e16c70fa5514488324f1c94bff1a39d8ec1d 100644 --- a/src/main/java/org/olat/user/propertyhandlers/ui/SmsPhoneComponentRenderer.java +++ b/src/main/java/org/olat/user/propertyhandlers/ui/SmsPhoneComponentRenderer.java @@ -62,21 +62,23 @@ public class SmsPhoneComponentRenderer extends DefaultComponentRenderer { FormJSHelper.setFlexiFormDirtyOnLoad(sb, smsFte.getRootForm()); } - sb.append("<div class='form-inline'>"); - FormLink editLink = smsFte.getEditLink(); - if(editLink != null && editLink.isVisible()) { - Component cmp = editLink.getComponent(); - cmp.getHTMLRendererSingleton().render(renderer, sb, cmp, ubu, translator, renderResult, args); - } - - if(StringHelper.containsNonWhitespace(phoneNumber)) { - sb.append(" "); - FormLink removeLink = smsFte.getRemoveLink(); - if(removeLink != null && removeLink.isVisible()) { - Component cmp = removeLink.getComponent(); + if(smsCmp.isEnabled()) { + sb.append("<div class='form-inline'>"); + FormLink editLink = smsFte.getEditLink(); + if(editLink != null && editLink.isVisible()) { + Component cmp = editLink.getComponent(); cmp.getHTMLRendererSingleton().render(renderer, sb, cmp, ubu, translator, renderResult, args); } + + if(StringHelper.containsNonWhitespace(phoneNumber)) { + sb.append(" "); + FormLink removeLink = smsFte.getRemoveLink(); + if(removeLink != null && removeLink.isVisible()) { + Component cmp = removeLink.getComponent(); + cmp.getHTMLRendererSingleton().render(renderer, sb, cmp, ubu, translator, renderResult, args); + } + } + sb.append("</div>"); } - sb.append("</div>"); } }