cancel
Showing results for 
Search instead for 
Did you mean: 

Get a list of a user's system groups

srowsell
Champ in-the-making
Champ in-the-making
I have this code:

var userIsSiteManager=false;
var siteId=page.url.templateArgs.site;
var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "?groups=true");
   var grps="";

   if (result.status == 200 && result != "{}")
   {
      var theUser = eval('(' + result + ')');

      var groups = theUser.groups;

      for (var i=0; i < groups.length; i++) {
         if (theUser.groups.itemName == "GROUP_site_"+siteId+"_SiteManager") userIsSiteManager = true;
         }
      }


It works in the sense that the groups array does contain the groups to which the user belongs.  The problem is that it doesn't contain *all* the groups – it doesn't contain the system groups, which is what I'm interested in.  Specifically I want to be able to show a dashlet's contents only if the user is a site manager.

Anyone know how to get the list of system groups?
2 REPLIES 2

lementree
Champ on-the-rise
Champ on-the-rise
Hi

I didnt get your requirement clearly. but to check whether user is site manager or not you should call other webscript.


var siteId = page.url.templateArgs.site || "";
   model.userIsSiteManager= false;
   if (siteId !== "")
   {
      var json = remote.call("/api/sites/" + siteId + "/memberships/" + encodeURIComponent(user.name));
      if (json.status == 200)
      {
        var obj = eval('(' + json + ')');
        if (obj)
        {
          model.userIsSiteManager= obj.role == "SiteManager";
        }
      }
            
   }   

srowsell
Champ in-the-making
Champ in-the-making
That got it, thanks for your help.