cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluator for doclib Action to check a group-membership

webdesigner
Champ in-the-making
Champ in-the-making
Hello,

how to display an action in the docLib for every document,
according to the membership in one specific group.

I couldn't find anything in the documentation, how to achieve that.

Here the registration of my action in share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibActions">
<actions>
<action id="disable-record-creation" type="javascript" icon="document-reject" label="actions.rm.disable-record-creation">
<param name="function">onActionDisableRecordCreation</param>
<permissions>
<permission allow="true">Write</permission>
</permissions>   
</action>
<actions>
</config>

How to add an evaluator to check the group membership of the current user? Without modification of the standard Alfresco files (such us documentLibrary-actions.js etc.) to avoid version-upgrade conflicts?

A code snippet with the main points, would be really great.

Thanks in advance
Vitali
1 REPLY 1

douglascrp
World-Class Innovator
World-Class Innovator
Hello,

how to display an action in the docLib for every document,
according to the membership in one specific group.

I couldn't find anything in the documentation, how to achieve that.

Here the registration of my action in share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibActions">
<actions>
<action id="disable-record-creation" type="javascript" icon="document-reject" label="actions.rm.disable-record-creation">
<param name="function">onActionDisableRecordCreation</param>
<permissions>
<permission allow="true">Write</permission>
</permissions>   
</action>
<actions>
</config>

How to add an evaluator to check the group membership of the current user? Without modification of the standard Alfresco files (such us documentLibrary-actions.js etc.) to avoid version-upgrade conflicts?

A code snippet with the main points, would be really great.

Thanks in advance
Vitali

I think this is a good start.

You can implement a java based evaluator, like this simple evaluator, which checks if the user is an admin user.

public class IsAdminUserEvaluator extends BaseEvaluator {

   @Override
   public boolean evaluate(JSONObject jsonObject) {
      RequestContext rc = ThreadLocalRequestContext.getRequestContext();
      User user = rc.getUser();

      return (user != null && user.isAdmin());
   }

}

Then you can register this evaluator on custom-slingshot-application-context.xml

<bean id="evaluator.doclib.action.isAdminUser" class="your.package.IsAdminUserEvaluator" />

And in you action, you can config like this

<action id="document-copy-to" type="javascript" label="actions.document.copy-to">
   <param name="function">onActionCopyTo</param>
   <evaluator>evaluator.doclib.action.isAdminUser</evaluator>
</action>