cancel
Showing results for 
Search instead for 
Did you mean: 

Make options in header 'admin-only' in Alfresco 4.2d

ebogaard
Champ on-the-rise
Champ on-the-rise
In 4.2c and older, I was able to make Header (sub)items admin-only by enclosing items between <#if user.isAdmin> and </#if>.
For example the Create Site-option was editable like that in: tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules/header/sites.get.html.ftl

Also, to make the Repository button admin-accessible only, you could set "permission=admin" to the right option in: tomcat/webapps/share/WEB-INF/classes/alfresco/share-config.xml

In 4.2d, these don't work anymore and I can't find where I can influence this behaviour.
Setting <legacy-mode-enabled> to 'true', which should make the pre-4.2d way work again, but this made things far worse: the Header bar layout was all wrong.

Hope someone can point me in te right direction!
22 REPLIES 22

ddraper
World-Class Innovator
World-Class Innovator
I was a bit embarrassed by this omission so I raised https://issues.alfresco.com/jira/browse/ALF-19911 and added some configuration options to make customization easier. Obviously this isn't a lot of use for 4.2d Community but there may yet be another 4.2 community release before 4.2 Enterprise is released.

The updates mean that you can control which elements are displayed by modifying the definition for the "HEADER_SITES_MENU" widget, e.g. the JavaScript controller extension just needs to contain:


var sitesMenu = widgetUtils.findObject(model.jsonModel.widgets, "id", "HEADER_SITE_CONFIGURATION_DROPDOWN");
if (sitesMenu)
{
   sitesMenu.config.showCreateSite = user.isAdmin;
}


This would result in the create site menu item only being displayed if the current user was the admin. You could do similar things for the Recent Sites group, the Useful group, the favourites controls and the site finder menu item.

Regards,
Dave

ebogaard
Champ on-the-rise
Champ on-the-rise
Hi Dave, thanks for your enthusiasm and raising a JIRA item.
Is there any way to (easily) implement your fix in 4.2d? Is there a commit # available with all the needed changes? So far, I can't find it in the public SVN.

ddraper
World-Class Innovator
World-Class Innovator
The commit I made was revision 54861. The public mirror now appears to be at 54900 so it might have just not caught up at the time you last looked. The path to the file that was changed is this: "/Slingshot/source/web/js/alfresco/header/AlfSitesMenu.js"

Regards,
Dave

ddraper
World-Class Innovator
World-Class Innovator
FYI: Managed to cobble together a first blog on customizing the header: http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-1/

ebogaard
Champ on-the-rise
Champ on-the-rise
Hi Dave,

as 4.2.e is out, which should simplify what I initially wanted, I checked your blogs a second time.
The objective is still the same: hiding the CreateSite-option in the Sites-menu.

First I tried to hide the option for all users. So I created the following files:
tomcat/shared/classes/alfresco/web-extension/site-data/extensions/share-header-extensions.xml


<extension>
   <modules>
      <module>
         <id>Hide Create Site</id>
         <version>1.0</version>
         <customizations>
            <customization>
               <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
               <sourcePackageRoot>test.hide-create-site</sourcePackageRoot>
           </customization>
         </customizations>
      </module>
   </modules>
</extension>


tomcat/shared/classes/alfresco/web-extension/site-webscripts/test/hide-create-site/share-header.get.js


// Find the "Sites" menu…
var sitesMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SITES_MENU");
if (sitesMenu != null)

{
   // Hide the site finder…
   sitesMenu.config.showCreateSite = false;
}



Even though I followed your code examples, this doesn't hide the option for admin or non-admin users. What am I doing wrong?

Only when I set showCreateSite to false in tomcat/webapps/share/js/alfresco/header/AlfSitesMenu-min.js, the option isn't shown anymore.

ddraper
World-Class Innovator
World-Class Innovator
Did you download and try the sample JAR linked on http://blogs.alfresco.com/wp/developer/2013/09/16/customizing-the-share-header-part-3/ ? Although it's hiding the Site Finder (and not create site) if that works then it should be easy to adapt. I've just tried it again on my local environment and it's working for me,

Regards,
Dave

ebogaard
Champ on-the-rise
Champ on-the-rise
To be sure, I tried the JAR from your blog.
First I put it in tomcat/webapps/share/WEB-INF/lib/, but after a restart the sitefinder was stll there.
I also tried tomcat/shared/lib/ and tomcat/lib/, but without success.

The My Files link is also still there.

I'm using a fresh install of 4.2.e on Centos 6 x64 with only some small modifcations to some dashlets, but none related to the header. I use a non-admin test user.

Is there any way to check if the jar is active and the files in it are loaded succesfully?

ddraper
World-Class Innovator
World-Class Innovator
Can I just check that you're definitely deploying the module via the module deployment page (e.g.at share/page/modules/deploy) ?

ebogaard
Champ on-the-rise
Champ on-the-rise
Hi Dave,

thanks for your suggestion: deploying it via the module deployment page was the solution. I probably didn'd re-read part 1 of you blog, where you mention this.
And I'm not yet very used to deploying new code via that mechanism, as for a long time it has been "placing files + restart = profit".

The good news is that I also found the previous additions I made (based on your code) to hide 'Create Site'.

Thanks for your help.

ddraper
World-Class Innovator
World-Class Innovator
It is possible to have modules auto-deploy (see this post:http://blogs.alfresco.com/wp/developer/2012/01/04/extensibilty-updates-roundup/) but the default it for module deployment to be manual. Glad you've resolved your problems though.

Regards,
Dave