cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I Disable the 'Leave Site' Option

chamill
Champ on-the-rise
Champ on-the-rise
Hello,

We are having a problem that our users keep thinking that the "Leave Site" option is used to log off the site. Is there a way of disabling this option.

we are currently on Alfresco version 3.4.c.

I have seen one thread https://forums.alfresco.com/en/viewtopic.php?t=16819 which I think is for a different version of Alfresco.

We are completely new to development in this area so any basic help would be great.

Thanks

Conor M Hamill
3 REPLIES 3

vamirr
Champ on-the-rise
Champ on-the-rise
Hi Conor,

There's a few ways to go about this.   Disclaimer: I'm using Enterprise 3.4.4, there may be differences in what I'm saying and what you see on your end.


First, you could just insert a CSS selector in your theme to remove the leaving site option from being displayed to anyone.

In my case, this works:  #yui-gen22 { display:none; }

Put that into your presentation.css or skin.css in found in <…>/webapps/Share/themes/<your theme here>/

This isn't the best solution as users who are not site managers will have an actions pull down with nothing in it and that's kind of goofy.  Also, I tend to avoid monkeying with the UI for absolutely everyone when I want to accomplish specific things for a targeted audience.



Another (better) solution is to edit the Share webscript template that defines the actions pull down.   This webscript (in my case) is found here:  <…>/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/title/collaboration-title.get.html.ftl

I've edited that webscript as shown below.  Look for the comment blocks <#–  –>

<#assign activePage = page.url.templateArgs.pageid!"">
<#assign siteTitle><#if profile.title != "">${profile.title}<#else>${profile.shortName}</#if></#assign>
<script type="text/javascript">//<![CDATA[
   new Alfresco.CollaborationTitle("${args.htmlid}").setOptions(
   {
      site: "${page.url.templateArgs.site!""}",
      siteTitle: "${siteTitle?js_string}",
      user: "${user.name!""}"
   }).setMessages(
      ${messages}
   );
   Alfresco.constants.DASHLET_RESIZE = ${userIsSiteManager?string};
//]]></script>
<div class="page-title theme-bg-color-1 theme-border-1">
   <div class="title">
      <h1 class="theme-color-3">${msg("header.site", "<span>${siteTitle?html}</span>")}</h1>
   </div>
   <div class="links title-button">
   <#if userIsSiteManager>
      <#assign linkClass><#if "invite" == activePage>class="active-page"</#if></#assign>
      <span class="yui-button yui-link-button">
         <span class="first-child">
            <a href="${url.context}/page/site/${page.url.templateArgs.site!}/invite" ${linkClass}>${msg("link.invite")}</a>
         </span>
      </span>
   </#if>
   <#if !userIsMember>
      <span class="yui-button yui-link-button">
         <span class="first-child">
      <#if profile.visibility == "PUBLIC">
            <a id="${args.htmlid}-join-link" href="#">${msg("link.join")}</a>
      <#else>
            <a id="${args.htmlid}-requestJoin-link" href="#">${msg("link.request-join")}</a>
      </#if>
         </span>
      </span>
   </#if>  
   <#assign siteDashboardUrl = page.url.context + "/page/site/" + page.url.templateArgs.site + "/dashboard">
   <#if userIsSiteManager && (page.url.uri == siteDashboardUrl || "customise-site-dashboard" == activePage) >
      <#assign linkClass><#if "customise-site-dashboard" == activePage>class="active-page"</#if></#assign>
      <span class="yui-button yui-link-button">
         <span class="first-child">
            <a href="${url.context}/page/site/${page.url.templateArgs.site!}/customise-site-dashboard" ${linkClass}>${msg("link.customiseDashboard")}</a>
         </span>
      </span>
   </#if>
    <#if userIsSiteManager>
      <input type="button" id="${args.htmlid}-more" name="${args.htmlid}-more" value="${msg("link.more")}"/>
      <select id="${args.htmlid}-more-menu">
         <option value="editSite">${msg("link.editSite")}</option>
         <option value="customiseSite">${msg("link.customiseSite")}</option>
         <option value="leaveSite">${msg("link.leave")}</option>        
      </select>
<#– EDIT——————————————–This comments out the case below————————
    <#elseif userIsMember>
      <input type="button" id="${args.htmlid}-more" name="${args.htmlid}-more" value="${msg("link.actions")}"/>   
      <select id="${args.htmlid}-more-menu">
         <option value="leaveSite">${msg("link.leave")}</option>
      </select>
———————————————————————————————————– –>
    </#if>  

   </div>
</div>

Editing that template in place isn't the best form either.   You should, instead, place it in the extensions directory: tomcat/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/title

Also, as you'll notice from the code, this will not remove the leave site option from the site manager's actions.  If you wish to do that as well, simply comment out the line two lines above my comment opening.

Also note that this will not remove the "leave" option from site search page, but it doesn't sound like that option is the one getting in your way.

Let me know if this helps.

chamill
Champ on-the-rise
Champ on-the-rise
Thank you Vamirr. That work perfectly. I have amended the script in the extentions area and all is working great.

"Every day is a school day"

Thank you so much !!!

erikwinlof
Confirmed Champ
Confirmed Champ
Hi,

Nice answer Vamirr!

As a side note about customizations and css files in general I just wanted to mention that in 4.0 it is theoretically possible to add in .css files based on user role using extensions & evaluators. You will need to create your own extension module and a custom role evaluator. The code would look *something* like this:

I.e.

/alfresco/site-data/extensions/acme-test-extension.xml
<extension>
   <modules>
      <module>
         <id>Acme :: Test</id>

         <!– Custom acme evaluator –>
         <evaluator type="acme.siteManagersOnly.evaluator"/>

         <!– Apply the following webscript customizations when the base evaluator above passes –>
         <customizations>
            <customization>
               <targetPackageRoot>org.alfresco</targetPackageRoot>
               <sourcePackageRoot>acme.site-manager.customizations</sourcePackageRoot>
               <dependencies>
                  <css>/res/acme/site-manager/css/site-managers.css</css>
               </dependencies>
            </customization>
         </customizations>
      </module>

   </modules>
</extension>

This means that the css dependency only will be included on every page if the "base" evaluator ("acme.siteManagersOnly.evaluator") returns true. To define the evaluator (it is just a Spring bean) go ahead and create the following file:

/alfresco/web-extension/acme-test-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
   <bean id="acme.evaluator.siteManagersOnly" class="acme.evaluator.SiteManagersOnlyModuleEvaluator"/>
</beans>

Your custom SiteManagersOnlyModuleEvaluator must implement ExtensionModuleEvaluator and will be able to use a RequestContext object to get the current user.
I.e. 
ThreadLocalRequestContext.getRequestContext().getUser();

To inspect the OOTB evaluators in Share, take a look at:
http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/slingshot/source/java...
http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/slingshot/source/java...


It is however also possible to use your module to add in add in additional css files to individual components since you also have provided target and source package roots.
Using this approach means that the custom css file only would get included if the component you're "customizing" is rendered on the page. You target by a component by matching the remaining part of the packages after the package roots. I.e. just create…

/alfresco/site-webscripts/acme/site-manager/components/title/collaboration-title.get.head.ftl
<#include "/org/alfresco/components/component.head.inc">
<!– Acme custom site manager css for the collaboration title –>
<@link rel="stylesheet" type="text/css" href="${url.context}/res/acme/site-manager/components/title/collaboration-title.css" />

For more information about Share extensions and modules feel free to take a look at:
http://blogs.alfresco.com/wp/ddraper/
http://blogs.alfresco.com/wp/ewinlof/
http://blogs.alfresco.com/wp/dwebster/