Quick Hack: Restricting Create Site Links to a Site Creators Group

At Alfresco Summit 2014 there was a wonderful session from Angel Borroy called, “10 Enhancements That Require Less Than 10 Lines of Code“. If you missed it you should follow that link and watch the recording.

Angel said the talk was inspired by my blog post about an example add-on I created that allows you to define default folder structures that get populated in the document library when you create a new site (see share-site-space-templates on GitHub).

One of the other 9 enhancements Angel showed was how to hide the “Create Site” link. I’ve seen so many of my clients and people in the forums asking for this functionality, I decided to enhance it a little bit, put it in an AMP, and make it available on GitHub. You can download share-site-creators and try it out for yourself.

Here’s a little more about how it works…

Instead of hiding the “Create Site” link from everyone but administrators, my add-on allows you to create a group that is used to determine who can create sites. The group, appropriately enough, is called “Site Creators”. If you aren’t in that group, you won’t see the “Create Site” link in any of these places:

  • The Sites menu
  • The “My Sites” Dashlet
  • The “Welcome” dashlet

Additionally, the add-on changes the underlying permissions at the repository tier so that if your teammates are hackers, they cannot circumvent the user interface and create their sites using other means.

The screenshot below (click to enlarge) shows what it looks like when you aren’t a member of the Site Creators group:

The Share Site Creators add-on restricts the Create Site link to a specific groupYou might notice that the text of the “Sharing” column in the welcome dashlet also changes to be more applicable to someone who cannot create their own sites.

The new text is in a properties file. Currently I have only an English version, so if any of my multi-lingual friends want to translate the new string, that might be useful to others.

Just like my Share Site Space Templates add-on, this one is not mind-blowing. But it is useful, both in terms of functionality, and as an example of how to override Alfresco Share web scripts without copying-and-pasting tons of code.

I’ve tested this with Alfresco 4.2.f Community Edition. If you want to get it working with other versions, or you have other improvements, bring on the pull requests!

29 comments

  1. Hi, thanks for the Plugin, but I cannot get it to work. I’m using Alfresco Community 5.0.c and getting the error:
    org.springframework.extensions.webscripts.WebScriptException: 02310004 Wrapped Exception (with status template): 02310071 Failed to execute script ‘classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js’: 02310070 ….

    Do you hav any hints whats going wrong?

    I can’t see the menu’s even if I’m in the additional group. And worse, I the Sites-Manager menu in administration throws an error!

    Thx in advance

    :peter

  2. Jeff Potts says:

    Peter,

    In the last few days I checked in a branch that is known to work on 5.0.d. I believe multiple people have also verified it works against 5.0.c but I have not (and won’t) test against that version.

    The code in HEAD will most definitely not work using 5.0.X. Are you using the code that was in HEAD or the code in the 5.0.d branch?

    Jeff

  3. 4lfr3d7115 says:

    tanks jeff for the Plugin, it´s working in 5.0.d , WTW The group, appropriately enough, is called “SITE_CREATORS” and not “GROUP_SITE_CREATORS”.

  4. Voula says:

    Hi,
    I installed the module for 5.0.d a few days ago and it worked perfectly at the time.
    After working on different customizations for a few days and of course restarting the server multiple times, I noticed today that the module wasn’t deployed anymore (I know, this is normal, since auto-deploy = false). So I went to the Module Deployment Console and re-deployed it. When I did that, the Alfresco header disappeared completely… So I un-deployed it, but the header is still gone. I tried uninstalling the module, restarting tomcat, re-installing it, and nothing worked…
    Do you know what might have happened?
    None of the customizations I made have to do with the header. As a matter of fact, none of the customizations I’ve tried have worked, so I always changed the files back to the originals. Unless I missed something, the current status of my Alfresco instance is the exact same as when I first installed site-creators a few days ago when it was working.
    PLEASE help!

    Voula

  5. Jeff Potts says:

    When you say, “I always changed the files back to the originals” that makes me think you were touching files that were included in the core Alfresco distribution which is something you should always avoid. It sounds like those files may now be in a state Alfresco does not expect and that’s causing a problem with the header.

    If you can re-produce the problem consistently using an out-of-the-box installation with no other customizations applied, please file an issue.

  6. Carlos says:

    Hi Jeff,

    I installed the addons on my alfresco server (Community 4.2.e), the addons works correctly (Only members of SITE_CREATORS group can create sites, all others users receive an error message indicating that they don’t have permission to create sites).
    The problem is that both site creation link (The Sites menu header and dashlet) were not be hidden when user doen’t have permission.
    Thx in advance

  7. Jeff Potts says:

    If the links are still showing up it probably means you either (1) did not deploy the Share tier AMP or (2) you deployed the AMP but did not enable the module in the Share module console.

    If you did both of these things and the links are still showing up on an out-of-the-box Community 4.2.e installation with no other customizations installed, then please file an issue on the github site.

  8. zehra says:

    Kindly help i dont know how to install this plugin i am new in alferesco ,plz eloborate me how you people are installing in steps.

  9. zehra says:

    yup i read but still some confusions.
    1.i have installed mvn 3.3.9 and jdk 1.8 .0_65 http://www.mkyong.com/maven/how-to-install-maven-in-windows/ (using all these steps).
    2.place repo files in amps and share in amp-share
    (i place alfresco in d:\ )
    3. but when i run d:\alfresco> mvn alfresco:install -Dmaven.alfresco.warLocation=$tomcat/webapps/alfresco in cmd prompt its give me error
    kindly let me know what m doing wrong

  10. Jeff Potts says:

    If you have already built the AMP files, you do not need Maven for the install step. Maven is only used during development. Instead, place the repo AMP in d:\alfresco\amps. Place the Share AMP in d:\alfresco\amps_share. Then, switch to d:\alfresco and run bin\apply_amps.bat. Inspect the list of installed AMPs that is output to the console. If the repo and Share AMP for this project are not listed, re-run apply_amps.bat with the -force flag. Finally, start Alfresco.

  11. zehra says:

    Thanks Jeff for your help.
    Actually m not able to convert “share-site-creators-repo” folder in to “share-site-creators-repo.amp” file and share folder too.
    on cmd prompt ,where is pom.xml present in that directory i am executing mvn install
    where iam getting error of group ID . and nono readable pom

    i have place share-site-creators in “d:\ ” where pom is in share-site-creators-repo\pm.xml
    cmd prompt
    d:\share-site-creators \share-site-creators -repo>mvn insatll

  12. Jeff Potts says:

    If you are running Alfresco Community Edition 5.0.d, just download the AMPs from here.

    Otherwise, tell me the error you are getting. I cannot help you without that.

  13. zehra says:

    Thanks jeff for bulit in amps this is what i exactly want it works perfectly.
    actually i was getting error when i was trying to built zip file in to amps file.
    now the plugin works perfectly thanks once again.

  14. Jeff Potts says:

    I have not tested them against 5.1 yet, but my intent is to do so. I am waiting on version 2.2.0 of the SDK, which is the version that supports 5.1, to be GA. If someone wants to download the release candidate of 2.2.0 and test against 201602GA that would be helpful. File any issues found on Github.

  15. Robert says:

    Hello, Jeff I am having issues creating the .amp file from the folder for community edition 5.1. Please can you provide the file for download.

Comments are closed.