From 2e652058389594d1e2e6d8ccaeb8244d3a1e63da Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 14 Mar 2024 20:27:43 +0100 Subject: [PATCH] button to check&save all inherited user permissions --- .../model/user/UserPermissionProfileBean.java | 30 ++++++++++++++++--- .../ctsms/web/user/labels.properties | 5 ++++ .../ctsms/web/user/labels_de.properties | 5 ++++ .../includes/user/userPermissionProfile.xhtml | 7 +++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java index 8dca7c6920f9..4cea5ce8b3bf 100644 --- a/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java +++ b/web/src/main/java/org/phoenixctms/ctsms/web/model/user/UserPermissionProfileBean.java @@ -34,6 +34,8 @@ import org.phoenixctms.ctsms.web.util.WebUtil; import org.primefaces.context.RequestContext; +import io.jsonwebtoken.lang.Collections; + @ManagedBean @ViewScoped public class UserPermissionProfileBean extends ManagedBeanBase { @@ -170,6 +172,16 @@ private void initIn() { } } + private void setInheritedPermissionProfileGroupsMap(boolean inherit, Collection inheritedPermissionProfileGroups) { + inheritedPermissionProfileGroupsMap.clear(); + if (inherit && inheritedPermissionProfileGroups != null) { + Iterator it = inheritedPermissionProfileGroups.iterator(); + while (it.hasNext()) { + inheritedPermissionProfileGroupsMap.put(it.next().name(), Boolean.TRUE.toString()); + } + } + } + private void initSets() { user = WebUtil.getUser(userId, GRAPH_MAX_USER_INSTANCES, GRAPH_MAX_USER_PARENT_DEPTH, GRAPH_MAX_USER_CHILDREN_DEPTH); parent = null; @@ -178,10 +190,7 @@ private void initSets() { parentPermissionProfileVOMap.clear(); if (user != null) { parent = WebUtil.getInheritedUser(user.getParent() != null ? user.getParent().getId() : null); - Iterator profileGroupIt = user.getInheritedPermissionProfileGroups().iterator(); - while (profileGroupIt.hasNext()) { - inheritedPermissionProfileGroupsMap.put(profileGroupIt.next().name(), Boolean.TRUE.toString()); - } + setInheritedPermissionProfileGroupsMap(true, user.getInheritedPermissionProfileGroups()); if (parent != null) { Collection parentUserPermissionProfiles = null; try { @@ -299,10 +308,23 @@ public String updateAction() { return ERROR_OUTCOME; } + public String updateInheritAction() { + setInheritedPermissionProfileGroupsMap(true, Collections.arrayToList(PermissionProfileGroup.values())); + return updateAction(); + } + + public void updateInherit() { + actionPostProcess(updateInheritAction()); + } + public Set getParentPermissionProfiles() { return parentPermissionProfiles; } + public boolean isHasParent() { + return parent != null; + } + public String getInheritedPermissionProfileGroupTooltip(String profileGroup) { if (parentPermissionProfileVOMap.containsKey(profileGroup)) { return Messages.getMessage(MessageCodes.INHERITED_USER_PERMISSION_PROFILE_TOOLTIP, parentPermissionProfileVOMap.get(profileGroup).getProfileName()); diff --git a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties index b4cf053b20fc..5276d6f049e9 100644 --- a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties +++ b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels.properties @@ -79,6 +79,9 @@ user_identity_tooltip=A person/organisation can be optionally selected as a user user_parent_label=Parent user\: user_parent_tooltip=Inherit settings and permissions from a parent user.\n +enable_inherited_properties_button_label=Inherit all settings from parent user +disable_inherited_properties_button_label=Inherit no settings from parent user + user_modules_field_set=Modules user_enable_inventory_module_label=Inventory: @@ -263,6 +266,8 @@ password_department_password_prompt_dialog_message=The department password is re password_department_password=new department's password password_department_password_tooltip=The new department's password. +update_inherit_user_permission_profiles_button_label=Inherit permissions from parent user + #user activity: user_activity_useractivity_list_header=journal entries diff --git a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties index cf65947ca730..993b1278ca61 100644 --- a/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties +++ b/web/src/main/resources/org/phoenixctms/ctsms/web/user/labels_de.properties @@ -79,6 +79,9 @@ user_identity_tooltip=Optional kann eine Person/Organisation als Identit\u00E4t user_parent_label=\u00DCbergeordneter Benutzer\: user_parent_tooltip=Einstellungen und Berechtigungen von einem \u00FCbergeordneten Benutzer vererben.\n +enable_inherited_properties_button_label=Alle Einstellungen des \u00FCbergeordneten Benutzers \u00FCbernehmen +disable_inherited_properties_button_label=Keine Einstellungen des \u00FCbergeordneten Benutzers \u00FCbernehmen + user_modules_field_set=Module user_enable_inventory_module_label=Inventar: @@ -263,6 +266,8 @@ password_department_password_prompt_dialog_message=Das Passwort f\u00FCr die Org password_department_password=neue Org.Einheit Passwort password_department_password_tooltip=Passwort der neuen Org.Einheit. +update_inherit_user_permission_profiles_button_label=Berechtigungen des \u00FCbergeordneten Benutzers \u00FCbernehmen + #user activity: user_activity_useractivity_list_header=Protokolleintr\u00E4ge diff --git a/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml b/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml index 5bc60b298f58..2d9f607ca951 100644 --- a/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml +++ b/web/src/main/webapp/META-INF/includes/user/userPermissionProfile.xhtml @@ -73,6 +73,13 @@ icon="ui-icon ui-icon-disk" ajax="true" disabled="#{!userPermissionProfileBean.editable}" update="userpermissionprofile_input_grid" /> +