@param array $groupIds

@return array
324111
public function getCountsUsersByGroups(array $groupIds) {
        array_walk($groupIds, function(&$item) {$item = new \MongoId($item);});
        $qa = $this->createAggregationQuery();
        $qa->project(array('_id' => 0, 'groups' => 1));
        $qa->unwind('$groups');
        $qa->match(array('groups.$id' => array('$in' => $groupIds)));
        $qa->group(array('_id' => '$groups', 'sum' => array('$sum' => 1)));
        $qa->project(array('_id' => 0, 'groups' => '$_id', 'sum' => 1));

        $aggregateGroupUsers = $qa->getQuery()->aggregate()->toArray();
        $nbrGroupsUsers = array();
        array_walk($aggregateGroupUsers, function($item) use (&$nbrGroupsUsers) {
            $groupId = $item['groups']['$id']->{'$id'};
            $nbrGroupsUsers[$groupId] = $item['sum'];
        });

        return array_merge(array_combine($groupIds, array_fill(0, count($groupIds), 0)), $nbrGroupsUsers);
    }
687818
public function deleteGroup($groupId)
    {
        return $this->auth(function () use ($groupId) {
            return $this->http->postJson(
                $this->baseUrl . 'cgi-bin/groups/delete?access_token=' . $this->accessToken,
                json_encode(
                    [
                        'group' => [
                            'id' => $groupId,
                        ],
                    ],
                    JSON_UNESCAPED_UNICODE
                )
            );
        });
    }
1174944
public function updateGroup($groupId)
    {
        $group = wei()->group()->findOrInitById($groupId);
        $ret = wei()->event->until('groupMove', [[$this['id']], $group]);
        if ($ret) {
            return $ret;
        }

        $this->save(['groupId' => $groupId]);

        return ['code' => 1, 'message' => '操作成功'];
    }
528901
public function getGroups( $uid ) {
        static $groups = [];
        if ( isset($groups[$uid]) )
            return $groups[$uid];
        $user_groups = Db::table( $this->prefix.$this->_config['auth_group_access'] )
            ->alias('a')
            ->join( $this->prefix.$this->_config['auth_group']." g", "g.id=a.group_id" )
            ->where( "a.uid='$uid' and g.status='1'" )
            ->field( 'uid,group_id,title,rules' )->select();
        $groups[$uid] = $user_groups ? $user_groups : [];
        return $groups[$uid];
    }
51176
public function loadTypesDataForGroup($groupId, $status)
    {
        $q = $this->getLoadTypeQueryBuilder();
        $q
            ->where($q->expr()->eq('g.group_id', ':gid'))
            ->andWhere($q->expr()->eq('c.version', ':version'))
            ->addOrderBy('c.identifier')
            ->setParameter('gid', $groupId, ParameterType::INTEGER)
            ->setParameter('version', $status, ParameterType::INTEGER);

        return $q->execute()->fetchAll();
    }
682925
private function getNavigationElementsByGroup($groupId)
    {
        $entries = array();
        foreach (MenuService::getPerspectivesByGroup($groupId) as $i => $perspective) {
            $binding = $perspective->getBinding();
            $children = $this->getMenuElementChildren($perspective);

            if (!empty($binding) || !empty($children)) {
                $entry = array(
                    'perspective' => $perspective,
                    'children'    => $children
                );
                if (!is_null($binding)) {
                    $entry['binding'] = $perspective->getExtension() . '/' . $binding;
                }
                $entries[$i] = $entry;
            }
        }
        return $entries;
    }
724914
public function findAllForGroup($groupId)
    {
        if (!$groupId) {
            return [];
        }

        if (!is_array($groupId)) {
            $groupId = [$groupId];
        }

        $cacheKey = join('_', $groupId);

        $permissions = Cache::remember($cacheKey, function () use ($groupId) {
            return $this
                ->find('list', [
                    'keyField' => 'path',
                    'valueField' => 'allowed'
                ])
                ->where([
                    'group_id IN' => $groupId,
                    'allowed >' => 0
                ])
                ->order('allowed DESC')
                ->hydrate(false)
                ->toArray();
        }, 'wasabi/core/group_permissions');

        return $permissions;
    }
908175
public function deleteGroup($groupId)
    {
        $q = $this->dbHandler->createDeleteQuery();
        $q->deleteFrom($this->dbHandler->quoteTable('ezcontentclassgroup'))
            ->where(
                $q->expr->eq(
                    $this->dbHandler->quoteColumn('id'),
                    $q->bindValue($groupId, null, \PDO::PARAM_INT)
                )
            );
        $q->prepare()->execute();
    }
158647
public function extractGroupsFromRows(array $rows)
    {
        $groups = array();

        foreach ($rows as $row) {
            $group = new Group();
            $group->id = (int)$row['id'];
            $group->created = (int)$row['created'];
            $group->creatorId = (int)$row['creator_id'];
            $group->modified = (int)$row['modified'];
            $group->modifierId = (int)$row['modifier_id'];
            $group->identifier = $row['name'];

            $groups[] = $group;
        }

        return $groups;
    }
1223269
public function fetchGroupMembers($groupId)
    {
        $result = $this->_get($this->_groupUrl($groupId, '/members'));
        return Deserialize::groupMembers($result);
    }
733920
public static function getPerspectivesByGroup($groupId) {
        $perspectives = array();
        foreach(self::getAllPerspectives() as $perspective) {
            if($perspective -> getGroup() === $groupId) {
                $perspectives[] = $perspective;
            }
        }
        return $perspectives;
    }
69238
public function getGroup($uid){
        
        $groupIds = $this->getGroupIds($uid);
        
        $groups = DB::table($this->dbTablePrefix . $this->tableGroup)
                    ->where('id' , 'in' , $groupIds)
                    ->where('status' , '1')
                    ->order('sort asc')
                    ->select();
        
        return $groups;
        
    }
396810
public function replaceGroup($groupId, Api\GroupCreate $group)
    {
        $json = Serialize::group($group);
        $result = $this->_put($this->_groupUrl($groupId), $json);
        return Deserialize::groupResponse($result);
    }
389589
public function getGroupMember($groupId, $memberId)
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('groups/%d/members/%d', $groupId, $memberId))
		);
	}
509344
public function deleteObjectStateGroup($groupId)
    {
        try {
            return $this->innerGateway->deleteObjectStateGroup($groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
432512
public static function get_groupings($groupingids, $returngroups = false) {
        global $CFG, $DB;
        require_once("$CFG->dirroot/group/lib.php");
        require_once("$CFG->libdir/filelib.php");

        $params = self::validate_parameters(self::get_groupings_parameters(),
                                            array('groupingids' => $groupingids,
                                                  'returngroups' => $returngroups));

        $groupings = array();
        foreach ($params['groupingids'] as $groupingid) {
            // Validate params.
            $grouping = groups_get_grouping($groupingid, '*', MUST_EXIST);

            // Now security checks.
            $context = context_course::instance($grouping->courseid);
            try {
                self::validate_context($context);
            } catch (Exception $e) {
                $exceptionparam = new stdClass();
                $exceptionparam->message = $e->getMessage();
                $exceptionparam->courseid = $grouping->courseid;
                throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
            }
            require_capability('moodle/course:managegroups', $context);

            list($grouping->description, $grouping->descriptionformat) =
                external_format_text($grouping->description, $grouping->descriptionformat,
                        $context->id, 'grouping', 'description', $grouping->id);

            $groupingarray = (array)$grouping;

            if ($params['returngroups']) {
                $grouprecords = $DB->get_records_sql("SELECT * FROM {groups} g INNER JOIN {groupings_groups} gg ".
                                               "ON g.id = gg.groupid WHERE gg.groupingid = ? ".
                                               "ORDER BY groupid", array($groupingid));
                if ($grouprecords) {
                    $groups = array();
                    foreach ($grouprecords as $grouprecord) {
                        list($grouprecord->description, $grouprecord->descriptionformat) =
                        external_format_text($grouprecord->description, $grouprecord->descriptionformat,
                        $context->id, 'group', 'description', $grouprecord->groupid);
                        $groups[] = array('id' => $grouprecord->groupid,
                                          'name' => $grouprecord->name,
                                          'idnumber' => $grouprecord->idnumber,
                                          'description' => $grouprecord->description,
                                          'descriptionformat' => $grouprecord->descriptionformat,
                                          'enrolmentkey' => $grouprecord->enrolmentkey,
                                          'courseid' => $grouprecord->courseid
                                          );
                    }
                    $groupingarray['groups'] = $groups;
                }
            }
            $groupings[] = $groupingarray;
        }

        return $groupings;
    }
25129
public function fetchGroupTags($groupId)
    {
        $result = $this->_get($this->_groupUrl($groupId, '/tags'));
        return Deserialize::tags($result);
    }