cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Tags component for Consumer users on document details page

bbiais
Champ in-the-making
Champ in-the-making
Hello,

On the document details page, I would like to hide the panel "Tags" (cf screenshot) but only for Consumer users.

For that, I did this tutorial, especially the part « Remove the Tags panel component ».
http://blogs.alfresco.com/wp/ewinlof/2011/11/09/add-remove-or-replace-components-on-shares-document-...

I generated the .jar file and deployed it on Alfresco. In the file acme-test-extension.xml, the original code works, hiding the "Tags" panel:


<!– Remove Tag Panel –>
<component>
   <scope>template</scope>
   <region-id>document-tags</region-id>
   <source-id>document-details</source-id>
   <sub-components>
     <sub-component id="default">
       <evaluations>
         <evaluation id="acme-test-removeTags">
            <render>false</render>
         </evaluation>
       </evaluations>
     </sub-component>
  </sub-components>
</component>


Then, I tried to change the code to hide the Tags panel only for Consumer, using evaluator « group.component.evaluator ».


<!– Remove Tag Panel –>
<component>
   <scope>template</scope>
   <region-id>document-tags</region-id>
   <source-id>document-details</source-id>
   <sub-components>
     <sub-component id="default">
       <evaluations>
         <evaluation id="acme-test-removeTags">
            <evaluators>
               <evaluator type="group.component.evaluator">
                                        <params><groups>SiteConsumer</groups></params>
               </evaluator>
            </evaluators>
            <render>false</render>
         </evaluation>
       </evaluations>
     </sub-component>
  </sub-components>
</component>


However, it doesn’t work, the Tags panel is displayed for all users.

I think this is related to the type evaluator, maybe I need to create my own class, but it’s not easy to find some tips to manage permissions for components extensions. Where could I find some examples to achieve this?

Thanks for your help!
2 REPLIES 2

douglascrp
World-Class Innovator
World-Class Innovator
You can see how to implement a custom evaluator here http://blogs.alfresco.com/wp/developer/2011/08/26/extensibility-module-deployment/

and here http://experiencewithalfresco.blogspot.dk/2012/06/type-subcomponent-evaluator.html

But back to the OOTB evaluator, I think you should use "site.module.evaluator" instead of "group.component.evaluator"

Replace it, redeploy your module and test again.

You can find the source code for that evaluator here http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/slingshot/source/java...

Let me know if that worked.

bbiais
Champ in-the-making
Champ in-the-making
Thanks for your help douglascrp and sorry for my late response.

I've modified acme-test-extension.xml with "site.module.evaluator".

Looking at class SlingshotSiteModuleEvaluator.java, I used and adapted example 3 to my needs : No render Tags panel for Consumer users for all sites.

Then, I restart ALfresco with automatic module deployement, but Consumer still can see Tags panel in document details page.

acme-test-extension.xml:


<extension>
   <modules>
      <module>
         <id>Acme :: Test - Document Details Page</id>
         <components>
            <!– Remove Tag Panel only for Consumers–>
            <component>
               <scope>template</scope>
               <region-id>document-tags</region-id>
               <source-id>document-details</source-id>
               <sub-components>
                  <sub-component id="default">
                     <evaluations>
                        <evaluation id="acme-test-removeTags">
            <evaluators>
            <evaluator type="site.module.evaluator">
               <params>
               <sites>.*</sites>
                    <applyForNonSites>false</applyForNonSites>
               <groups>SiteConsumer</groups>
               </params>
                 </evaluator>
            </evaluators>
         <render>false</render>
                        </evaluation>
                     </evaluations>
                  </sub-component>
              </sub-components>
            </component>
         </components>
      </module>
   </modules>
</extension>


Is it necessary to include SlingshotSiteModuleEvaluator class to extension?

Looking at file slingshot-application-context.xml, I think 4.2.e Alfresco version already include this class:


   <!– Module extensibility evaluators –>
   <bean id="site.module.evaluator" class="org.alfresco.web.extensibility.SlingshotSiteModuleEvaluator">
      <property name="slingshotEvaluatorUtil" ref="slingshot.evaluator.utility" />
   </bean>


Any ideas?