Last active
June 15, 2017 11:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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