diff --git a/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallback.java b/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallback.java index 667901bbec992f58ff964cba350f711c2ff67e07..036ee56e7c65e07f671765a4d1c0d139a9453d77 100644 --- a/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallback.java +++ b/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallback.java @@ -31,8 +31,16 @@ public interface CurriculumSecurityCallback { public boolean canEditCurriculum(); + public boolean canManagerCurriculumUsers(); + public boolean canNewCurriculumElement(); public boolean canEditCurriculumElement(); + + public boolean canManagerCurriculumElementUsers(); + + public boolean canManagerCurriculumElementResources(); + + } diff --git a/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallbackFactory.java b/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallbackFactory.java index ae586b3513063ec6ec3ae78f37fd32c6cf2d631d..6bc8c423e7d91c494bf79d879ba8edb06c27d15e 100644 --- a/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallbackFactory.java +++ b/src/main/java/org/olat/modules/curriculum/CurriculumSecurityCallbackFactory.java @@ -56,6 +56,11 @@ public class CurriculumSecurityCallbackFactory { return admin; } + @Override + public boolean canManagerCurriculumUsers() { + return admin; + } + @Override public boolean canNewCurriculumElement() { return admin; @@ -65,6 +70,15 @@ public class CurriculumSecurityCallbackFactory { public boolean canEditCurriculumElement() { return admin; } - + + @Override + public boolean canManagerCurriculumElementUsers() { + return admin; + } + + @Override + public boolean canManagerCurriculumElementResources() { + return admin; + } } } diff --git a/src/main/java/org/olat/modules/curriculum/ui/CurriculumComposerController.java b/src/main/java/org/olat/modules/curriculum/ui/CurriculumComposerController.java index 40e2fc9bb0b7613295f93f598a65fe42c5dcba70..15bc47dfec4fbe68fd1fe69257f7eebe35af4647 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/CurriculumComposerController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/CurriculumComposerController.java @@ -57,6 +57,7 @@ import org.olat.core.util.resource.OresHelper; import org.olat.modules.curriculum.Curriculum; import org.olat.modules.curriculum.CurriculumElement; import org.olat.modules.curriculum.CurriculumElementManagedFlag; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.olat.modules.curriculum.model.CurriculumElementInfos; import org.olat.modules.curriculum.ui.CurriculumComposerTableModel.ElementCols; @@ -89,24 +90,28 @@ public class CurriculumComposerController extends FormBasicController implements private int counter; private final Curriculum curriculum; + private final CurriculumSecurityCallback secCallback; @Autowired private CurriculumService curriculumService; public CurriculumComposerController(UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbarPanel, - Curriculum curriculum) { + Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl, "manage_curriculum_structure"); this.toolbarPanel = toolbarPanel; this.curriculum = curriculum; + this.secCallback = secCallback; initForm(ureq); loadModel(); } @Override public void initTools() { - newElementButton = LinkFactory.createToolLink("add.curriculum.element", translate("add.curriculum.element"), this, "o_icon_add"); - newElementButton.setElementCssClass("o_sel_add_curriculum_element"); - toolbarPanel.addTool(newElementButton, Align.left); + if(secCallback.canNewCurriculumElement()) { + newElementButton = LinkFactory.createToolLink("add.curriculum.element", translate("add.curriculum.element"), this, "o_icon_add"); + newElementButton.setElementCssClass("o_sel_add_curriculum_element"); + toolbarPanel.addTool(newElementButton, Align.left); + } } @Override @@ -127,10 +132,12 @@ public class CurriculumComposerController extends FormBasicController implements selectColumn.setExportable(false); selectColumn.setAlwaysVisible(true); columnsModel.addFlexiColumnModel(selectColumn); - DefaultFlexiColumnModel toolsColumn = new DefaultFlexiColumnModel(ElementCols.tools); - toolsColumn.setExportable(false); - toolsColumn.setAlwaysVisible(true); - columnsModel.addFlexiColumnModel(toolsColumn); + if(secCallback.canEditCurriculumElement()) { + DefaultFlexiColumnModel toolsColumn = new DefaultFlexiColumnModel(ElementCols.tools); + toolsColumn.setExportable(false); + toolsColumn.setAlwaysVisible(true); + columnsModel.addFlexiColumnModel(toolsColumn); + } tableModel = new CurriculumComposerTableModel(columnsModel); tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout); @@ -247,7 +254,7 @@ public class CurriculumComposerController extends FormBasicController implements private void doNewCurriculumElement(UserRequest ureq) { if(newElementCtrl != null) return; - newElementCtrl = new EditCurriculumElementController(ureq, getWindowControl(), null, curriculum); + newElementCtrl = new EditCurriculumElementController(ureq, getWindowControl(), null, curriculum, secCallback); listenTo(newElementCtrl); cmc = new CloseableModalController(getWindowControl(), "close", newElementCtrl.getInitialComponent(), true, translate("add.curriculum.element")); @@ -261,7 +268,7 @@ public class CurriculumComposerController extends FormBasicController implements tableEl.reloadData(); showWarning("warning.curriculum.element.deleted"); } else { - newSubElementCtrl = new EditCurriculumElementController(ureq, getWindowControl(), parentElement, curriculum); + newSubElementCtrl = new EditCurriculumElementController(ureq, getWindowControl(), parentElement, curriculum, secCallback); newSubElementCtrl.setParentElement(parentElement); listenTo(newSubElementCtrl); @@ -278,7 +285,7 @@ public class CurriculumComposerController extends FormBasicController implements showWarning("warning.curriculum.element.deleted"); } else { WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(CurriculumElement.class, row.getKey()), null); - EditCurriculumElementOverviewController editCtrl = new EditCurriculumElementOverviewController(ureq, swControl, element, curriculum); + EditCurriculumElementOverviewController editCtrl = new EditCurriculumElementOverviewController(ureq, swControl, element, curriculum, secCallback); listenTo(editCtrl); toolbarPanel.pushController(row.getDisplayName(), editCtrl); } diff --git a/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementResourceListController.java b/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementResourceListController.java index c0d078f6ac75e65892c0aad2cd1306f6231d1157..498327f50dfa22432f2bb09799046473864bef31 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementResourceListController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementResourceListController.java @@ -48,6 +48,7 @@ import org.olat.core.util.Util; import org.olat.course.CourseModule; import org.olat.modules.curriculum.CurriculumElement; import org.olat.modules.curriculum.CurriculumElementManagedFlag; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryService; @@ -79,14 +80,16 @@ public class CurriculumElementResourceListController extends FormBasicController private final boolean resourcesManaged; private final CurriculumElement curriculumElement; + private final CurriculumSecurityCallback secCallback; @Autowired private CurriculumService curriculumService; - public CurriculumElementResourceListController(UserRequest ureq, WindowControl wControl, CurriculumElement curriculumElement) { + public CurriculumElementResourceListController(UserRequest ureq, WindowControl wControl, + CurriculumElement curriculumElement, CurriculumSecurityCallback secCallback) { super(ureq, wControl, "curriculum_element_resources"); setTranslator(Util.createPackageTranslator(RepositoryService.class, ureq.getLocale(), getTranslator())); - + this.secCallback = secCallback; this.curriculumElement = curriculumElement; resourcesManaged = CurriculumElementManagedFlag.isManaged(curriculumElement, CurriculumElementManagedFlag.resources); @@ -96,7 +99,7 @@ public class CurriculumElementResourceListController extends FormBasicController @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - if(!resourcesManaged) { + if(!resourcesManaged && secCallback.canManagerCurriculumElementResources()) { addResourcesButton = uifactory.addFormLink("add.resources", formLayout, Link.BUTTON); addResourcesButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add"); diff --git a/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementUserManagementController.java b/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementUserManagementController.java index 5383028e2101067d541bf75c367acf4a41cb3a9c..7454020299cc681dcd4dec6979d15fd4d0a484ee 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementUserManagementController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/CurriculumElementUserManagementController.java @@ -52,6 +52,7 @@ import org.olat.core.id.Identity; import org.olat.modules.curriculum.CurriculumElement; import org.olat.modules.curriculum.CurriculumElementManagedFlag; import org.olat.modules.curriculum.CurriculumRoles; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.olat.modules.curriculum.model.CurriculumMember; import org.olat.modules.curriculum.ui.CurriculumUserManagementTableModel.CurriculumMemberCols; @@ -87,6 +88,7 @@ public class CurriculumElementUserManagementController extends FormBasicControll private final CurriculumElement curriculumElement; private final boolean membersManaged; private final boolean isAdministrativeUser; + private final CurriculumSecurityCallback secCallback; private final List<UserPropertyHandler> userPropertyHandlers; @Autowired @@ -97,11 +99,13 @@ public class CurriculumElementUserManagementController extends FormBasicControll private CurriculumService curriculumService; - public CurriculumElementUserManagementController(UserRequest ureq, WindowControl wControl, CurriculumElement curriculumElement) { + public CurriculumElementUserManagementController(UserRequest ureq, WindowControl wControl, + CurriculumElement curriculumElement, CurriculumSecurityCallback secCallback) { super(ureq, wControl, "curriculum_element_user_mgmt"); setTranslator(userManager.getPropertyHandlerTranslator(getTranslator())); this.curriculumElement = curriculumElement; + this.secCallback = secCallback; isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles()); userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser); @@ -114,7 +118,7 @@ public class CurriculumElementUserManagementController extends FormBasicControll @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - if(!membersManaged) { + if(!membersManaged && secCallback.canManagerCurriculumElementUsers()) { addMemberButton = uifactory.addFormLink("add.member", formLayout, Link.BUTTON); addMemberButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add_member"); addMemberButton.setIconRightCSS("o_icon o_icon_caret"); diff --git a/src/main/java/org/olat/modules/curriculum/ui/CurriculumListManagerController.java b/src/main/java/org/olat/modules/curriculum/ui/CurriculumListManagerController.java index dfe40482db2e7234487ab334e7c35b2c0f2724f3..e9ba25903bef554edd0576d1611142df179c01a0 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/CurriculumListManagerController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/CurriculumListManagerController.java @@ -113,10 +113,12 @@ public class CurriculumListManagerController extends FormBasicController impleme DefaultFlexiColumnModel editCol = new DefaultFlexiColumnModel("edit.icon", translate("edit.icon"), "edit"); editCol.setExportable(false); columnsModel.addFlexiColumnModel(editCol); - DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(CurriculumCols.tools); - toolsCol.setExportable(false); - toolsCol.setAlwaysVisible(true); - columnsModel.addFlexiColumnModel(toolsCol); + if(secCallback.canEditCurriculum()) { + DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(CurriculumCols.tools); + toolsCol.setExportable(false); + toolsCol.setAlwaysVisible(true); + columnsModel.addFlexiColumnModel(toolsCol); + } tableModel = new CurriculumManagerDataModel(columnsModel, getLocale()); tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout); @@ -223,7 +225,7 @@ public class CurriculumListManagerController extends FormBasicController impleme private void doNewCurriculum(UserRequest ureq) { if(newCurriculumCtrl != null) return; - newCurriculumCtrl = new EditCurriculumController(ureq, getWindowControl()); + newCurriculumCtrl = new EditCurriculumController(ureq, getWindowControl(), secCallback); listenTo(newCurriculumCtrl); cmc = new CloseableModalController(getWindowControl(), "close", newCurriculumCtrl.getInitialComponent(), true, translate("add.curriculum")); @@ -238,7 +240,7 @@ public class CurriculumListManagerController extends FormBasicController impleme if(curriculum == null) { showWarning("warning.curriculum.deleted"); } else { - editCurriculumCtrl = new EditCurriculumOverviewController(ureq, getWindowControl(), curriculum); + editCurriculumCtrl = new EditCurriculumOverviewController(ureq, getWindowControl(), curriculum, secCallback); listenTo(editCurriculumCtrl); toolbarPanel.pushController(row.getDisplayName(), editCurriculumCtrl); } @@ -250,7 +252,7 @@ public class CurriculumListManagerController extends FormBasicController impleme showWarning("warning.curriculum.deleted"); } else { WindowControl swControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(Curriculum.class, row.getKey()), null); - CurriculumComposerController composerCtrl = new CurriculumComposerController(ureq, swControl, toolbarPanel, curriculum); + CurriculumComposerController composerCtrl = new CurriculumComposerController(ureq, swControl, toolbarPanel, curriculum, secCallback); listenTo(composerCtrl); toolbarPanel.pushController(row.getDisplayName(), composerCtrl); } diff --git a/src/main/java/org/olat/modules/curriculum/ui/CurriculumUserManagementController.java b/src/main/java/org/olat/modules/curriculum/ui/CurriculumUserManagementController.java index 09b1f2cf4727a43c2e8f063f94ccf2fd9bc71e9f..e67876398473787e48a37201ecd42a806736390f 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/CurriculumUserManagementController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/CurriculumUserManagementController.java @@ -52,6 +52,7 @@ import org.olat.core.id.Identity; import org.olat.modules.curriculum.Curriculum; import org.olat.modules.curriculum.CurriculumManagedFlag; import org.olat.modules.curriculum.CurriculumRoles; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.olat.modules.curriculum.model.CurriculumMember; import org.olat.modules.curriculum.ui.CurriculumUserManagementTableModel.CurriculumMemberCols; @@ -87,6 +88,7 @@ public class CurriculumUserManagementController extends FormBasicController { private final Curriculum curriculum; private final boolean membersManaged; private final boolean isAdministrativeUser; + private final CurriculumSecurityCallback secCallback; private final List<UserPropertyHandler> userPropertyHandlers; @Autowired @@ -96,11 +98,13 @@ public class CurriculumUserManagementController extends FormBasicController { @Autowired private CurriculumService curriculumService; - public CurriculumUserManagementController(UserRequest ureq, WindowControl wControl, Curriculum curriculum) { + public CurriculumUserManagementController(UserRequest ureq, WindowControl wControl, + Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl, "curriculum_element_user_mgmt"); setTranslator(userManager.getPropertyHandlerTranslator(getTranslator())); this.curriculum = curriculum; + this.secCallback = secCallback; isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles()); userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser); @@ -113,7 +117,7 @@ public class CurriculumUserManagementController extends FormBasicController { @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - if(!membersManaged) { + if(!membersManaged && secCallback.canManagerCurriculumUsers()) { addMemberButton = uifactory.addFormLink("add.member", formLayout, Link.BUTTON); addMemberButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add_member"); addMemberButton.setIconRightCSS("o_icon o_icon_caret"); diff --git a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumController.java b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumController.java index a251f9f1ab528622e8ede096a409815a4f806f9b..aa388b87ccfe14b093b5a2d57598b451aff0f3c4 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumController.java @@ -42,6 +42,7 @@ import org.olat.core.util.UserSession; import org.olat.modules.curriculum.Curriculum; import org.olat.modules.curriculum.CurriculumManagedFlag; import org.olat.modules.curriculum.CurriculumRoles; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.springframework.beans.factory.annotation.Autowired; @@ -59,6 +60,7 @@ public class EditCurriculumController extends FormBasicController { private SingleSelection organisationEl; private Curriculum curriculum; + private final CurriculumSecurityCallback secCallback; @Autowired private CurriculumService curriculumService; @@ -71,15 +73,17 @@ public class EditCurriculumController extends FormBasicController { * @param ureq The user request * @param wControl The window control */ - public EditCurriculumController(UserRequest ureq, WindowControl wControl) { + public EditCurriculumController(UserRequest ureq, WindowControl wControl, CurriculumSecurityCallback secCallback) { super(ureq, wControl); curriculum = null; + this.secCallback = secCallback; initForm(ureq); } - public EditCurriculumController(UserRequest ureq, WindowControl wControl, Curriculum curriculum) { + public EditCurriculumController(UserRequest ureq, WindowControl wControl, Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl); this.curriculum = curriculum; + this.secCallback = secCallback; initForm(ureq); } @@ -98,12 +102,12 @@ public class EditCurriculumController extends FormBasicController { String identifier = curriculum == null ? "" : curriculum.getIdentifier(); identifierEl = uifactory.addTextElement("curriculum.identifier", "curriculum.identifier", 255, identifier, formLayout); - identifierEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.identifier)); + identifierEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.identifier) && secCallback.canEditCurriculum()); identifierEl.setMandatory(true); String displayName = curriculum == null ? "" : curriculum.getDisplayName(); displayNameEl = uifactory.addTextElement("curriculum.displayName", "curriculum.displayName", 255, displayName, formLayout); - displayNameEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.displayName)); + displayNameEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.displayName) && secCallback.canEditCurriculum()); displayNameEl.setMandatory(true); initFormOrganisations(formLayout, ureq.getUserSession()); @@ -111,12 +115,14 @@ public class EditCurriculumController extends FormBasicController { String description = curriculum == null ? "" : curriculum.getDescription(); descriptionEl = uifactory.addRichTextElementForStringDataCompact("curriculum.description", "curriculum.description", description, 10, 60, null, formLayout, ureq.getUserSession(), getWindowControl()); - descriptionEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.description)); + descriptionEl.setEnabled(!CurriculumManagedFlag.isManaged(curriculum, CurriculumManagedFlag.description) && secCallback.canEditCurriculum()); FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); formLayout.add(buttonsCont); uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl()); - uifactory.addFormSubmitButton("save", buttonsCont); + if(secCallback.canEditCurriculum()) { + uifactory.addFormSubmitButton("save", buttonsCont); + } } private void initFormOrganisations(FormItemContainer formLayout, UserSession usess) { @@ -130,10 +136,20 @@ public class EditCurriculumController extends FormBasicController { keyList.add(organisation.getKey().toString()); valueList.add(organisation.getDisplayName()); } + + String selectedOrganisationKey = null; + if(curriculum != null && curriculum.getOrganisation() != null) { + selectedOrganisationKey = curriculum.getOrganisation().getKey().toString(); + if(!keyList.contains(selectedOrganisationKey)) { + keyList.add(selectedOrganisationKey); + valueList.add(curriculum.getOrganisation().getDisplayName()); + } + } + organisationEl = uifactory.addDropdownSingleselect("curriculum.organisation", formLayout, keyList.toArray(new String[keyList.size()]), valueList.toArray(new String[valueList.size()])); - if(curriculum != null && curriculum.getOrganisation() != null) { - organisationEl.select(curriculum.getOrganisation().getKey().toString(), true); + if(selectedOrganisationKey != null && keyList.contains(selectedOrganisationKey)) { + organisationEl.select(selectedOrganisationKey, true); } } @@ -144,7 +160,7 @@ public class EditCurriculumController extends FormBasicController { @Override protected boolean validateFormLogic(UserRequest ureq) { - boolean allOk = true; + boolean allOk = super.validateFormLogic(ureq); displayNameEl.clearError(); if(!StringHelper.containsNonWhitespace(displayNameEl.getValue())) { @@ -158,7 +174,7 @@ public class EditCurriculumController extends FormBasicController { allOk &= false; } - return allOk & super.validateFormLogic(ureq); + return allOk; } @Override diff --git a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementController.java b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementController.java index 64a82af205cc35d49e370fd5107479a147925832..509a7e3b8864f7261e1491840d1f4616c104eaf7 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementController.java @@ -41,6 +41,7 @@ import org.olat.modules.curriculum.CurriculumElement; import org.olat.modules.curriculum.CurriculumElementManagedFlag; import org.olat.modules.curriculum.CurriculumElementType; import org.olat.modules.curriculum.CurriculumElementTypeToType; +import org.olat.modules.curriculum.CurriculumSecurityCallback; import org.olat.modules.curriculum.CurriculumService; import org.olat.modules.curriculum.model.CurriculumElementTypeRefImpl; import org.olat.modules.taxonomy.TaxonomyLevel; @@ -66,6 +67,7 @@ public class EditCurriculumElementController extends FormBasicController { private Curriculum curriculum; private CurriculumElement element; private CurriculumElement parentElement; + private final CurriculumSecurityCallback secCallback; @Autowired private CurriculumService curriculumService; @@ -77,19 +79,21 @@ public class EditCurriculumElementController extends FormBasicController { * @param wControl The window control */ public EditCurriculumElementController(UserRequest ureq, WindowControl wControl, - CurriculumElement parentElement, Curriculum curriculum) { + CurriculumElement parentElement, Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl); this.curriculum = curriculum; this.parentElement = parentElement; + this.secCallback = secCallback; initForm(ureq); } public EditCurriculumElementController(UserRequest ureq, WindowControl wControl, - CurriculumElement element, CurriculumElement parentElement, Curriculum curriculum) { + CurriculumElement element, CurriculumElement parentElement, Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl); this.curriculum = curriculum; this.element = element; this.parentElement = parentElement; + this.secCallback = secCallback; initForm(ureq); } @@ -116,12 +120,12 @@ public class EditCurriculumElementController extends FormBasicController { String identifier = element == null ? "" : element.getIdentifier(); identifierEl = uifactory.addTextElement("identifier", "curriculum.element.identifier", 255, identifier, formLayout); - identifierEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.identifier)); + identifierEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.identifier) && secCallback.canEditCurriculumElement()); identifierEl.setMandatory(true); String displayName = element == null ? "" : element.getDisplayName(); displayNameEl = uifactory.addTextElement("displayName", "curriculum.element.displayName", 255, displayName, formLayout); - displayNameEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.displayName)); + displayNameEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.displayName) && secCallback.canEditCurriculumElement()); displayNameEl.setMandatory(true); List<CurriculumElementType> types = getTypes(); @@ -134,7 +138,7 @@ public class EditCurriculumElementController extends FormBasicController { typeValues[i+1] = types.get(i).getDisplayName(); } curriculumElementTypeEl = uifactory.addDropdownSingleselect("type", "curriculum.element.type", formLayout, typeKeys, typeValues, null); - curriculumElementTypeEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.type)); + curriculumElementTypeEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.type) && secCallback.canEditCurriculumElement()); boolean typeFound = false; if(element != null && element.getType() != null) { String selectedTypeKey = element.getType().getKey().toString(); @@ -162,21 +166,23 @@ public class EditCurriculumElementController extends FormBasicController { Date begin = element == null ? null : element.getBeginDate(); beginEl = uifactory.addDateChooser("start", "curriculum.element.begin", begin, formLayout); - beginEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.dates)); + beginEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.dates) && secCallback.canEditCurriculumElement()); Date end = element == null ? null : element.getEndDate(); endEl = uifactory.addDateChooser("end", "curriculum.element.end", end, formLayout); - endEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.dates)); + endEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.dates) && secCallback.canEditCurriculumElement()); String description = element == null ? "" : element.getDescription(); descriptionEl = uifactory.addRichTextElementForStringDataCompact("curriculum.description", "curriculum.description", description, 10, 60, null, formLayout, ureq.getUserSession(), getWindowControl()); - descriptionEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.description)); + descriptionEl.setEnabled(!CurriculumElementManagedFlag.isManaged(element, CurriculumElementManagedFlag.description) && secCallback.canEditCurriculumElement()); FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); formLayout.add(buttonsCont); uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl()); - uifactory.addFormSubmitButton("save", buttonsCont); + if(secCallback.canEditCurriculumElement()) { + uifactory.addFormSubmitButton("save", buttonsCont); + } } private List<CurriculumElementType> getTypes() { diff --git a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementOverviewController.java b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementOverviewController.java index c788ac2435f3f1d7d8a987fdf365c0aa95e0931b..3d90a5f5aa6011dad081db862e3497ea77ca7597 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementOverviewController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumElementOverviewController.java @@ -28,6 +28,7 @@ import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.modules.curriculum.Curriculum; import org.olat.modules.curriculum.CurriculumElement; +import org.olat.modules.curriculum.CurriculumSecurityCallback; /** * @@ -44,18 +45,21 @@ public class EditCurriculumElementOverviewController extends BasicController { private CurriculumElementUserManagementController userManagementCtrl; private CurriculumElement element; + private final CurriculumSecurityCallback secCallback; public EditCurriculumElementOverviewController(UserRequest ureq, WindowControl wControl, - CurriculumElement element, Curriculum curriculum) { + CurriculumElement element, Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl); this.element = element; + this.secCallback = secCallback; VelocityContainer mainVC = createVelocityContainer("curriculum_element_overview"); tabPane = new TabbedPane("tabs", getLocale()); tabPane.addListener(this); - metadataCtrl = new EditCurriculumElementController(ureq, getWindowControl(), element, element.getParent(), curriculum); + metadataCtrl = new EditCurriculumElementController(ureq, getWindowControl(), + element, element.getParent(), curriculum, secCallback); listenTo(metadataCtrl); tabPane.addTab(translate("curriculum.element.metadata"), metadataCtrl); initTabPane(); @@ -67,13 +71,13 @@ public class EditCurriculumElementOverviewController extends BasicController { private void initTabPane() { tabPane.addTab(translate("tab.resources"), uureq -> { - resourcesCtrl = new CurriculumElementResourceListController(uureq, getWindowControl(), element); + resourcesCtrl = new CurriculumElementResourceListController(uureq, getWindowControl(), element, secCallback); listenTo(resourcesCtrl); return resourcesCtrl.getInitialComponent(); }); tabPane.addTab(translate("tab.user.management"), uureq -> { - userManagementCtrl = new CurriculumElementUserManagementController(uureq, getWindowControl(), element); + userManagementCtrl = new CurriculumElementUserManagementController(uureq, getWindowControl(), element, secCallback); listenTo(userManagementCtrl); return userManagementCtrl.getInitialComponent(); }); diff --git a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumOverviewController.java b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumOverviewController.java index d5ba608a2c23df17998e03b43ccdd87d94953372..24943478dc3d7d6ba08a192a75b301b7cabaea14 100644 --- a/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumOverviewController.java +++ b/src/main/java/org/olat/modules/curriculum/ui/EditCurriculumOverviewController.java @@ -27,6 +27,7 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.modules.curriculum.Curriculum; +import org.olat.modules.curriculum.CurriculumSecurityCallback; /** * @@ -42,17 +43,20 @@ public class EditCurriculumOverviewController extends BasicController { private CurriculumUserManagementController userManagementCtrl; private Curriculum curriculum; + private final CurriculumSecurityCallback secCallback; - public EditCurriculumOverviewController(UserRequest ureq, WindowControl wControl, Curriculum curriculum) { + public EditCurriculumOverviewController(UserRequest ureq, WindowControl wControl, + Curriculum curriculum, CurriculumSecurityCallback secCallback) { super(ureq, wControl); this.curriculum = curriculum; + this.secCallback = secCallback; VelocityContainer mainVC = createVelocityContainer("curriculum_overview"); tabPane = new TabbedPane("tabs", getLocale()); tabPane.addListener(this); - editMetadataCtrl = new EditCurriculumController(ureq, getWindowControl(), curriculum); + editMetadataCtrl = new EditCurriculumController(ureq, getWindowControl(), curriculum, secCallback); listenTo(editMetadataCtrl); tabPane.addTab(translate("curriculum.metadata"), editMetadataCtrl); initTabPane(); @@ -63,7 +67,7 @@ public class EditCurriculumOverviewController extends BasicController { private void initTabPane() { tabPane.addTab(translate("tab.user.management"), uureq -> { - userManagementCtrl = new CurriculumUserManagementController(uureq, getWindowControl(), curriculum); + userManagementCtrl = new CurriculumUserManagementController(uureq, getWindowControl(), curriculum, secCallback); listenTo(userManagementCtrl); return userManagementCtrl.getInitialComponent(); }); diff --git a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java index 0dffbcb4d498183f17cdb16928e3758f0e77dbf3..bcf32f08d132b74d4fd78e3ee3dbd9cfed04531d 100644 --- a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java @@ -172,7 +172,7 @@ public class CoursesWebService { } if(StringHelper.containsNonWhitespace(repositoryEntryKey) && StringHelper.isLong(repositoryEntryKey)) { try { - params.setRepositoryEntryKeys(Collections.singletonList(new Long(repositoryEntryKey))); + params.setRepositoryEntryKeys(Collections.singletonList(Long.valueOf(repositoryEntryKey))); } catch (NumberFormatException e) { log.error("Cannot parse the following repository entry key: " + repositoryEntryKey); }