cancel
Showing results for 
Search instead for 
Did you mean: 

Disable 'Create site' link

lees
Champ in-the-making
Champ in-the-making
Hi all,

I want to disable  the 'Create Site' link from the 'My sites' dashlet in case the user is not belong to admin group.

let me know any pointers as to how to implement..

-thx
41 REPLIES 41

fast3r
Champ on-the-rise
Champ on-the-rise
I'm trying to do the same for users not belonging to a specific created group (in my case, SYSTEM_MANAGERS), so I can't use the isAdmin attribute.

The only way I've found in Share is to make a remote call to "/api/people/{username}?groups=true" and check whether in the groups array of the user properties there's the SYSTEM_MANAGERS one.
By the way, this is very expensive in terms of page overhead, it has to be called for each page in Share… there must be a better way, like saving a boolean value in a global constant and checking the repo only when the user logs in.

Any suggestions?

brauliotrujillo
Champ in-the-making
Champ in-the-making
If you simply want to prevent the Create Site-link from being shown you could disable it in the file my-sites.get.html.ftl.

to remove it from the Getting started dashlet edit user-welcome.get.html.ftl , something like :

<#if user.isAdmin>
      <div class="detail-list-item">
         <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4>
         <div>${msg("text.customiseDashboard")}</div>
         <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div>
      </div>
      <div class="detail-list-item last-item">
         <h4 class="theme-color-2">${msg("header.createSite")}</h4>
         <div>${msg("text.createSite")}</div>
         <div><a id="${args.htmlid}-createSite-button" href="#" class="theme-color-2">${msg("link.createSite")}</a></div>
      </div>
<#else>
      <div class="detail-list-item last-item">
         <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4>
         <div>${msg("text.customiseDashboard")}</div>
         <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div>
      </div>

Excellent post by fkoenig, i already did as he instructs, just one important note, i got two errors the first time i ran the server again, one error was on the user-welcome.get.html.ftl, but i found out its only missing an "</#if> at the end of the code, just add that and you should be fine. The other issue was on the header.get.html.ftl , i got it to work by removing the lines at both ends of the suggested code, "<#if !isGuest> and "</#if>, leaving only the <#if user.isAdmin>.

Now with these tweaks, only Admin would be able to create sites, which in our case works great because we want to control that part of the app.

srinivasmurty
Champ in-the-making
Champ in-the-making
I am also looking to do this. However, I recently deployed Alfresco Community edition 3.2 on an Amazon EC2 instance. Turns out this was a ".war" implementation which does not expose all the Alfresco files for me to open, edit and customize away. I am scratching my bald had wondering how I can do this. I have another installation on a server at home which of course lets me do all those tweaks. Anyone of you experts know what I can do?

srinivasmurty
Champ in-the-making
Champ in-the-making
I just thought I should add some additional stuff that I had tried. I used "jar" to extract the files from the "share.war" file. I then made some changes to replace some of the logo files under the default theme's image folder. This had worked in my other Alfresco Community installation. Alas, despite recreating the "war" file and replacing the old one with the new one, it does not seem to work. I was hoping if this worked, I would go on to other stuff like removing the "Create Site" link. If anyone there has an idea what's going on I would really appreciate the help.

fast3r
Champ on-the-rise
Champ on-the-rise
Maybe you could think about downloading the whole source from Alfresco (HEAD), make your changes and rebuild the package from source.
There are some good tutorials on Alfresco Wiki that explain how to do that!

mikeh
Star Contributor
Star Contributor
Use the extensions mechanism*, that's what it's there for.

* shared/classes/alfresco/extension for the alfresco.war
shared/classes/alfresco/web-extension for the share.war

Thanks,
Mike

srinivasmurty
Champ in-the-making
Champ in-the-making
Mike, thanks for the info. I will look it up. Might require me to dust off some tech cobwebs to figure it out.

Fast3r - thank you for the suggestion. I do believe that's a good way to do it. However, I had decided to go with one of Alfresco's Amazon AMIs which has a pre-configured Alfresco installation. At the moment, I found it more important to get up and running with Alfresco Share rather than try to learn how to create Amazon AMIs and then do the hand-build thing.

srinivasmurty
Champ in-the-making
Champ in-the-making
I had a question. Is http://wiki.alfresco.com/wiki/Web_Client_Configuration_Guide the most current documentation that will help me with understanding "web-extension"?

Use the extensions mechanism*, that's what it's there for.

* shared/classes/alfresco/extension for the alfresco.war
shared/classes/alfresco/web-extension for the share.war

Thanks,
Mike

ottopodo
Champ in-the-making
Champ in-the-making
Hello,
here is my solution using some suggestions I found in this Thread:
extend header.get.js by adding this function:
function userHasGroup(username, group) {
   var result = remote.call("/api/people/" + stringUtils.urlEncode(username) + "?groups=true");
   if (result.status == 200 && result != "{}")
   {
      var user = eval('(' + result + ')');
    
      var groups = new Array();
      groups = user.groups;
      var mygroups = "";
      for (i=0; i<groups.length; i++)
      {                  
         if (groups[i].displayName == group || groups[i].displayName == "ALFRESCO_ADMINISTRATORS"){
        return true; // found group
      }else{
        mygroup = mygroups+groups[i].displayName;
      }
      }
     
      return false;
   }
   else return false;
}
and by adding at the end of the file this:

  var createSiteVisible = userHasGroup(user.name, 'YOUR_GROUP_NAME');
  model.createSiteVisible = createSiteVisible;
YOUR_GROUP_NAME is the name of the GROUP you created to control site creation feature.

Then in header.get.html.ftl replace:

<#if !user.isGuest>
         <ul class="create-site-menuitem">
            <li>
               <a href="#" onclick="thisHeader.showCreateSite(); return false;">${msg("header.sites.createSite")}</a>
            </li>
         </ul>
         </#if>
with:

<#if createSiteVisible>
         <ul class="create-site-menuitem">
            <li>
               <a href="#" onclick="thisHeader.showCreateSite(); return false;">${msg("header.sites.createSite")}</a>
            </li>
         </ul>
         </#if>

Marco

deeps
Champ in-the-making
Champ in-the-making
Hi,

i have written 1 ftl for hiding create site button in menu.
its worked properly.

but after that i have deployed some amp. after that all changes are reverted back.
i have written that ftl inside share folder directly.

and i think i need to do that changes inside shared folder of alfresco.
but i dont know where should i write that file inside shared folder.

i am new in alfresco.

so can you help me please.

your help will really appreciated.

Thanks in Advance