cancel
Showing results for 
Search instead for 
Did you mean: 

Server Side Scripting Inquiry for Current Users

karimbuenaseda
Champ on-the-rise
Champ on-the-rise
Hi All,

I'm a newbie in Alfresco development and I would just like to ask for your guidance in getting the current username and permission on a per folder basis. I have been looking at the server script "document-versions.js" and I'd just like to make some modifications on it that will depend on the current username and permission (say for example I would be hiding the "Download" button if the user has a "Write" permission). Also I have been exploring the Permissions and Security API and I tested to add some codes but so far I still can't get this working. Hope you could help me out on this.

Thanks
4 REPLIES 4

niketapatel
Star Contributor
Star Contributor
HI

This is general info for share development.

js file - document-versions.js you are referring that is share side/client side js. You can not access alfresco API over here directly.

You need to follow below step
1)From share side js or share client side js You need to call custom or OOB alfresco script - java or js based script.
2)Alfresco script returns current user's permission or any other required info in JSON as per your requirement. Please check if any alfresco OOB script is availble you may use that directly.
3)You need to parse this JSON at share side js and accordingly take next action like hide download link etc..

You can refer share OOB any module .

Hope it helps

karimbuenaseda
Champ on-the-rise
Champ on-the-rise
Hi Niketa,

Sorry bit of a newbie here, in terms of calling a OOB alfresco script (say for example a javascript) how could I do it? I mean what will be the process in terms of calling a webscript?

Appreciate the help.

anshu_kumar
Star Contributor
Star Contributor
From your 'share-side' js, you can call repository web-script using 'remote' root-scoped object to connect to alfresco like this…

var connector = remote.connect("alfresco");
var result = connector.get("/yourCustomURI/or/OOTB-URI");

or you can directly use 'remote.call' like

var result = remote.call("/yourCustomURI/or/OOTB-URI");


And from client-side js, you can call the same using Ajax request like this..

Alfresco.util.Ajax.request({
    url: "/yourCustomURI/or/OOTB-URI"
    , method: "GET"
    , successCallback: {
        fn: this.onSuccess
        , scope: this
    }
    , failureCallback: {
        fn: this.onFailure
        , scope: this
    }
});

Hope it is helpful.

Hi Anshu,

Okay I'll try that one out. Thanks for the help. I'll let you know soon regarding the results.