From 8f33b27c8766d1692e7fc0f324cc926825218869 Mon Sep 17 00:00:00 2001
From: gnaegi <none@none>
Date: Wed, 16 May 2012 19:04:18 +0200
Subject: [PATCH] OO-265 add subscription listing to user management
 environment for better management possibilities

---
 .../java/org/olat/admin/user/UserAdminController.java | 11 ++++++++++-
 .../olat/admin/user/_i18n/LocalStrings_de.properties  |  1 +
 .../olat/admin/user/_i18n/LocalStrings_en.properties  |  1 +
 .../org/olat/basesecurity/BaseSecurityModule.java     |  3 +++
 .../olat/basesecurity/_spring/baseSecurityContext.xml |  5 +++++
 5 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/olat/admin/user/UserAdminController.java b/src/main/java/org/olat/admin/user/UserAdminController.java
index 232f52476dd..44145420f0f 100644
--- a/src/main/java/org/olat/admin/user/UserAdminController.java
+++ b/src/main/java/org/olat/admin/user/UserAdminController.java
@@ -59,6 +59,7 @@ import org.olat.core.logging.OLATSecurityException;
 import org.olat.core.util.WebappHelper;
 import org.olat.core.util.resource.OresHelper;
 import org.olat.core.util.vfs.QuotaManager;
+import org.olat.notifications.NotificationUIFactory;
 import org.olat.properties.Property;
 import org.olat.user.ChangePrefsController;
 import org.olat.user.DisplayPortraitController;
@@ -94,6 +95,7 @@ public class UserAdminController extends BasicController implements Activateable
 	private static final String NLS_EDIT_UROLES			= "edit.uroles";
 	private static final String NLS_EDIT_UQUOTA			= "edit.uquota";
 	private static final String NLS_VIEW_GROUPS 		= "view.groups";
+	private static final String NLS_VIEW_SUBSCRIPTIONS 		= "view.subscriptions";
 	
 	private VelocityContainer myContent;
 		
@@ -326,7 +328,14 @@ public class UserAdminController extends BasicController implements Activateable
 		grpCtr = new GroupOverviewController(ureq, getWindowControl(), identity, canStartGroups);
 		listenTo(grpCtr);
 		userTabP.addTab(translate(NLS_VIEW_GROUPS), grpCtr.getInitialComponent());
-				
+
+		Boolean canSubscriptions = BaseSecurityModule.USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS;
+		if (canSubscriptions.booleanValue() || isOlatAdmin) {
+			Controller subscriptionsCtr = NotificationUIFactory.createSubscriptionListingController(identity, ureq, getWindowControl());
+			listenTo(subscriptionsCtr); // auto-dispose
+			userTabP.addTab(translate(NLS_VIEW_SUBSCRIPTIONS), subscriptionsCtr.getInitialComponent());			
+		}
+		
 		rolesCtr = new SystemRolesAndRightsController(getWindowControl(), ureq, identity);
 		userTabP.addTab(translate(NLS_EDIT_UROLES), rolesCtr.getInitialComponent());
 		
diff --git a/src/main/java/org/olat/admin/user/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/admin/user/_i18n/LocalStrings_de.properties
index d9113bddfd7..bcf7076cfb7 100644
--- a/src/main/java/org/olat/admin/user/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/admin/user/_i18n/LocalStrings_de.properties
@@ -133,6 +133,7 @@ title.usersearch=Benutzersuche
 user.found=Benutzer wurde gefunden
 view.groups=Gruppen
 view.effStatements=Statements
+view.subscriptions=Abonnements
 error.search.form.to.short=Suchbegriff ist zu kurz.
 error.search.form.no.wildcard.dublicates=Suchbegriffe mit `**` sind nicht erlaubt.
 error.search.form.no.valid.datechooser=Bitte geben Sie ein g\u00fcltiges Datum an.
diff --git a/src/main/java/org/olat/admin/user/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/admin/user/_i18n/LocalStrings_en.properties
index cbc48896274..7ab31bde492 100644
--- a/src/main/java/org/olat/admin/user/_i18n/LocalStrings_en.properties
+++ b/src/main/java/org/olat/admin/user/_i18n/LocalStrings_en.properties
@@ -136,3 +136,4 @@ title.usersearch=User search
 user.found=User was found
 view.effStatements=Statements
 view.groups=Groups
+view.subscriptions=Subscriptions
diff --git a/src/main/java/org/olat/basesecurity/BaseSecurityModule.java b/src/main/java/org/olat/basesecurity/BaseSecurityModule.java
index 3c01faea186..349856d0aa6 100644
--- a/src/main/java/org/olat/basesecurity/BaseSecurityModule.java
+++ b/src/main/java/org/olat/basesecurity/BaseSecurityModule.java
@@ -44,6 +44,7 @@ public class BaseSecurityModule extends AbstractOLATModule {
 	private static final String CONFIG_USERMANAGER_CAN_CREATE_PWD = "sysGroupUsermanager.canCreatePassword";
 	private static final String CONFIG_USERMANAGER_CAN_MODIFY_PWD = "sysGroupUsermanager.canModifyPassword";
 	private static final String CONFIG_USERMANAGER_CAN_START_GROUPS = "sysGroupUsermanager.canStartGroups";
+	private static final String CONFIG_USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS = "sysGroupUsermanager.canModifySubscriptions";
 	private static final String CONFIG_USERMANAGER_ACCESS_TO_QUOTA = "sysGroupUsermanager.accessToQuota";
 	private static final String CONFIG_USERMANAGER_ACCESS_TO_PROP = "sysGroupUsermanager.accessToProperties";
 	private static final String CONFIG_USERMANAGER_ACCESS_TO_POLICIES = "sysGroupUsermanager.accessToPolicies";
@@ -63,6 +64,7 @@ public class BaseSecurityModule extends AbstractOLATModule {
 	public static Boolean USERMANAGER_CAN_CREATE_PWD = true;
 	public static Boolean USERMANAGER_CAN_MODIFY_PWD = true;
 	public static Boolean USERMANAGER_CAN_START_GROUPS = true;
+	public static Boolean USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS = true;
 	public static Boolean USERMANAGER_ACCESS_TO_QUOTA = true;
 	public static Boolean USERMANAGER_ACCESS_TO_PROP = false;
 	public static Boolean USERMANAGER_ACCESS_TO_POLICIES = false;
@@ -103,6 +105,7 @@ public class BaseSecurityModule extends AbstractOLATModule {
 		USERMANAGER_CAN_CREATE_PWD = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_CREATE_PWD, USERMANAGER_CAN_CREATE_PWD);
 		USERMANAGER_CAN_MODIFY_PWD = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MODIFY_PWD, USERMANAGER_CAN_MODIFY_PWD);
 		USERMANAGER_CAN_START_GROUPS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_START_GROUPS, USERMANAGER_CAN_START_GROUPS);
+		USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS = getBooleanConfigParameter(CONFIG_USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS, USERMANAGER_CAN_MODIFY_SUBSCRIPTIONS);
 		
 		USERMANAGER_ACCESS_TO_QUOTA = getBooleanConfigParameter(CONFIG_USERMANAGER_ACCESS_TO_QUOTA, USERMANAGER_ACCESS_TO_QUOTA);
 		USERMANAGER_ACCESS_TO_PROP = getBooleanConfigParameter(CONFIG_USERMANAGER_ACCESS_TO_PROP, USERMANAGER_ACCESS_TO_PROP);
diff --git a/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml b/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml
index 845c53d3b14..559d096d59b 100644
--- a/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml
+++ b/src/main/java/org/olat/basesecurity/_spring/baseSecurityContext.xml
@@ -40,6 +40,7 @@ depends-on="database, i18nModule, triggerI18nModuleInit">
 						sysGroupUsermanager.canCreatePassword=true
 						sysGroupUsermanager.canModifyPassword=true
 						sysGroupUsermanager.canStartGroups=true
+						sysGroupUsermanager.canModifySubscriptions=true
 						sysGroupUsermanager.accessToQuota=true
 						sysGroupUsermanager.accessToProperties=false
 						sysGroupUsermanager.accessToPolicies=false
@@ -82,6 +83,10 @@ depends-on="database, i18nModule, triggerI18nModuleInit">
 				  groupmanagers. Groupmanagers can manage course comprehensive groups using the top
 				  navigation site Groupmanagement. When set to false, the user manager is not allowed 
 				  to modify any profile information or password from a user that is within such a group.
+				- canModifySubscriptions: Allows the user to list all the subscriptions the users has, 
+				  launch the corresponding resource and allow the user to delete unwanted subscriptions.
+				  This is e.g. usefull to delete subscriptions where the user has no more access or to 
+				  manage users that are inactive at the moment but you do not yet want to delete them.
 				- canManageAuthors: Allows the user to add a user to the system group authors. Authors
 				  are allowed to create new learning resources in the learning resources repository. Note
 				  that beeing added as a co-author to a learning resource grants also the right to create
-- 
GitLab