cancel
Showing results for 
Search instead for 
Did you mean: 

Modify 'Favorite Sites' dropdown to show ALL sites

filmchris
Champ in-the-making
Champ in-the-making
I've been trying to get this working for at least the last 6 hours and keep hitting a wall.

I would like the Favorite "Sites" dropdown in the header to display all sites to which the logged in user has access. I only have two sites, with one group of users having access to both sites, and the other group having access to only one. I would like to forego the "favorites" route and just display the site(s) that the user has access to, for quick navigation between them.

My approach today was to extend /site-webscripts/org/alfresco/modules/header/sites.get.js and sites.get.html.ftl to more closely resemble the "Sites" dashlet (my-sites.get.js / my-sites.get.html.ftl) on the user dashboard, which provides a similar functionality (displaying all accessible sites to the user). So far, however, I've had no luck in getting this to work.

I'm fairly new to Alfresco, but it really seems like this shouldn't be that difficult. Any suggestions would be greatly, hugely appreciated.

Alfresco 3.4d (Bitnami AMI / Amazon EC2)
Linux Ubuntu i386
Apache Tomcat/6.0.26
JVM 1.6.0_18-b07
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
Posting what you've already got would help people spot where you can fix any problems…

Thanks,
Mike

filmchris
Champ in-the-making
Champ in-the-making
That's just it – I don't feel like I'm really any closer to getting this resolved than when I started. I was hoping it would be as easy as replacing the result value:

sites.get.js

   // Call the repo for the user's favourite sites
   // TODO: Clean-up old favourites here?
   var result = remote.call("/api/people/" + encodeURIComponent(user.name) + "/preferences?pf=" + PREF_FAVOURITE_SI
TES);
   if (result.status == 200 && result != "{}")
   {
      prefs = eval('(' + result + ')');

with

my-sites.get.js

   // Call the repo for sites the user is a member of
   var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "/sites");
   if (result.status == 200)
   {
      var site, favourites = {}, imapFavourites = {}, managers,
         i, ii, j, jj;

      // Create javascript objects from the server response
      sites = eval('(' + result + ')');

But alas, it didn't work. I am continuing to work at this, so will post additional snippets if/when I get closer.

Thanks for the response.

filmchris
Champ in-the-making
Champ in-the-making
Finally, sweet success! Here's what I did, in case anyone else stumbles across this looking for a similar solution.

Original file: {apache-tomcat}/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules/header/sites.get.js

Extended to: {apache-tomcat}/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/modules/header/sites.get.js

Replace this:

const PREF_FAVOURITE_SITES = "org.alfresco.share.sites.favourites";
With this:

const PREF_FAVOURITE_SITES = "org.alfresco.share.sites";

Replace this:

var result = remote.call("/api/people/" + encodeURIComponent(user.name) + "/preferences?pf=" + PREF_FAVOURITE_SITES);
if (result.status == 200 && result != "{}")
With this:

var result = remote.call("/api/people/" + encodeURIComponent(user.name) + "/sites");
if (result.status == 200)

Finally, replace this:

model.favouriteSites = favouriteSites;
With this:

model.favouriteSites = prefs;

I also made some minor changes to sites.get.html.ftl to remove the "Add site to favorites" link, but that's pretty self-explanatory.

Hopefully this saves someone else a similar headache!

count0
Champ in-the-making
Champ in-the-making
Hi, i cannot find this:
<javascript>
var result = remote.call("/api/people/" + encodeURIComponent(user.name) + "/preferences?pf=" + PREF_FAVOURITE_SITES);

if (result.status == 200 && result != "{}")
</javascript>
May be code is changed now?