Skip to content

Instantly share code, notes, and snippets.

@angelborroy-ks
Last active June 15, 2017 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelborroy-ks/7a2addb9df59f4036a480c8760c95e9b to your computer and use it in GitHub Desktop.
Save angelborroy-ks/7a2addb9df59f4036a480c8760c95e9b to your computer and use it in GitHub Desktop.
Alfresco Share JavaScript repo code to guess if a user is SiteManager
// Call the repo for sites the user is a member of
var sites = [];
var result = remote.call("/api/people/" + encodeURIComponent(user.name) + "/sites");
model.role = "Undefined";
if (result.status == 200)
{
var managers, i, ii, j, jj;
// Create javascript objects from the server response
sites = eval('(' + result + ')');
if (sites.length > 0)
{
for (var index = 0; index < sites.length; index++)
{
site = sites[index];
// Is current user a Site Manager for this site?
site.isSiteManager = false;
if (site.siteManagers)
{
managers = site.siteManagers;
for (j = 0, jj = managers.length; j < jj; j++)
{
if (managers[j] == user.name)
{
model.role = "SiteManager";
break;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment