Skip to content

Commit

Permalink
button to check&save all inherited user permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Mar 14, 2024
1 parent 44cfc5e commit 2e65205
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -170,6 +172,16 @@ private void initIn() {
}
}

private void setInheritedPermissionProfileGroupsMap(boolean inherit, Collection<PermissionProfileGroup> inheritedPermissionProfileGroups) {
inheritedPermissionProfileGroupsMap.clear();
if (inherit && inheritedPermissionProfileGroups != null) {
Iterator<PermissionProfileGroup> 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;
Expand All @@ -178,10 +190,7 @@ private void initSets() {
parentPermissionProfileVOMap.clear();
if (user != null) {
parent = WebUtil.getInheritedUser(user.getParent() != null ? user.getParent().getId() : null);
Iterator<PermissionProfileGroup> profileGroupIt = user.getInheritedPermissionProfileGroups().iterator();
while (profileGroupIt.hasNext()) {
inheritedPermissionProfileGroupsMap.put(profileGroupIt.next().name(), Boolean.TRUE.toString());
}
setInheritedPermissionProfileGroupsMap(true, user.getInheritedPermissionProfileGroups());
if (parent != null) {
Collection<UserPermissionProfileOutVO> parentUserPermissionProfiles = null;
try {
Expand Down Expand Up @@ -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<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
icon="ui-icon ui-icon-disk" ajax="true"
disabled="#{!userPermissionProfileBean.editable}"
update="userpermissionprofile_input_grid" />
<p:commandButton process="@this,userpermissionprofile_inputs"
id="updateInherit" value="#{userlabels.update_inherit_user_permission_profiles_button_label}"
actionListener="#{userPermissionProfileBean.updateInherit}"
oncomplete="handleUpdateUserTabTitles(xhr, status, args)"
icon="ui-icon ui-icon-disk" ajax="true"
disabled="#{!userPermissionProfileBean.editable or !userPermissionProfileBean.hasParent}"
update="userpermissionprofile_input_grid" />
<p:commandButton process="@this"
value="#{labels.load_button_label}"
actionListener="#{userPermissionProfileBean.load}"
Expand Down

0 comments on commit 2e65205

Please sign in to comment.