Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-109827 Only remove one scope by clicking remove permission button #121526

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -262,10 +262,6 @@ private void _updateSearchContainerResultRows() throws PortalException {

String actionId = permissionDisplay.getActionId();

ResultRow row = new ResultRow(
new Object[] {permissionDisplay.getPermission(), role},
actionId, i);

List<Group> groups = Collections.emptyList();

int scope = ResourceConstants.SCOPE_COMPANY;
Expand Down Expand Up @@ -293,6 +289,23 @@ private void _updateSearchContainerResultRows() throws PortalException {
scope = ResourceConstants.SCOPE_GROUP_TEMPLATE;
}

Permission permission = permissionDisplay.getPermission();

String[] primKeys = {permission.getPrimKey()};

if (scope == ResourceConstants.SCOPE_GROUP) {
primKeys = new String[groups.size()];

for (int j = 0; j < groups.size(); j++) {
Group group = groups.get(j);

primKeys[j] = String.valueOf(group.getGroupId());
}
}

ResultRow row = new ResultRow(
new Object[] {permission, role, primKeys}, actionId, i);

boolean selected =
ResourcePermissionLocalServiceUtil.hasScopeResourcePermission(
_themeDisplay.getCompanyId(), currentResource, scope,
Expand Down
Expand Up @@ -164,12 +164,15 @@ public void deletePermission(

String name = ParamUtil.getString(actionRequest, "name");
int scope = ParamUtil.getInteger(actionRequest, "scope");
String primKey = ParamUtil.getString(actionRequest, "primKey");
String[] primKeys = ParamUtil.getStringValues(
actionRequest, "primKeys");
String actionId = ParamUtil.getString(actionRequest, "actionId");

_resourcePermissionService.removeResourcePermission(
themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), name,
scope, primKey, roleId, actionId);
for (String primKey : primKeys) {
_resourcePermissionService.removeResourcePermission(
themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(),
name, scope, primKey, roleId, actionId);
}

// Send redirect

Expand Down
Expand Up @@ -23,6 +23,7 @@ Object[] objArray = (Object[])row.getObject();

Permission permission = (Permission)objArray[0];
Role role = (Role)objArray[1];
String[] primKeys = (String[])objArray[2];
%>

<liferay-ui:icon-menu
Expand All @@ -35,7 +36,7 @@ Role role = (Role)objArray[1];
<portlet:param name="roleId" value="<%= String.valueOf(role.getRoleId()) %>" />
<portlet:param name="name" value="<%= permission.getName() %>" />
<portlet:param name="scope" value="<%= String.valueOf(permission.getScope()) %>" />
<portlet:param name="primKey" value="<%= permission.getPrimKey() %>" />
<portlet:param name="primKeys" value="<%= StringUtil.merge(primKeys, StringPool.COMMA) %>" />
<portlet:param name="actionId" value="<%= String.valueOf(permission.getActionId()) %>" />
</portlet:actionURL>

Expand Down