Hide Manage Permissions & Manage Rules

cancel
Showing results for 
Search instead for 
Did you mean: 
aishu
Active Member

Hide Manage Permissions & Manage Rules

Dear Team,

how can i  hide manage rules, manage permissions & manage aspect from Site members,

I add code in the share-documentlibrary-config.xml as below: reffer bold for changes done in code

<!-- Manage permissions (repository roles) -->
<action id="document-manage-repo-permissions" type="link" icon="document-manage-permissions" label="actions.document.manage-permissions">
<param name="href">{managePermissionsUrl}</param>

<permissions>
<permission allow="true">ChangePermissions</permission>

</permissions>
<evaluator negate="true">evaluator.doclib.action.siteBased</evaluator>

<evaluator negate="true">evaluator.doclib.action.isWorkingCopy</evaluator>
<evaluator negate="false">evaluator.doclib.action.isSiteManager</evaluator>
<evaluator negate="false">evaluator.doclib.action.isSiteCollaborator</evaluator>
<evaluator negate="false">evaluator.doclib.action.isSiteContributor</evaluator>
<evaluator negate="false">evaluator.doclib.action.isSiteConsumer</evaluator>
</action>

But , When i login with Admin, these options are hide.I need to hide only from users not from admin

can u suggest!

Thanks regard,

Aishwarya jadhav.

4 Replies
abhinavmishra14
Advanced

Re: Hide Manage Permissions & Manage Rules

The behavior is correct. You are trying to hide some actions from all site users but want to allow admin user to see those actions. 

Admin user is also part of the same site and can have either of the above given site specific roles. I would suggest to do other way around. 

Create an evaluator called IsAdmin, and then use this evaluator to show the action else action will be disabled for other users. 

Update action config as:

<action id="document-manage-repo-permissions" type="link" icon="document-manage-permissions" label="actions.document.manage-permissions">
<param name="href">{managePermissionsUrl}</param>
<permissions>
<permission allow="true">ChangePermissions</permission>
</permissions>
<evaluator negate="true">evaluator.doclib.action.siteBased</evaluator>
<evaluator negate="true">evaluator.doclib.action.isWorkingCopy</evaluator>

<evaluator>share.module.evaluator.doclib.action.isAdmin</evaluator>
</action>‍‍‍‍‍‍‍‍‍‍‍‍

Add this in share application context file:

<bean id="share.module.evaluator.doclib.action.isAdmin" class="com.github.abhinavmishra14.action.evaluator.IsAdmin" />

Create IsAdmin evaluator class in your share module:

package com.github.abhinavmishra14.action.evaluator;

import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.evaluator.BaseEvaluator;
import org.json.simple.JSONObject;
import org.springframework.extensions.surf.RequestContext;
import org.springframework.extensions.surf.support.ThreadLocalRequestContext;
import org.springframework.extensions.webscripts.connector.User;

/**
* The Class IsAdmin.
*
*/

public class IsAdmin extends BaseEvaluator {

/* (non-Javadoc)
* @see org.alfresco.web.evaluator.BaseEvaluator#evaluate(org.json.simple.JSONObject)
*/

@Override
public boolean evaluate(final JSONObject jsonObject) {
try {
final RequestContext requestCtx = ThreadLocalRequestContext.getRequestContext();
final User user = requestCtx.getUser();
return user != null && user.isAdmin();
} catch (RuntimeException excp) {
throw new AlfrescoRuntimeException("Exception while running action evaluator: "
+ excp.getMessage(), excp);
}
}
}
~Abhinav
(ACSCE, AWS SAA, Azure Admin)
aishu
Active Member

Re: Hide Manage Permissions & Manage Rules

I understand first point,

but i m not understand where to save Add this in share application context file:?

can u tell me on which location i need to modify?

and on which location isAdmin evaluator class is create?

abhinavmishra14
Advanced

Re: Hide Manage Permissions & Manage Rules

It is talking about the application context file where you declare all beans in your share module and a class file named IsAdmin needs to be created in same share module. 

I think you should go through this tutorial before hand: Creating Custom Actions in Alfresco | ECMArchitect | Alfresco Developer Tutorials 

Custom evaluators: 

https://docs.alfresco.com/5.2/tasks/dev-extensions-share-tutorials-custom-evaluator.html

You will understand in-out of custom action, custom evaluators etc. 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
aishu
Active Member

Re: Hide Manage Permissions & Manage Rules

Thank you fro your response i will refer and try this.