Permission API
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2011 10:45 AM
Hi everyone,
Suppose the following code :
I am looking for a similar expression that make display the span only if the user role for the current node is different from a role X (added role) which is supposed to be a consumer without the download ability
I tried all combinations of the userhome and permissions objects but I got always something like this :
Suppose the following code :
<#if user.isAdmin><span><a href="${url.context}/proxy/alfresco${version.downloadURL}" class="download">${msg("link.download")}</a></span></#if>
I am looking for a similar expression that make display the span only if the user role for the current node is different from a role X (added role) which is supposed to be a consumer without the download ability
I tried all combinations of the userhome and permissions objects but I got always something like this :
Exception: freemarker.core.InvalidReferenceException - Expression userhome is undefined on line 45, column 38 in org/alfresco/components/document-details/document-versions.get.html.ftl.freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)….
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2011 11:35 AM
I had a similar question. This is how I solved it:
On the controller file for your webscript (should be a file with the same name as the .ftl one but with a .js extension) do the following:
Then on your ftl file of the webscript you can do this check :
You can replace SiteConsumer with any role you like.
On the controller file for your webscript (should be a file with the same name as the .ftl one but with a .js extension) do the following:
model.permissions = AlfrescoUtil.getSiteMembership(model.site).role ;
Then on your ftl file of the webscript you can do this check :
<#if permissions!="SiteConsumer" ><span><a href="${url.context}/proxy/alfresco${version.downloadURL}" class="download">${msg("link.download")}</a></span></#if>
You can replace SiteConsumer with any role you like.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011 04:39 AM
Hello,
Can you post the content of AlfrescoUtil.getSiteMembership function, it doesnt exist in my Alfresco
Thank you
Can you post the content of AlfrescoUtil.getSiteMembership function, it doesnt exist in my Alfresco
Thank you
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011 06:12 AM
Alfresco utils library is located in this fodler: share\WEB-INF\classes\templates\org\alfresco\import\alfrsco-util.js
You should import it in your js controller like this :
<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
Perhaps thats missing from your code ?
If not, this is the code pasted from that file:
However this might not help you, as it calls another webscript within alfresco that return a json response about the current user's site membership status. That webscript might be missing on your version as well ? I have no alfresco experience prior to 4.0 so I may be unable to help you there.
You can test if you have that webscript by running http://yourserver/alfresco/service/api/sites/{siteid}/memberships/{username}
You should see a json response on your browser.
You should import it in your js controller like this :
<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
Perhaps thats missing from your code ?
If not, this is the code pasted from that file:
/** * Retrieve current user's site membership. * * @method getSiteMembership * @param siteId {string} Site to get details for * @return {object} Object literal of the form * <pre> * isMember: true|false, * isManager: true|false * role: "SiteManager"|"SiteCollaborator"|"SiteContributor"|"SiteConsumer" * </pre> */getSiteMembership: function getSiteMembership(siteId) { var obj = { isMember: false, isManager: false, role: "" }; var json = remote.call("/api/sites/" + encodeURIComponent(siteId) + "/memberships/" + encodeURIComponent(user.name)); if (json.status == 200) { response = eval('(' + json + ')'); if (response) { obj = { isMember: true, isManager: response.role == "SiteManager", role: response.role }; } } return obj; }
However this might not help you, as it calls another webscript within alfresco that return a json response about the current user's site membership status. That webscript might be missing on your version as well ? I have no alfresco experience prior to 4.0 so I may be unable to help you there.
You can test if you have that webscript by running http://yourserver/alfresco/service/api/sites/{siteid}/memberships/{username}
You should see a json response on your browser.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011 09:29 AM
All that is missing in version 3.4, I will install Alfresco 4 and try to copy stuff in 3.4
before that I want just to ensure something, do this function really return the current user's role for the CURRENT NODE ?
before that I want just to ensure something, do this function really return the current user's role for the CURRENT NODE ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011 12:40 PM
It returns the user's role for the given site.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2011 04:10 AM
Ok thank you so much Kriton
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2011 12:44 PM
How about if I try to extend the download link to be watermark-first-then-download link? Are there any possibilities to add extended permission API to my new watermark-first-then-download link?
Best Regards,
Rudyanto
Best Regards,
Rudyanto