添加群成员——批量

@param string $group_id
@param array  $users [用户名称 数组]

@return mixed
@throws EasemobError
970426
public function groupAddUsers($group_id, $users)
    {
        if (count($users) >= 60 || count($users) < 1) {
            throw new EasemobError('一次最多可以添加60位成员,最少为1个');
        }

        $url          = $this->url.'chatgroups/'.$group_id.'/users';
        $option       = [
            'usernames' => $users
        ];
        $access_token = $this->getToken();
        $header []    = 'Authorization: Bearer '.$access_token;

        return Http::postCurl($url, $option, $header, 'POST');
    }
41226
function add_to_group($group_id, $contact_ids)
    {
        $group_cache = $this->_fetch_groups();
        $member_attr = $group_cache[$group_id]['member_attr'];
        $group_dn    = $group_cache[$group_id]['dn'];
        $new_attrs   = array();

        if (!is_array($contact_ids)) {
            $contact_ids = explode(',', $contact_ids);
        }

        foreach ($contact_ids as $id) {
            $new_attrs[$member_attr][] = self::dn_decode($id);
        }

        if (!$this->ldap->mod_add($group_dn, $new_attrs)) {
            $this->set_error(self::ERROR_SAVING, 'errorsaving');
            return 0;
        }

        if ($this->cache) {
            $this->cache->remove('groups');
        }

        return count($new_attrs[$member_attr]);
    }
1025695
public function copy($userGroupId, $group, $copyMembers = 0)
    {
        $this->groupId = $userGroupId;
        $this->copyMembers = $copyMembers;

        $this->getLogger()->info('Creating a copy of User Group ID ' . $userGroupId);
        $response = $this->doPost('/group/' . $userGroupId . '/copy', [
            'group' => $group,
            'copyMembers' => $copyMembers
        ]);

        /** @var XiboUserGroup $userGroup */
        $userGroup = $this->hydrate($response);

        return $userGroup;
    }
392170
def add_manager_to_group(self, group_id, user_id):
        
        url = self.TEAM_MANAGERS_URL % (group_id, user_id)

        connection = Connection(self.token)
        connection.set_url(self.production, url)

        return connection.post_request()
486681
public function roomAddUsers($room_id, $users)
    {
        $url          = $this->url.'chatrooms/'.$room_id.'/users';
        $option       = [
            'usernames' => $users
        ];
        $access_token = $this->getToken();
        $header []    = 'Authorization: Bearer '.$access_token;

        return Http::postCurl($url, $option, $header, 'POST');
    }
1149886
public function getGroupDetail($group_id, $begin = 0, $count = 100)
    {
        $url = "https://api.weixin.qq.com/shakearound/device/group/getdetail?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['group_id' => $group_id, 'begin' => $begin, 'count' => $count]);
    }
178316
public function stepCreateMemberWithGroup($id, $groupId) {
		$group = $this->fixtureFactory->get('Group', $groupId);
		if(!$group) $group = $this->fixtureFactory->createObject('Group', $groupId);
		
		$member = $this->fixtureFactory->createObject('Member', $id);
		$member->Groups()->add($group);
	}
376825
public function parseGroup($group_id)
    {
        list($data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id, true);

        $group = new Group();
        $group->parse($data);

        try {
            list($member_data) = $this->_callUrl($this->api_base . '/api/public/groups/' . $group_id . '/members', true);
        } catch (Exception $e) {
            // Can't collect member data
            $member_data = false;
        }

        if ($member_data) {
            /** @var Habbo[] $members */
            $members = array();
            foreach ($member_data as $member) {
                $temp_habbo = new Habbo();
                $temp_habbo->parse($member);
                $members[] = $temp_habbo;
            }
            $group->setMembers($members);
        }

        return $group;
    }
8793
public function deleteUser($groupId, $userId, $options=array()){

        $data = array();
        
        $data['group_id'] = $groupId;
        $data['user_id'] = $userId;

        $data = array_merge($data, $options);

        return $this->request($this->userDeleteUrl, $data);
    }
1086396
public function updateUserCount($groupIds)
    {
        $query = $this->UsersGroups->find();
        $groupIdUserCount = $query
            ->select(['group_id', 'user_count' => $query->func()->count('user_id')])
            ->where(['group_id IN' => $groupIds])->group('group_id')
            ->combine('group_id', 'user_count')->toArray();

        foreach ($groupIds as $groupId) {
            $userCount = isset($groupIdUserCount[$groupId]) ? $groupIdUserCount[$groupId] : 0;
            $this->save($this->get($groupId)->set('user_count', $userCount));
        }
    }
229897
def show_group(self, group_id):
        
        res = self.post('loadGroups', {'groupId': group_id})
        if isinstance(res, list):
            return _fix_group(res[0])
        else:
            return _fix_group(res)
762021
public function addGroup($user_id, $group_id) {
    try {
      $group = Group::findOrFail($group_id);
      $user = User::findOrFail($user_id);
      $user->addGroup($group);
    } catch (ModelNotFoundException $e) {
      throw new NotFoundException;
    }
  }
77019
public function remove_user_from_group($user, $groupid) {
        global $DB;
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!groups_remove_member_allowed($group, $user)) {
            return false;
        }
        if (!$group) {
            return false;
        }
        return groups_remove_member($group, $user);
    }
801484
def get_group_by_id(self, group_id) -> typing.Optional['Group']:
        
        for group in self.groups:

            if group.group_id == group_id:
                return group

        return None
514112
def cli(ctx, group, user):
    
    return ctx.gi.users.add_to_group(group, user)
971653
public function groupDelete($group_id){
        $params=array(
            'group_id'=>$group_id
        );
        $rst = $this->_request->post($this->_url . 'group/delete', $params);
        return $this->_client->rst($rst);
    }
1201772
public function add_user_to_group($user, $groupid) {
        require_capability('moodle/course:managegroups', $this->context);
        $group = $this->get_group($groupid);
        if (!$group) {
            return false;
        }
        return groups_add_member($group->id, $user->id);
    }