diff --git a/src/main/java/org/olat/group/BusinessGroupModule.java b/src/main/java/org/olat/group/BusinessGroupModule.java index 8d5246881f74a3780da24b5747373905be9db727..e0d25eb831a3502cfdba2e5ba6d98876c058c901 100644 --- a/src/main/java/org/olat/group/BusinessGroupModule.java +++ b/src/main/java/org/olat/group/BusinessGroupModule.java @@ -23,6 +23,7 @@ import org.olat.NewControllerFactory; import org.olat.core.configuration.AbstractOLATModule; import org.olat.core.configuration.PersistedProperties; import org.olat.core.id.context.SiteContextEntryControllerCreator; +import org.olat.core.util.StringHelper; import org.olat.core.util.resource.OresHelper; import org.olat.group.site.GroupsSite; @@ -38,14 +39,9 @@ import org.olat.group.site.GroupsSite; public class BusinessGroupModule extends AbstractOLATModule { public static String ORES_TYPE_GROUP = OresHelper.calculateTypeName(BusinessGroup.class); - - public static final String LAST_USAGE_DURATION_PROPERTY_NAME = "LastUsageDuration"; - public static final int DEFAULT_LAST_USAGE_DURATION = 24; - public static final String DELETE_EMAIL_DURATION_PROPERTY_NAME = "DeleteEmailDuration"; - public static final int DEFAULT_DELETE_EMAIL_DURATION = 30; - - public static final String USER_ALLOWED_TO_CREATE_BG = "userAllowedToCreate"; - public static final String AUTHOR_ALLOWED_TO_CREATE_BG = "authorAllowedToCreate"; + + private boolean userAllowedCreate; + private boolean authorAllowedCreate; /** * [used by spring] @@ -64,6 +60,16 @@ public class BusinessGroupModule extends AbstractOLATModule { new BusinessGroupContextEntryControllerCreator()); NewControllerFactory.getInstance().addContextEntryControllerCreator(GroupsSite.class.getSimpleName(), new SiteContextEntryControllerCreator(GroupsSite.class)); + + //set properties + String userAllowed = getStringPropertyValue("user.allowed.create", true); + if(StringHelper.containsNonWhitespace(userAllowed)) { + userAllowedCreate = "true".equals(userAllowed); + } + String authorAllowed = getStringPropertyValue("author.allowed.create", true); + if(StringHelper.containsNonWhitespace(authorAllowed)) { + authorAllowedCreate = "true".equals(authorAllowed); + } } /** @@ -71,44 +77,33 @@ public class BusinessGroupModule extends AbstractOLATModule { */ @Override protected void initDefaultProperties() { - // nothing to init + userAllowedCreate = getBooleanConfigParameter("user.allowed.create", true); + authorAllowedCreate = getBooleanConfigParameter("author.allowed.create", true); } - /** - * @see org.olat.core.configuration.AbstractOLATModule#initFromChangedProperties() - */ @Override protected void initFromChangedProperties() { - // nothing to init + init(); } - + @Override public void setPersistedProperties(PersistedProperties persistedProperties) { this.moduleConfigProperties = persistedProperties; } - - public void setLastUsageDuration(int lastUsageDuration) { - setIntProperty(LAST_USAGE_DURATION_PROPERTY_NAME, lastUsageDuration, true); - } - public void setDeleteEmailDuration(int deleteEmailDuration) { - setIntProperty(DELETE_EMAIL_DURATION_PROPERTY_NAME, deleteEmailDuration, true); + public boolean isUserAllowedCreate() { + return userAllowedCreate; } - public int getLastUsageDuration() { - return DEFAULT_LAST_USAGE_DURATION;// getIntProperty(LAST_USAGE_DURATION_PROPERTY_NAME, DEFAULT_LAST_USAGE_DURATION); + public void setUserAllowedCreate(boolean userAllowedCreate) { + setStringProperty("user.allowed.create", Boolean.toString(userAllowedCreate), true); } - public int getDeleteEmailDuration() { - return DEFAULT_DELETE_EMAIL_DURATION;//getIntProperty(DELETE_EMAIL_DURATION_PROPERTY_NAME, DEFAULT_DELETE_EMAIL_DURATION); - } - - public boolean isUserAllowedToCreateBG() { - return true; - } - - public boolean isAuthorAllowedToCreateBG() { - return true; + public boolean isAuthorAllowedCreate() { + return authorAllowedCreate; } -} + public void setAuthorAllowedCreate(boolean authorAllowedCreate) { + setStringProperty("author.allowed.create", Boolean.toString(authorAllowedCreate), true); + } +} \ No newline at end of file diff --git a/src/main/java/org/olat/group/_spring/businessGroupContext.xml b/src/main/java/org/olat/group/_spring/businessGroupContext.xml index c611e622a70967f860efee1b4b15b513388aee1a..e8a8d35f334e8110ad786b589cfb78d21d5db99a 100644 --- a/src/main/java/org/olat/group/_spring/businessGroupContext.xml +++ b/src/main/java/org/olat/group/_spring/businessGroupContext.xml @@ -16,7 +16,47 @@ <tx:annotation-driven transaction-manager="txManager"/> <bean id="businessGroupModule" class="org.olat.group.BusinessGroupModule" - init-method="init" depends-on="userModule"/> + init-method="init" depends-on="userModule"> + <property name="persistedProperties"> + <bean class="org.olat.core.configuration.PersistedProperties" scope="prototype" init-method="init" destroy-method="destroy" + depends-on="coordinatorManager,org.olat.core.util.WebappHelper"> + <constructor-arg index="0" ref="coordinatorManager"/> + <constructor-arg index="1" ref="businessGroupModule" /> + </bean> + </property> + </bean> + + <!-- default configuration --> + <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> + <property name="targetObject" ref="businessGroupModule" /> + <property name="targetMethod" value="init" /> + <property name="arguments"> + <value> + user.allowed.create=${group.user.create} + author.allowed.create=${group.author.create} + </value> + </property> + </bean> + + <!-- Business group admin. panel --> + <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> + <property name="order" value="8205" /> + <property name="actionController"> + <bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype"> + <property name="className" value="org.olat.group.ui.BusinessGroupModuleAdminController"/> + </bean> + </property> + <property name="navigationKey" value="group" /> + <property name="i18nActionKey" value="admin.menu.title"/> + <property name="i18nDescriptionKey" value="admin.menu.title.alt"/> + <property name="translationPackage" value="org.olat.group.ui"/> + <property name="parentTreeNodeIdentifier" value="sysconfigParent" /> + <property name="extensionPoints"> + <list> + <value>org.olat.admin.SystemAdminMainController</value> + </list> + </property> + </bean> <!-- Menu of the business group main controller --> <bean class="org.olat.core.extensions.action.GenericActionExtension" name="groups.my" init-method="initExtensionPoints"> diff --git a/src/main/java/org/olat/group/ui/BusinessGroupModuleAdminController.java b/src/main/java/org/olat/group/ui/BusinessGroupModuleAdminController.java new file mode 100644 index 0000000000000000000000000000000000000000..e29c73a3f69656e59771e0600848fddf227103d8 --- /dev/null +++ b/src/main/java/org/olat/group/ui/BusinessGroupModuleAdminController.java @@ -0,0 +1,59 @@ +package org.olat.group.ui; + +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.MultipleSelectionElement; +import org.olat.core.gui.components.form.flexible.impl.FormBasicController; +import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer; +import org.olat.core.gui.control.Controller; +import org.olat.core.gui.control.WindowControl; +import org.olat.group.BusinessGroupModule; + +/** + * + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + */ +public class BusinessGroupModuleAdminController extends FormBasicController { + + private MultipleSelectionElement allowEl; + + private final BusinessGroupModule module; + private String[] onKeys = new String[]{"user","author"}; + + public BusinessGroupModuleAdminController(UserRequest ureq, WindowControl wControl) { + super(ureq, wControl); + module = CoreSpringFactory.getImpl(BusinessGroupModule.class); + initForm(ureq); + } + + @Override + protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { + setFormTitle("module.admin.title"); + setFormDescription("module.admin.desc"); + + String[] values = new String[]{ + translate("user.allow.create"), + translate("author.allow.create") + }; + allowEl = uifactory.addCheckboxesVertical("module.admin.allow.create", formLayout, onKeys, values, null, 1); + allowEl.select("user", module.isUserAllowedCreate()); + allowEl.select("author", module.isAuthorAllowedCreate()); + + FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("module.buttons", getTranslator()); + buttonsContainer.setRootForm(mainForm); + formLayout.add(buttonsContainer); + uifactory.addFormSubmitButton("ok", "ok", formLayout); + } + + @Override + protected void doDispose() { + // + } + + @Override + protected void formOK(UserRequest ureq) { + module.setUserAllowedCreate(allowEl.isSelected(0)); + module.setAuthorAllowedCreate(allowEl.isSelected(1)); + } +} diff --git a/src/main/java/org/olat/group/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/group/ui/_i18n/LocalStrings_de.properties index 4c4e91a682c195dd4826a7141f396314f371ed00..9e783b388f0e795f9cdbc2ddcb6da859c6b0f5fc 100644 --- a/src/main/java/org/olat/group/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/group/ui/_i18n/LocalStrings_de.properties @@ -36,6 +36,14 @@ warn.foldernotavailable=Der Ordner ist momentan nicht aktiviert und kann nicht a warn.forumnotavailable=Das Forum ist momentan nicht aktiviert und kann nicht angezeigt werden. +admin.menu.title=Gruppe +admin.menu.title.alt=Gruppe +module.admin.title=Gruppe Modul +module.admin.desc=Gruppe Modul +module.admin.allow.create=Darf Gruppe erstellen +user.allow.create=Benutzer +author.allow.create=Authoren + bgcopywizard.copyform.owners=Betreuer der Gruppe chkBox.show.owners=Mitglieder sehen Betreuer diff --git a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java index 204958553154aab13af207e63aa4bbb523fe8c9d..10e2080746ee246b83f974164b10c8ccd0f4cd76 100644 --- a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java @@ -170,8 +170,8 @@ abstract class AbstractBusinessGroupListController extends BasicController { protected boolean canCreateBusinessGroup(UserRequest ureq) { Roles roles = ureq.getUserSession().getRoles(); if(roles.isOLATAdmin() || roles.isGroupManager() - || (roles.isAuthor() && groupModule.isAuthorAllowedToCreateBG()) - || (!roles.isInvitee() && !roles.isInvitee() && groupModule.isUserAllowedToCreateBG())) { + || (roles.isAuthor() && groupModule.isAuthorAllowedCreate()) + || (!roles.isGuestOnly() && !roles.isInvitee() && groupModule.isUserAllowedCreate())) { return true; } return false; diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index ea179d7282aaaa0ad692ab26202287e11950e8b9..0287fa8210066dee3f1a338c4f484a77948302ff 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -189,6 +189,17 @@ notification.interval.half-daily=true notification.interval.four-hourly=true notification.interval.two-hourly=true +#################################################### +# Groups +#################################################### + +# standard users can create groups +group.user.create=true +group.user.create.values=true,false +# authors can create groups +group.author.create=true +group.author.create.values=true,false + #################################################### # assessmentplugin config ####################################################