cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict use of execute-script-action to admin only

xarope
Champ in-the-making
Champ in-the-making
I'm using the replacement for the old alfresco explorer interface which allowed script execution, with the share-extras script found here:
http://share-extras.github.io/addons/execute-script-action/

To limit this use to only administrators, I made a simple change to the execute-script.get.js, wrapping up all the code in a conditional checking for whether the user is an admin:
if (user.isAdmin) {

}


And that works, but unfortunately doesn't hide the "Execute script" action from showing in the first place.

Anybody know how to hide this as well?

Perhaps in the share-config-custom.xml code, is there a way to also do a config evaluator where condition="isAdmin" or some equivalent?  e.g.

   <!– Custom Execute Script Action –>
   <config evaluator="string-compare" condition="isAdmin"> <!– just guessing! –>
     <config evaluator="string-compare" condition="DocLibActions">
        <actionGroups>
           <actionGroup id="folder-browse">
              <action index="980" id="org_sharextras_execute-script" />
           </actionGroup>
…etc…
     </config>
   </config>
2 REPLIES 2

douglascrp
World-Class Innovator
World-Class Innovator
Hey xarope, how are you?
Do you speak portuguese? I'm asking that because your nickname is funny in portuguese Smiley Very Happy

So, answering your question, you can use the approach presented on this blog post https://angelborroy.wordpress.com/2015/06/03/alfresco-customizing-actions-and-document-details-by-us...

Basically what you have to do is to create an extension module and include the evaluator:

<module>
    <id>Hide action for non-admin</id>
    <auto-deploy>true</auto-deploy>
    <evaluator type="group.module.evaluator">
        <params>
            <groups>GROUP_ALFRESCO_ADMINISTRATORS</groups>
            <groupRelation>AND</groupRelation>
            <negate>false</negate>
        </params>
    </evaluator>
    <configurations>
        <config evaluator="string-compare" condition="DocLibActions">
            <action id="org_sharextras_execute-script">
            <evaluator>evaluator.doclib.action.disableAction</evaluator>
            </action>               
        </config>
    </configurations>
</module>


Try it and let me know if it worked.

xarope
Champ in-the-making
Champ in-the-making
Thanks douglascrp, I'll give it a try.

P.S. xarope is my old capoeira nickname, yes it's quite funny!