cancel
Showing results for 
Search instead for 
Did you mean: 

check if a user is in a group[Solved]

michaelc
Champ on-the-rise
Champ on-the-rise
Let me try asking this question another way.

How in Surf can I see if a user is in a given group ?
I wish to allow/dissllow a link based on the user being in a group, like you have for admin.

   <#if user.isAdmin>
   <div class="toolbar">
      <a href="#" id="${args.htmlid}-createSite-button" class="theme-color-1">${msg("link.createSite")}</a>
   </div>
   </#if>

Any help would be appreciated
Regards
  Michael C
2 REPLIES 2

fast3r
Champ on-the-rise
Champ on-the-rise
Don't know if there's a better way…

From a server-side JS:


function userHasGroup(user, group) {

   var result = remote.call("/api/people/" + stringUtils.urlEncode(user) + "?groups=true");
   if (result.status == 200 && result != "{}")
   {
      var user = eval('(' + result + ')');
     
      var groups = new Array();
      groups = user.groups;

      for (i=0; i<groups.length; i++)
      {                   
         if (groups[i]=="GROUP_" + group) return true; // found group
      }
      return false;
   }
   else return false;

}

michaelc
Champ on-the-rise
Champ on-the-rise
It's an answer that gives me something to work with  Smiley Very Happy
  Thank you very much.

Being a newbie I seem to be lost in the trees all the time and I know there is a forest in here somewhere.
Using what you sent me, I found the Restfull JavaScript API
http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference
thanks