diff --git a/src/main/java/org/olat/course/PersistingCourseImpl.java b/src/main/java/org/olat/course/PersistingCourseImpl.java index 0ad03dd2920787a85450a38384a3e1bc3a62c16f..3a6cf370e7a2f7ddf547e5d346735508222cc0bb 100644 --- a/src/main/java/org/olat/course/PersistingCourseImpl.java +++ b/src/main/java/org/olat/course/PersistingCourseImpl.java @@ -38,7 +38,6 @@ import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.FileUtils; import org.olat.core.util.nodes.INode; -import org.olat.core.util.resource.OresHelper; import org.olat.core.util.tree.TreeVisitor; import org.olat.core.util.tree.Visitor; import org.olat.core.util.vfs.Quota; @@ -181,16 +180,11 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ /** * @see org.olat.course.ICourse#getCourseTitle() */ - public String getCourseTitle() { - synchronized (courseTitleSyncObj) { //o_clusterOK by:ld/se - if (courseTitle == null) { + public String getCourseTitle() { + if (courseTitle == null) { + synchronized (courseTitleSyncObj) { //o_clusterOK by:ld/se // load repository entry for this course and get title from it - RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry( - OresHelper.createOLATResourceableInstance(CourseModule.class, this.resourceableId), false); - if (re == null) throw new AssertException( - "trying to get repoentry of a course to get the title, but no repoentry found although course is there, course resid = " - + resourceableId); - courseTitle = re.getDisplayname(); + courseTitle = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resourceableId); } } return courseTitle; diff --git a/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java b/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java index db6329506b6e9ad24e16058a2c058db6b37d6622..b4a55a1167f1c14494389605a2230222d6be5788 100644 --- a/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java +++ b/src/main/java/org/olat/course/condition/ConditionConfigEasyController.java @@ -73,6 +73,7 @@ import org.olat.group.area.BGAreaManager; import org.olat.group.ui.NewAreaController; import org.olat.group.ui.NewBGController; import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryManagedFlag; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; import org.olat.shibboleth.ShibbolethModule; @@ -140,6 +141,8 @@ public class ConditionConfigEasyController extends FormBasicController implement private final BGAreaManager areaManager; private final BusinessGroupService businessGroupService; + private boolean managedGroup; + /** * with default layout <tt>_content/easycondedit.html</tt> * @@ -163,6 +166,10 @@ public class ConditionConfigEasyController extends FormBasicController implement singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter(); groupConfigChangeEventOres = OresHelper.createOLATResourceableType(MultiUserEvent.class); singleUserEventCenter.registerFor(this, ureq.getIdentity(), groupConfigChangeEventOres); + + OLATResource courseResource = env.getCourseGroupManager().getCourseResource(); + RepositoryEntry courseRe = RepositoryManager.getInstance().lookupRepositoryEntry(courseResource, false); + managedGroup = RepositoryEntryManagedFlag.isManaged(courseRe, RepositoryEntryManagedFlag.groups); /* * my instance variables, these data is used by form items to initialise @@ -1314,7 +1321,7 @@ public class ConditionConfigEasyController extends FormBasicController implement boolean hasAreas = areaManager.countBGAreasInContext(courseResource) > 0; boolean hasGroups = businessGroupService.countBusinessGroups(null, courseResource) > 0; - createGroupsLink.setVisible(!hasGroups); + createGroupsLink.setVisible(!hasGroups && !managedGroup); chooseGroupsLink.setVisible(!createGroupsLink.isVisible()); createAreasLink.setVisible(!hasAreas); chooseAreasLink.setVisible(!createAreasLink.isVisible()); diff --git a/src/main/java/org/olat/course/condition/GroupSelectionController.java b/src/main/java/org/olat/course/condition/GroupSelectionController.java index e280584f47ad89b25f50da6d18675fd9b8487ced..d157d6a1215462be4f6f36c3ca5836c12a289357 100644 --- a/src/main/java/org/olat/course/condition/GroupSelectionController.java +++ b/src/main/java/org/olat/course/condition/GroupSelectionController.java @@ -45,6 +45,7 @@ import org.olat.course.groupsandrights.CourseGroupManager; import org.olat.group.BusinessGroup; import org.olat.group.ui.NewBGController; import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryManagedFlag; import org.olat.repository.RepositoryManager; /** @@ -65,11 +66,15 @@ public class GroupSelectionController extends FormBasicController { private String[] groupNames; private String[] groupKeys; + private boolean createEnable; public GroupSelectionController(UserRequest ureq, WindowControl wControl, String title, CourseGroupManager courseGrpMngr, List<Long> selectionKeys) { super(ureq, wControl, "group_or_area_selection"); this.courseGrpMngr = courseGrpMngr; + + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(courseGrpMngr.getCourseResource(), false); + createEnable = !RepositoryEntryManagedFlag.isManaged(re, RepositoryEntryManagedFlag.groups); // unique names from list to array loadNamesAndKeys(); initForm(ureq); @@ -135,21 +140,23 @@ public class GroupSelectionController extends FormBasicController { } @Override - protected void initForm(FormItemContainer boundTo, Controller listener, UserRequest ureq) { - // easy creation only possible if a default group context available - createNew = new FormLinkImpl("create"); - //is a button - createNew.setCustomEnabledLinkCSS("b_button"); - createNew.setCustomDisabledLinkCSS("b_button b_disabled"); - // create new group/area on the right side - boundTo.add(createNew); - - entrySelector = uifactory.addCheckboxesVertical("entries", null, boundTo, groupKeys, groupNames, null, 1); + protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { + if(createEnable) { + // easy creation only possible if a default group context available + createNew = new FormLinkImpl("create"); + //is a button + createNew.setCustomEnabledLinkCSS("b_button"); + createNew.setCustomDisabledLinkCSS("b_button b_disabled"); + // create new group/area on the right side + formLayout.add(createNew); + } + + entrySelector = uifactory.addCheckboxesVertical("entries", null, formLayout, groupKeys, groupNames, null, 1); // submitCancel after checkboxes Submit subm = new FormSubmit("subm", "apply"); Reset reset = new FormReset("reset", "cancel"); - boundTo.add(subm); - boundTo.add(reset); + formLayout.add(subm); + formLayout.add(reset); } @Override diff --git a/src/main/java/org/olat/course/nodes/co/COConfigForm.java b/src/main/java/org/olat/course/nodes/co/COConfigForm.java index 4f9f148b978d1b693bcd0409c7a92d2c0a71d92c..ed595657dee871547fb1143b33dd86d50beff4ac 100644 --- a/src/main/java/org/olat/course/nodes/co/COConfigForm.java +++ b/src/main/java/org/olat/course/nodes/co/COConfigForm.java @@ -64,6 +64,7 @@ import org.olat.group.ui.NewAreaController; import org.olat.group.ui.NewBGController; import org.olat.modules.ModuleConfiguration; import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryManagedFlag; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -123,6 +124,8 @@ public class COConfigForm extends FormBasicController { private final BGAreaManager areaManager; private final BusinessGroupService businessGroupService; + + private final boolean managedGroups; /** * Form constructor @@ -137,6 +140,11 @@ public class COConfigForm extends FormBasicController { this.cev = uce.getCourseEditorEnv(); areaManager = CoreSpringFactory.getImpl(BGAreaManager.class); businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); + + OLATResource courseResource = cev.getCourseGroupManager().getCourseResource(); + RepositoryEntry courseRe = RepositoryManager.getInstance().lookupRepositoryEntry(courseResource, false); + managedGroups = RepositoryEntryManagedFlag.isManaged(courseRe, RepositoryEntryManagedFlag.groups); + initForm(ureq); } @@ -546,7 +554,7 @@ public class COConfigForm extends FormBasicController { hasGroups = businessGroupService.countBusinessGroups(null, cev.getCourseGroupManager().getCourseResource()) > 0; chooseGroupsLink.setVisible(wg && hasGroups); - createGroupsLink.setVisible(wg && !hasGroups); + createGroupsLink.setVisible(wg && !hasGroups && !managedGroups); hasAreas = areaManager.countBGAreasInContext(cev.getCourseGroupManager().getCourseResource()) > 0; chooseAreasLink.setVisible(wg && hasAreas); @@ -560,6 +568,7 @@ public class COConfigForm extends FormBasicController { } recipentsContainer.clearError(); + flc.setDirty(true); } @Override diff --git a/src/main/java/org/olat/course/nodes/en/ENEditGroupAreaFormController.java b/src/main/java/org/olat/course/nodes/en/ENEditGroupAreaFormController.java index 06143c518988cb88b1bf40bfe86f28b8fba0ec45..7edb815089249b265c525a04b5d2e4a6e132fdab 100644 --- a/src/main/java/org/olat/course/nodes/en/ENEditGroupAreaFormController.java +++ b/src/main/java/org/olat/course/nodes/en/ENEditGroupAreaFormController.java @@ -69,6 +69,7 @@ import org.olat.group.ui.NewAreaController; import org.olat.group.ui.NewBGController; import org.olat.modules.ModuleConfiguration; import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryManagedFlag; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -113,6 +114,8 @@ class ENEditGroupAreaFormController extends FormBasicController implements Gener private CloseableModalController cmc; + private final boolean managedGroups; + private final BGAreaManager areaManager; private final BusinessGroupService businessGroupService; @@ -133,6 +136,11 @@ class ENEditGroupAreaFormController extends FormBasicController implements Gener hasAreas = areaManager.countBGAreasInContext(cev.getCourseGroupManager().getCourseResource()) > 0; hasGroups = businessGroupService.countBusinessGroups(null, cev.getCourseGroupManager().getCourseResource()) > 0; + + + OLATResource courseResource = cev.getCourseGroupManager().getCourseResource(); + RepositoryEntry courseRe = RepositoryManager.getInstance().lookupRepositoryEntry(courseResource, false); + managedGroups = RepositoryEntryManagedFlag.isManaged(courseRe, RepositoryEntryManagedFlag.groups); initForm(ureq); } @@ -574,7 +582,7 @@ class ENEditGroupAreaFormController extends FormBasicController implements Gener private void updateGroupsAndAreasCheck() { hasGroups = businessGroupService.countBusinessGroups(null, cev.getCourseGroupManager().getCourseResource()) > 0; chooseGroupsLink.setVisible(hasGroups); - createGroupsLink.setVisible(!hasGroups); + createGroupsLink.setVisible(!hasGroups && !managedGroups); hasAreas = areaManager.countBGAreasInContext(cev.getCourseGroupManager().getCourseResource()) > 0; chooseAreasLink.setVisible(hasAreas);