Search code examples
customizationsharealfresco

How to disable Quick Share in Alfresco Share?


I'm currently trying find out a way to disable system-wide the Quick Share functionality in Alfresco 4.2.b, or if it is not possible, at least remove quickshare links from both the documentlibrary and the document-details pages.

First thing I have tried is to take advantage of the system.quickshare.enabled property which is configurable in the alfresco-global.properties file. It simply doesn't work throwing the next exception:

I have found an issue opened about that: https://issues.alfresco.com/jira/browse/ALF-16233.

As it seems to be a bug and would be fixed in further releases, I'm focused in removing quickshare links from UI as far as possible. By the way I found a post related which helps: https://forums.alfresco.com/en/viewtopic.php?f=48&t=46659. I have successfully removed the document-links region in document-details page by creating the next extension:

<extension>
    <modules>
        <module>
            <id>Removes from document-details page the Share region.</id>
            <auto-deploy>true</auto-deploy>
            <components>
                <component>
                    <scope>template</scope>
                    <region-id>document-links</region-id>
                    <source-id>document-details</source-id>
                    <sub-components>
                        <sub-component id="default">
                            <evaluations>
                                <evaluation id="hideDocumentLinks">
                                    <render>false</render>
                                </evaluation>
                            </evaluations>
                        </sub-component>
                    </sub-components>
                </component>
            </components>
        </module>
    </modules>
</extension>

That's fine. I have also the quickshare link from the document-details page performing some changes in the share-config.xml file, specifically by leaving empty the tag within the Social section:

<config evaluator="string-compare" condition="Social">
      <!-- Alfresco QuickShare social widget - for creating public url that can be shared -->
      <quickshare>
         <!--
            Will be available as Alfresco.constants.QUICKSHARE_URL using javascrip in the browser.
            If changing this, make sure this url matches the quickshare rule in urlrewrite.xml
         -->
         <url>{context}/s/{sharedId}</url>
      </quickshare>

      <!-- Alfresco LinkShare social widget - share a link to social sites -->
      <linkshare>
         <!--
            These actions will be available as Alfresco.constants.LINKSHARE_ACTIONS using javascript in the browser.
            Labels will be retrieved from msg key "linkshare.action.<id>.label" unless explicitly provided as an
            attribute to the action element.
            Each param value accepts the following input: {shareUrl}, {displayName} or a msg key that will be prefixed.
            I.e. {body} for the email action's href param will be retrieved using "linkshare.action.email.body".
         -->
         <action id="email" type="link" index="10">
            <param name="href">mailto:?subject={subject}&amp;body={body}</param>
            <param name="target">new</param>
         </action>
         <action id="facebook" type="link" index="20">
            <param name="href">https://www.facebook.com/sharer/sharer.php?u={shareUrl}&amp;t={message}</param>
            <param name="target">new</param>
         </action>
         <action id="twitter" type="link" index="30">
            <param name="href">https://twitter.com/intent/tweet?text={message}&amp;url={shareUrl}</param>
            <param name="target">new</param>
         </action>
         <action id="google-plus" type="link" index="40">
            <param name="href">https://plus.google.com/share?url={shareUrl}</param>
            <param name="target">new</param>
         </action>
      </linkshare>

   </config>

As this logic is defined in the node-header.get.js webscript:

model.showQuickShare = (!model.isContainer && model.showQuickShare && config.scoped["Social"]["quickshare"].getChildValue("url") != null).toString();

Nevertheless, the quickshare link remains in the documentlibrary page, which surprise me. I believed that a similar logic as above would exist for showing or not the link in the documentlibrary page but it isn't. So, now I'm wondering what else I can do... As I have been seeing, that link is generated in the client side with the documentlibrary widget (documentlist.js):

    if (!record.node.isContainer)
    {
       html += '<span class="item item-social item-separator">' + Alfresco.DocumentList.generateQuickShare(this, record) + '</span>';
    }

I'm thinking about creating an extension which customize the documentlibrarywidget similarly has described here: [url]http://blogs.alfresco.com/wp/ddraper/2012/05/22/customizing-share-javascript-widget-instantiation-part-1/[/url]. Would that be possible?

I would like to know if there is an easier way to do what I need to do before starting to customize the widget. If that "magic" way doesn't exist, I would like to know if the approach described is correct or not.

Thanks in advance.


Solution

  • As the extension of the documentlibrary widget (documentlist.js) wasn't as straightforward as I expected, I have solved it by an easier, simpler and un-intrusive solution based in the idea explained in one of the comments on the original question. In general terms, it consists in defining an extension module which adds a custom CSS in every page's header. That CSS overrides the quickshare link's styles this way:

    /* Disables the Quick Share link both in documentlibrary and document-details pages */
    .item-social a.quickshare-action {
        visibility: hidden;
    }
    

    How to define that kind of extension module is explained here: https://forums.alfresco.com/en/viewtopic.php?f=48&t=47312#p140623.

    Hope it helps others trying to achieve the same.