Check required group(s)
488975
def check_membership(self, group):
        
        user_groups = self.request.user.groups.values_list("name", flat=True)
        if isinstance(group, (list, tuple)):
            for req_group in group:
                if req_group in user_groups:
                    return True

        is_member = group in user_groups
        if not is_member:
            messages.add_message(self.request, messages.ERROR, 'You do not have sufficient permissions to do that.')

        return is_member
716992
private void checkOthers(Collidable objectA, Entry<Point, Set<Collidable>> current)
    {
        for (final Integer acceptedGroup : objectA.getAccepted())
        {
            // Others to compare only in accepted group
            if (collidables.containsKey(acceptedGroup))
            {
                checkOthers(objectA, current, acceptedGroup);
            }
        }
    }
693916
public function orGroup()
    {
        $conditions = func_get_args();
        if (Collection::count($conditions) == 0) {
            throw new ErrorException('Missing arguments for orGroup() ');
        }
        //
        return $this->groupWhere($conditions[0], 'or', $conditions);
    }
1370436
def get_required(self, obj):
        """"""
        required = []

        for field_name, field in sorted(obj.fields.items()):
            if field.required:
                required.append(field.name)

        return required or missing
1246741
def get_roles(self, groups):
        """"""
        roles = set([])
        parentroles = set([])
        notroles = set([])
        tmp = set([])
        usedgroups = {}
        unusedgroups = {}
        ret = {}
        # determine roles membership
        for role in self.roles:
            if self._check_member(
                    role, groups, notroles,
                    tmp, parentroles, usedgroups):
                roles.add(role)
        # determine standalone groups not matching any roles
        for b in groups:
            for g in groups[b]:
                if b not in usedgroups or g not in usedgroups[b]:
                    if b not in unusedgroups:
                        unusedgroups[b] = set([])
                    unusedgroups[b].add(g)

        ret['roles'] = roles
        ret['unusedgroups'] = unusedgroups
        return ret
540458
def by_user(config):
        """"""
        client = Client()
        client.prepare_connection()
        audit_api = API(client)
        CLI.parse_membership('Groups by User', audit_api.by_user())
816340
def _check_user(user, group):
    '''
    
    '''
    err = ''
    if user:
        uid = __salt__['file.user_to_uid'](user)
        if uid == '':
            err += 'User {0} is not available '.format(user)
    if group:
        gid = __salt__['file.group_to_gid'](group)
        if gid == '':
            err += 'Group {0} is not available'.format(group)
    return err
364223
def _guess_group(info):
    """"""
    value = "fake"
    if "metadata" in info:
        if info["metadata"]:
            return ",".join(map(str, info["metadata"].values()))
    return value
1155629
def get_ngroups(self, field=None):
        '''
        
        '''
        field = field if field else self._determine_group_field(field)
        if 'ngroups' in self.data['grouped'][field]:
            return self.data['grouped'][field]['ngroups']
        raise ValueError("ngroups not found in response. specify group.ngroups in the query.")
1065703
protected function verifyGroupRequirements()
    {
        if (isset($this->requiredFieldsGroups)) {
            $fields = $this->requiredFieldsGroups->getArrayCopy();

            $emptyFlag = false;
            $groupsFormatted = [];

            foreach ($fields as $group => $groupFields) {
                $groupsFormatted[] = sprintf(
                    '%s (%s)',
                    ucfirst($group),
                    implode(', ', $groupFields)
                );

                foreach ($groupFields as $field) {
                    if (!empty($this->$field)) {
                        $emptyFlag = true;
                    }
                }
            }

            if (!$emptyFlag) {
                throw new \Genesis\Exceptions\ErrorParameter(
                    sprintf(
                        'One of the following group/s of field/s must be filled in: %s%s',
                        PHP_EOL,
                        implode(
                            PHP_EOL,
                            $groupsFormatted
                        )
                    ),
                    true
                );
            }
        }
    }
151274
def get_user_groups(user):
    """"""
    if user.is_active and user.is_authenticated():
        if user.is_superuser:
            return TenantGroup.objects.all()
        else:
            return TenantGroup.objects.filter(tenantrole__user=user).distinct()
    else:
        return TenantGroup.objects.none()
217484
def _validate(cls, group_name):
        
        if group_name and not cls._group_name_regex.match(group_name):
            raise ArgumentError("'%s': Illegal group name" % (group_name,))
        if group_name and len(group_name) > 255:
            raise ArgumentError("'%s': Group name is too long" % (group_name,))
1076758
def user_in_all_groups(user, groups):
    """"""
    return user_is_superuser(user) or all(user_in_group(user, group) for group in groups)
265524
def get_groups(self, load):
        '''
        
        '''
        if 'eauth' not in load:
            return False
        fstr = '{0}.groups'.format(load['eauth'])
        if fstr not in self.auth:
            return False
        fcall = salt.utils.args.format_call(
            self.auth[fstr],
            load,
            expected_extra_kws=AUTH_INTERNAL_KEYWORDS)
        try:
            return self.auth[fstr](*fcall['args'], **fcall['kwargs'])
        except IndexError:
            return False
        except Exception:
            return None
732044
def is_group_valid(self, groupID):
        
        cur = self.conn.cursor()
        cur.execute('SELECT * FROM groups WHERE id=? LIMIT 1', [groupID])
        results = cur.fetchall()
        cur.close()

        logging.debug('is_group_valid(groupID={}) => {}'.format(groupID, True if len(results) else False))
        return len(results) > 0
1339860
private function groupIsSecure() : bool
    {
        foreach ($this->groupOptionsStack as $groupOptions) {
            if (isset($groupOptions['https']) && $groupOptions['https']) {
                return true;
            }
        }

        return false;
    }
1102853
def in_group(self, group, dn=False):
        
        if dn:
            return group in self.groups()
        return group.check_member(self)