cancel
Showing results for 
Search instead for 
Did you mean: 

Display documentlibrary action for admins only

flm
Champ in-the-making
Champ in-the-making
Hi,

I am planning to add a "run script for this document"-Action to the Javascript Console extension. This should be an action for documents and folders in the document library that is only available to users that are admins (i.e. everone who can access the admin console). I was looking into custom evaluators and permissions to configure the Share action but I couldn't see any way to do this with the existing permissions.

As far as I can see I would have to override the evaluators.lib.js in the repo and add a new virtual permission but I don't think it would be good for the Javascript Console extension to override that file and possibly break other/future extensions.

Am I missing something or do you have ideas?

Regards,
Florian
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hi Florian,

as far as I see using a CustomResponse on the Repository tier and a metadata value evaluator like "evaluator.doclib.action.onlineEditVtiServer" on the Share tier should do the trick here. As you are referring to full / global admins, I feel there is no need to include anything in permission evaluation. The evaluators.lib.js can remain untouched.

Regards
Axel

flm
Champ in-the-making
Champ in-the-making
Thanks Axel, I didn't remember the CustomResponse - that will come in handy. After talking to Jan I figured out that I can just use an Evaluator since Share already knows that the user is an admin:


public class IsAdminEvaluator extends BaseEvaluator {

   @Override
   public boolean evaluate(JSONObject jsonObject) {
      RequestContext rc = ThreadLocalRequestContext.getRequestContext();
      User user = rc.getUser();
      
      return (user != null && user.isAdmin());
   }
}

afaust
Legendary Innovator
Legendary Innovator
I always suppress the information that Share has this isGuest / isAdmin information as I dislike the hardcoding that is often based upon that, but of course this simplifies matters…

wabson
Star Contributor
Star Contributor
Hi Florian, I already wrote a basic add-on to do the same kind of thing, did you see it?

http://code.google.com/p/share-extras/wiki/ExecuteScriptAction

If you're working on a similar thing it would be good if we could combine the two and rationalise the add-ons (i.e. kill the old one 😉

Cheers,
Will