Unassigns the user from a user group.

@param $userId
@param $groupPath

@throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException

@return \eZ\Publish\Core\REST\Server\Values\UserGroupRefList
519070
public function unassignUserFromUserGroup($userId, $groupPath)
    {
        $user = $this->userService->loadUser($userId);
        $userGroupLocation = $this->locationService->loadLocation(trim($groupPath, '/'));

        $userGroup = $this->userService->loadUserGroup(
            $userGroupLocation->contentId
        );

        try {
            $this->userService->unAssignUserFromUserGroup($user, $userGroup);
        } catch (ApiExceptions\InvalidArgumentException $e) {
            // User is not in the group
            throw new Exceptions\ForbiddenException($e->getMessage());
        }

        $userGroups = $this->userService->loadUserGroupsOfUser($user);
        $restUserGroups = array();
        foreach ($userGroups as $userGroup) {
            $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
            $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
            $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);

            $restUserGroups[] = new Values\RestUserGroup(
                $userGroup,
                $contentType,
                $userGroupContentInfo,
                $userGroupLocation,
                $this->contentService->loadRelations($userGroup->getVersionInfo())
            );
        }

        return new Values\UserGroupRefList(
            $restUserGroups,
            $this->router->generate(
                'ezpublish_rest_loadUserGroupsOfUser',
                array('userId' => $userId)
            ),
            $userId
        );
    }
535725
public static function get_users_in_context(userlist $userlist) {
        $context = $userlist->get_context();

        if (!$context instanceof \context_course) {
            return;
        }

        static::get_group_members_in_context($userlist, '');
    }
1024728
public function delete(Group $group, $userId = null)
    {
        $this->dispatch($group, 'preDelete', [], $userId);

        $this->database->delete('ucms_group')->condition('id', $group->getId())->execute();

        $this->dispatch($group, 'delete', [], $userId);
    }
93784
public function loadSubUserGroups($groupPath, Request $request)
    {
        $offset = $request->query->has('offset') ? (int)$request->query->get('offset') : 0;
        $limit = $request->query->has('limit') ? (int)$request->query->get('limit') : 25;

        $userGroupLocation = $this->locationService->loadLocation(
            $this->extractLocationIdFromPath($groupPath)
        );

        $userGroup = $this->userService->loadUserGroup(
            $userGroupLocation->contentId
        );

        $subGroups = $this->userService->loadSubUserGroups(
            $userGroup,
            $offset >= 0 ? $offset : 0,
            $limit >= 0 ? $limit : 25,
            Language::ALL
        );

        $restUserGroups = array();
        foreach ($subGroups as $subGroup) {
            $subGroupContentInfo = $subGroup->getVersionInfo()->getContentInfo();
            $subGroupLocation = $this->locationService->loadLocation($subGroupContentInfo->mainLocationId);
            $contentType = $this->contentTypeService->loadContentType($subGroupContentInfo->contentTypeId);

            $restUserGroups[] = new Values\RestUserGroup(
                $subGroup,
                $contentType,
                $subGroupContentInfo,
                $subGroupLocation,
                $this->contentService->loadRelations($subGroup->getVersionInfo())
            );
        }

        if ($this->getMediaType($request) === 'application/vnd.ez.api.usergrouplist') {
            return new Values\CachedValue(
                new Values\UserGroupList($restUserGroups, $request->getPathInfo()),
                array('locationId' => $userGroupLocation->id)
            );
        }

        return new Values\CachedValue(
            new Values\UserGroupRefList($restUserGroups, $request->getPathInfo()),
            array('locationId' => $userGroupLocation->id)
        );
    }
1311073
public function userHasGroup($groupName, DeterminableUserInterface $user)
    {
        $userHasGroup = false;
        if (true === in_array($groupName, $user->getGroups())) {
            $userHasGroup = true;
        }
        return $userHasGroup;
    }
1009844
public function deleteUser($userId)
    {
        try {
            return $this->innerGateway->deleteUser($userId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
873719
public function removeUser($groupName, $username)
    {
        $groupDn = $this->dn($groupName);

        $userDn = $this->adldap->user()->dn($username);

        if (is_string($groupDn) && is_string($userDn)) {
            $del = [];
            $del['member'] = $userDn;

            return $this->connection->modDelete($groupDn, $del);
        }

        return false;
    }
1190770
public function findGmailUserById(string $userId)
    {
        foreach ($this->gmailUsers as $user) {
            /** @var GmailUserInterface $user */
            if ($user->getUserId() === $userId) {
                return $user;
            }
        }

        return;
    }
1184579
protected function unassignUserFromUserGroups(User $user, array $userGroups)
    {
        $existingUserGroups = $this->userService->loadUserGroupsOfUser($user);
        foreach ($existingUserGroups as $existingUserGroup) {
            if (!array_key_exists($existingUserGroup->id, $userGroups)) {
                $this->userService->unAssignUserFromUserGroup($user, $existingUserGroup);
            }
        }
    }
317368
public function deleteUser($userId)
    {
        // Forget remembered users.
        $this->userEntities = [];

        $query = $this->deleteUserQuery($userId);

        return $query->execute();
    }
1328370
public function batchDeleteUser(array $userIdList)
    {
        $result = $this->httpRaw(self::WECHAT_USER_BATCH_DELETE_PREFIX, [
            'useridlist' => $userIdList
        ], [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && ($result['errcode'] ? $this->dump([$result,$this->getAccessToken()]) : !$result['errcode']);
    }
267862
public function removeMember($id, $userId)
    {
        try {
            $result = $this->service->remove(Auth::user(), $id, $userId);

            if ($result) {
                return back()->with('message', 'Successfully removed member');
            }

            return back()->with('message', 'Failed to remove member');
        } catch (Exception $e) {
            return back()->withErrors($e->getMessage());
        }
    }
47695
public function delete($userId)
    {
        if (is_array($userId)) {
            return $this->batchDelete($userId);
        }

        return $this->httpGet('cgi-bin/user/delete', ['userid' => $userId]);
    }
734604
public function userUnreadMessages($userId)
    {
        $messages = $this->messages()->get();

        try {
            $participant = $this->getParticipantFromUser($userId);
        } catch (ModelNotFoundException $e) {
            return collect();
        }

        if (!$participant->last_read) {
            return $messages;
        }

        return $messages->filter(function ($message) use ($participant) {
            return $message->updated_at->gt($participant->last_read);
        });
    }
1051923
public function unassignDisplayGroup($displayGroupId)
    {
        $this->getLogger()->info('Unassigning display Group ID ' . json_encode($displayGroupId) . ' From display Group ID ' . $this->displayGroupId);
        $this->doPost('/displaygroup/' . $this->displayGroupId . '/displayGroup/unassign', [
        'displayGroupId' => $displayGroupId
        ]);
        return $this;
    }
516211
public function changeAllGroups (array $userOpenIDs, $groupID)
    {
        if (count($userOpenIDs) < 1) {
            throw new InvalidArgumentException("At least one user is required.");
        }

        // Build requests.
        $requests = function ($users) use ($groupID) {
            foreach (array_chunk($users, 50) as $chunk) {
                yield new Request(
                    "POST",
                    "https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate",
                    [],
                    json_encode([
                        'openid_list' => $chunk,
                        'to_groupid'  => $groupID,
                    ])
                );
            }
        };

        $failed = [];

        (new Pool(
            $this->client,
            $requests($userOpenIDs),
            [   
                'rejected' => function (RequestException $reason) use (&$failed) {
                    $json = json_decode((string)$reason->getRequest()->getBody());

                    if (isset($json->openid_list)) {
                        $failed = array_merge($failed, $json->openid_list);
                    }
                },
            ]
        ))->promise()->wait();

        return $failed;
    }
171021
public function loadRoleAssignmentsForUser($userId)
    {
        $user = $this->userService->loadUser($userId);

        $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);

        return new Values\RoleAssignmentList($roleAssignments, $user->id);
    }