07-29-2019 03:40 AM
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.
07-29-2019 06:13 AM
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);
}
}
}
07-30-2019 12:13 AM
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?
07-30-2019 03:40 AM
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.
07-31-2019 10:46 PM
Thank you fro your response i will refer and try this.
Explore our Alfresco products with the links below. Use labels to filter content by product module.