cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco 4.2 Enterprise: Hide Create Folder from non-admin users

mduduzi
Confirmed Champ
Confirmed Champ
Hi,

We have a requirement to hide Create Folder from non-admin users and when we edit the file toolbar.lib.ftl as follows I get the Upload button is disabled as well:

       <#if user.isAdmin>
         <div class="hideable toolbar-hidden DocListTree">
            <div class="new-folder">
               <span id="${id}-newFolder-button" class="yui-button yui-push-button">
                  <span class="first-child">
                     <button name="newFolder">${msg("button.new-folder")}</button>
                  </span>
               </span>
            </div>
         </div>
       </#if>
      
       <#if !user.isAdmin>
         <div class="hideable toolbar-hidden DocListTree" style="display: none;">
            <div class="new-folder">
               <span id="${id}-newFolder-button" class="yui-button yui-push-button">
                  <span class="first-child">
                     <button name="newFolder">${msg("button.new-folder")}</button>
                  </span>
               </span>
            </div>
         </div>
       </#if>
      
        
         <div class="hideable toolbar-hidden DocListTree">
            <div class="file-upload">
               <span id="${id}-fileUpload-button" class="yui-button yui-push-button">
                  <span class="first-child">
                     <button name="fileUpload">${msg("button.upload")}</button>
                  </span>
               </span>
            </div>
         </div>


I am not sure why because this are two seperate button. If the is another way of hiding the create folder button from non-admin user please advise.

Kind regards
7 REPLIES 7

scouil
Star Contributor
Star Contributor
Hi,

Here is an comment in alfresco's code

<blockcode>
<!–
         Create Content menu items, can be of 3 types matching the usual doclib action config:

         * "link" - accepts a "href" param that will be passed a nodeRef token for substitution, used for external links
         * "pagelink" - accepts a "page" param that will be passed a nodeRef token for substitution, used for Share links
         * "javascript" - accepts & "function" param of an action that will get the current folder item as first argument.

         I.e.
         <content id="plain-text" label="create-content.text" icon="text" type="pagelink">
            <param name="page">create-content?destination={nodeRef}&amp;itemId=cm:content&amp;mimeType=text/plain</param>
            <permissions>
               <permission allow="true">SomeUserPermissions</permission>
            </permissions>
         </content>

         Note that the "CreateChildren" permission is always required and will disable the entire menu if no granted for a folder.

         Also note that the old/untyped simple config still is allowed, the config snippet below will automatically be
         converted to a "pagelink" as in the example above.
         <content id="plain-text" label="create-content.text" icon="text" itemid="cm:content" mimetype="text/plain" permission="SomeUserPermissions"/>
      –>
</blockcode>
Which means you can just configure share-config-custom.xml to add a permission check on the action.

I don't believe the is an "isAdmin" permission so you'd have to create it with something like
<globalPermission permission="AdminControl" authority="ROLE_ADMINISTRATOR"/>

And then will be able to assign it as a permission on the create folder element

scouil
Star Contributor
Star Contributor
I also came across this file in the alfresco svn:
http://svn.alfresco.com/repos/alfresco-open-mirror/integrations/GoogleDocs/HEAD/Google%20Docs%20Shar...

So it seems you can also use an evaluator to toggle the create folder for admin only.
This would be even easier and cleaner.

mduduzi
Confirmed Champ
Confirmed Champ
Thanks for the response. The desired result is not to disable the folder creation action but to hide it from non admin users.

I will have a look it again tomorrow. And if there are other options please post them.

scouil
Star Contributor
Star Contributor
Yes, I understand that.
And that's what both of those solutions would do.

The permissions one says that the link to create a folder would only appear for someone who has your custom permission on the current folder. Making it a global permission ensures it's always the case.
The evaluator solution enables you to write some custom java code returning true or false to display/hide that same create folder action. Just returning if the user is admin would work as intended.

mduduzi
Confirmed Champ
Confirmed Champ
I manage to solve the problem by overriding the template toolbar.lib.ftl to hide the create folder for non admin user.

So now if a user either than the admin is logged in he won't even see that option. I will post the solution on Monday at work.

mduduzi
Confirmed Champ
Confirmed Champ
As promised. The below worked.
Thanks for the response. I am not sure if the there something wrong with Freemarker but the below html works:

      <#if !user.isAdmin>
         <div class="hideable toolbar-hidden DocListTree" style="display: none;">
            <div class="new-folder">
               <span id="${id}-newFolder-button" class="yui-button yui-push-button">
                  <span class="first-child">
                     <button name="newFolder">${msg("button.new-folder")}</button>
                  </span>
               </span>
            </div>
         </div>
      <#else>
         <div class="hideable toolbar-hidden DocListTree">
            <div class="new-folder">
               <span id="${id}-newFolder-button" class="yui-button yui-push-button">
                  <span class="first-child">
                     <button name="newFolder">${msg("button.new-folder")}</button>
                  </span>
               </span>
            </div>
         </div>
      </#if>

cristina_lancio
Champ in-the-making
Champ in-the-making
I've tried but it doesn't work in my installation of Alfresco 4.2e….
How can I do?
I have to hide folder creation for a specific role

Thanks in advance.