Wednesday, January 25, 2017

Restricting Availability of Alfresco Dashlets by Group

There are two kinds of dashboards in Alfresco Share: User and Site dashboards.  By default, after logging into Share, the user is presented with a customizable dashboard page.  The dashboard page is made up of dashlets that can be arranged using the Customize User Dashboard page, as shown here. Site dashboard pages can be similarly arranged and customized by the site managers.


Developers are able to create new dashlets that can be added to the list of available dashlets. A dashlet is composed of a number of files, one of which is called the descriptor file.  The descriptor file is a brief XML document that describes the name, description and availability information about the dashlet.

Alfresco documentation describes how the <family> tag can be used in the descriptor to specify which of the two dashboards the dashlet can appear: on the user, site, or both of the dashboards.

The family tag can take the following values:
  • user-dashlet - for use on the User Dashboard
  • site-dashlet - for use on the Site Dashboard
  • dashlet - for use on either User or Site Dashboards
But, there is another use for the family tag which isn't well documented.  The family tag can also be used to restrict availability of a dashlet by group. In that case, the name of the group is included in the family tag, like this:

 <family>group:GROUP_ALFRESCO_ADMINISTRATORS</family>  

Here we refer to the Alfresco administrators group called ALFRESCO_ADMINISTRATORS.  Note that the group name used within Alfresco code prefixes all names with GROUP_. We see the group is referenced here as GROUP_ALFRESCO_ADMINISTRATORS, even though it is displayed as ALFRESCO_ADMINISTRATORS in the Group Browser of the Share UI.



Now, let's consider a specific case. When developing the Formtek Peer Association Extension, we had the need for a dashlet to be available only to administrators from their user dashboards. To enforce both restrictions, we used the following dashlet descriptor file with two family tag elements:

 <webscript>  
   <shortname>Remove Peer Association</shortname>  
   <description>Removes Formtek Peer Association Metadata</description>  
   <family>user-dashlet</family>  
   <family>group:GROUP_ALFRESCO_ADMINISTRATORS</family>  
   <url>/components/ftkassociations/dashlets/remove</url>  
 </webscript>    


No comments:

Post a Comment