List user groups
----------------
returns an array of user group objects
329104
public function list_usergroups()
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $response = $this->exec_curl('/api/s/' . $this->site . '/list/usergroup');

        return $this->process_response($response);
    }
1113771
def list_users(self, pattern=None):
        
        request_url = "{}/api/0/users".format(self.instance)
        params = None
        if pattern:
            params = {'pattern': pattern}
        return_value = self._call_api(request_url, params=params)
        return return_value['users']
902783
def get_user_group(key)

      if !Setting.get('user_groups').blank?

        arr = ActiveSupport::JSON.decode(Setting.get('user_groups').gsub("\\", ''))

        if arr.has_key? key
          arr[key]
        else
          Array.new
        end

      end
    end
922426
def getusers(self, userlist):
        
        userobjs = [User(self, **rawuser) for rawuser in
                    self._getusers(names=userlist).get('users', [])]

        # Return users in same order they were passed in
        ret = []
        for u in userlist:
            for uobj in userobjs[:]:
                if uobj.email == u:
                    userobjs.remove(uobj)
                    ret.append(uobj)
                    break
        ret += userobjs
        return ret
553721
def list(self, limit=None, marker=None, name=None, visibility=None,
            member_status=None, owner=None, tag=None, status=None,
            size_min=None, size_max=None, sort_key=None, sort_dir=None):
        
        return self._manager.list(limit=limit, marker=marker, name=name,
                visibility=visibility, member_status=member_status,
                owner=owner, tag=tag, status=status, size_min=size_min,
                size_max=size_max, sort_key=sort_key, sort_dir=sort_dir)
484157
public function getRequestUserGroups($request) {

        // user id of the user trying to log in
        $user_id = $this->user->where('email', '=', $this->getRequestEmail($request) )->get()->first()->id;

        // the user's user groups (actually, the records as a GROUP (model) object
        $user_groups = $this->user->find($user_id)->group;

        // create an array
        $usergroupArray = [];
        foreach ($user_groups as $user_group) {
            $usergroupArray[] = $user_group->title;
        }

        return $usergroupArray;
    }
554817
def get_user_lists(self, course, aggregationid=''):
        
        tutor_list = course.get_staff()

        # Determine student list and if they are grouped
        student_list = list(self.database.aggregations.aggregate([
            {"$match": {"courseid": course.get_id()}},
            {"$unwind": "$students"},
            {"$project": {
                "classroom": "$_id",
                "students": 1,
                "grouped": {
                    "$anyElementTrue": {
                        "$map": {
                            "input": "$groups.students",
                            "as": "group",
                            "in": {
                                "$anyElementTrue": {
                                    "$map": {
                                        "input": "$$group",
                                        "as": "groupmember",
                                        "in": {"$eq": ["$$groupmember", "$students"]}
                                    }
                                }
                            }
                        }
                    }
                }
            }}
        ]))

        student_list = dict([(student["students"], student) for student in student_list])
        users_info = self.user_manager.get_users_info(list(student_list.keys()) + tutor_list)

        if aggregationid:
            # Order the non-registered students
            other_students = [student_list[entry]['students'] for entry in student_list.keys() if
                              not student_list[entry]['classroom'] == ObjectId(aggregationid)]
            other_students = sorted(other_students, key=lambda val: (("0"+users_info[val][0]) if users_info[val] else ("1"+val)))

            return student_list, tutor_list, other_students, users_info
        else:
            return student_list, tutor_list, users_info
348338
def get_groups(user=None):
    
    portal_groups = get_tool("portal_groups")
    user = get_user(user)
    if user is None:
        return []
    return portal_groups.getGroupsForPrincipal(user)
1125644
def _get_users_of_group(config, group):
    
    if not group:
        return set()
    fas = fmn.rules.utils.get_fas(config)
    return fmn.rules.utils.get_user_of_group(config, fas, group)
277056
public function getUserGroups() {

        $db = $this->db;

        $query = $db->getQuery(true)
                    ->select('a.*, COUNT(DISTINCT b.id) AS level')
                    ->from($db->quoteName('#__usergroups') . ' AS a')
                    ->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
                    ->group('a.id, a.title, a.lft, a.rgt, a.parent_id')
                    ->order('a.lft ASC');

        return $db->setQuery($query)
                  ->loadObjectList();

    }
1342931
def _get_user_groups(session, user_id, filter):
        
        return session.fetch_items('groups.get', Group.from_json, count=1000, user_id=user_id, filter=filter, extended=1, fields=",".join(Group.GROUP_FIELDS))
498259
def users(self):
        
        if self.__users is None:
            self.__users = GroupUsersCursor(swimlane=self._swimlane, user_ids=self.__user_ids)
        return self.__users
520397
def list(self):
        
        params = {'user': self.user_id}
        response = self.session.get(self.url, params=params)
        blocks = response.data['blocks']
        return [Block(self, **block) for block in blocks]
821981
def get_group_list(user, include_default=True):
    '''
    
    '''
    if HAS_GRP is False or HAS_PWD is False:
        return []
    group_names = None
    ugroups = set()
    if hasattr(os, 'getgrouplist'):
        # Try os.getgrouplist, available in python >= 3.3
        log.trace('Trying os.getgrouplist for \'%s\'', user)
        try:
            group_names = [
                grp.getgrgid(grpid).gr_name for grpid in
                os.getgrouplist(user, pwd.getpwnam(user).pw_gid)
            ]
        except Exception:
            pass
    elif HAS_PYSSS:
        # Try pysss.getgrouplist
        log.trace('Trying pysss.getgrouplist for \'%s\'', user)
        try:
            group_names = list(pysss.getgrouplist(user))
        except Exception:
            pass

    if group_names is None:
        # Fall back to generic code
        # Include the user's default group to match behavior of
        # os.getgrouplist() and pysss.getgrouplist()
        log.trace('Trying generic group list for \'%s\'', user)
        group_names = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
        try:
            default_group = get_default_group(user)
            if default_group not in group_names:
                group_names.append(default_group)
        except KeyError:
            # If for some reason the user does not have a default group
            pass

    if group_names is not None:
        ugroups.update(group_names)

    if include_default is False:
        # Historically, saltstack code for getting group lists did not
        # include the default group. Some things may only want
        # supplemental groups, so include_default=False omits the users
        # default group.
        try:
            default_group = grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name
            ugroups.remove(default_group)
        except KeyError:
            # If for some reason the user does not have a default group
            pass
    log.trace('Group list for user \'%s\': %s', user, sorted(ugroups))
    return sorted(ugroups)
1269625
function user_groups($username,$recursive=NULL){
        if ($username==NULL){ return (false); }
        if ($recursive==NULL){ $recursive=$this->_recursive_groups; } //use the default option if they haven't set it
        if (!$this->_bind){ return (false); }
        
        //search the directory for their information
        $info=@$this->user_info($username,array($this->_group_attribute,"member","primarygroupid"));
        
        $groups=$this->nice_names($info[0][$this->_group_attribute]); //presuming the entry returned is our guy (unique usernames)

        if ($recursive){
            foreach ($groups as $id => $group_name){
                $extra_groups=$this->recursive_groups($group_name);
                $groups=array_merge($groups,$extra_groups);
            }
        }
        return ($groups);
    }
623329
def get_user_groups(self, user):
        
        self.project_service.set_auth(self._token_project)
        return self.project_service.get_user_groups(user)
29158
public function getGroups()
	{
		if ( ! $this->userGroups)
		{
			$this->userGroups = $this->groups()->get();
		}

		return $this->userGroups;
	}