Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the Repository link on Alfresco Share?

Tags:

alfresco

In Alfresco Share, when you click the "Repository" icon in the toolbar, you're taken to:

/share/page/repository

I would like to change this link to take the user to their home folder, example:

/share/page/repository#filter=path|/User%2520Homes/g/gi/gillespie/patrick.j.gillespie

I figured this would be a simple change, however, I'm pulling my hair out trying to figure out how to change the link. Does anyone know what I edit to change that link?

Update: So I can update the link via the share-config-custom.xml file, changing this line:

<item type="link" id="repository">/repository</item>

But I'm not sure how to get the folder path information in there. Does anyone have any ideas?

like image 498
patorjk Avatar asked Apr 04 '12 16:04

patorjk


People also ask

What is a repository in alfresco?

The Alfresco Repository provides a set of reusable cross-cutting Content Management services such as content storage, query, versioning and content transformation. These services may be utilized by multiple applications.

What is Alfresco Share?

Getting StartedAlfresco ShareAlfresco Share provides a rich web-based collaboration environment for managing documents, wiki content, blogs and more. Share leverages the Alfresco repository to provide content services and utilises the Alfresco Surf Platform to provide the underlying presentation framework.


1 Answers

This was surprisingly difficult, so I figured I'd post what I did in case anyone else has the same problem.

If you're not using hashed home folders, you can provide this functionality by simply updating your share-config.xml or share-config-custom.xml like so:

<item type="link" id="repository">/repository#filter=path|/User%2520Homes/{userid}</item>

However, if you're using hashed home folders, things become a little tricky. Instead of modifying any XML files, you'll instead create a web script to get the user's home folder path and then modify the share template file to replace the links to the repository. Below is a sample web script and the modifications to the template file that are needed in order to do this.

hfp.get.desc.xml

<webscript>
    <shortname>Home Folder Path</shortname>
    <description>Description here.</description>
    <format default="json">argument</format>
    <url>/demo/get-home-folder-path</url>
    <authentication>user</authentication>
</webscript>

hfp.get.js

This script traverses up the node tree and puts together the folder's path.

var myPerson = person;//used people.getPerson("patrick.j.gillespie") for testing
var currentNode = myPerson.properties.homeFolder;
var myDir = currentNode.properties["{http://www.alfresco.org/model/content/1.0}name"];
var count = 0;

while (count < 100) { // prevent an infinite loop
    currentNode = currentNode.parent;
    if (currentNode === undefined || currentNode === null) {break;}
    if (currentNode.properties === undefined) {break;}
    myDir = currentNode.properties["{http://www.alfresco.org/model/content/1.0}name"] + "/" + myDir;
    count++;
}
if (count === 100) { //something went wrong
    myDir = "";
}

model.homeFolder = myDir;

hfp.get.json.ftl

{
   "homeFolder": "${homeFolder}"
}

Finally, you'll need to modify the "alfresco-template.ftl" file, located in "share/WEB-INF/classes/alfresco/templates/org/alfresco/include". Near the bottom of the file, add the code below. It will call the above web script to fetch the home folder path, and then update the Repository links with the home folder link.

<script type="text/javascript">
    var callback = {
        success: function(res) {
            var data = YAHOO.lang.JSON.parse(res.responseText);
            var homeFolder = "";
            var hfIndex = data.homeFolder.indexOf("/User Homes/");
            if (hfIndex !== -1) {
                homeFolder = data.homeFolder.substr(hfIndex+12);
            }

            var repoLinks = $("a[title='Repository']");
            for (var ii = 0; ii < repoLinks.length; ii++) {
                repoLinks.get(ii).href = "/share/page/repository#filter=path|/User%2520Homes/" + homeFolder;
            }
        }
    };
    var sUrl = Alfresco.constants.PROXY_URI + "demo/get-home-folder-path";
    var postData = "";
    var getData = "";
    var request = YAHOO.util.Connect.asyncRequest('GET', sUrl+getData, callback, postData);
</script>

There may possibly be a better way, but I was unable to find it. I'll probably refine it later, and this should mostly just be used as a starting point, but I figured I'd post it in case anyone had a similar problem.

like image 96
patorjk Avatar answered Oct 06 '22 07:10

patorjk