(Temporarily) the group of the current user.

@param int $groupId
@return self
184933
public function setGroupTemp($groupId)
    {
        if ($groupId == $this->_getVar('user_group')) {
            $this->_unsetVar('current_user_group');
            $this->_unsetVar('current_user_role');
        } else {
            $groups = $this->getAllowedStaffGroups(false);

            $group = $this->userLoader->getGroup($groupId);

            if (isset($groups[$groupId])) {
                $this->_setVar('current_user_group', $groupId);
                $this->_setVar('current_user_role',  $group->getRole());
            } elseif ($group->isActive()) {
                throw new \Gems_Exception($this->_('No access to group'), 403, null, sprintf(
                        $this->_('You are not allowed to switch to the %s group.'),
                        $group->getName()
                        ));
            } else {
                throw new \Gems_Exception($this->_('No access to group'), 403, null, sprintf(
                        $this->_('You cannot switch to an inactive or non-existing group.')
                        ));
            }
        }
        return $this;
    }
1237856
public function setUserId( $userId )
    {
        $this->_user    = null;
        $this->userId   = ( (int) $userId ) ?: null;
        return $this;
    }
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);
    }
548860
public function loadGroup($groupId)
    {
        $groups = $this->mapper->extractGroupsFromRows(
            $this->contentTypeGateway->loadGroupData([$groupId])
        );

        if (count($groups) !== 1) {
            throw new Exception\TypeGroupNotFound($groupId);
        }

        return $groups[0];
    }
284211
public function groupBy($group)
    {
        if (is_string($group)) {
            $group = [$group];
        }

        $this->group = $group;
        return $this;
    }
1199812
public function leaveGroup($groupId)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the success response code.
		$this->oauth->setOption('success_code', 204);

		// Set the API base
		$base = '/v1/people/~/group-memberships/' . $groupId;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'DELETE', $parameters);

		return $response;
	}
1236518
public function groupBy($group)
    {
         //Argument 1 must be a string or array
         Argument::i()->test(1, 'string', 'array');
            
        if (is_string($group)) {
            $group = array($group);
        }
        
        $this->group = $group;
        return $this;
    }
807681
public static function changeGroup(int $group_id) {
		\Application::set('flag.global.__in_group_id', $group_id);
		\I18n::init();
		setcookie("__in_group_id", $group_id);
	}
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
                )
            );
        });
    }
579668
static public function create($groupId, $siteId, Site $site = null)
    {
        $instance = new self();

        $instance->group_id = $groupId;
        $instance->site_id = $siteId;

        return $instance;
    }
428221
public function addGroup($group)
    {
        if ($this->groups === null) {
            $this->setGroups($this->groupRepository->getAllByRevision($this));
        }
        $this->groups[] = $group;
        return $this;
    }
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);
        }
    }
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);
    }
396810
public function replaceGroup($groupId, Api\GroupCreate $group)
    {
        $json = Serialize::group($group);
        $result = $this->_put($this->_groupUrl($groupId), $json);
        return Deserialize::groupResponse($result);
    }
315990
public function get_group($groupid) {
        $groups = $this->get_all_groups();
        if (!array_key_exists($groupid, $groups)) {
            return false;
        }
        return $groups[$groupid];
    }
990655
public function deleteGroup($groupId)
    {
        try {
            return $this->innerGateway->deleteGroup($groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
112524
public function stack($elements, $groupId, $position = null): self
    {
        $group = new Group($groupId);

        $this->filter(function ($element) use ($elements) {
            return in_array($element->id(), $elements, true);
        })->each(function ($element) use ($group) {
            $group->push($element);
            $this->items = $this->without($element->id())->all();
        });

        if ($position) {
            $this->insert($group, $position);
        } else {
            $this->push($group);
        }

        return $this;
    }