Loads role assignments for user.

@param $userId

@return \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList
171021
public function loadRoleAssignmentsForUser($userId)
    {
        $user = $this->userService->loadUser($userId);

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

        return new Values\RoleAssignmentList($roleAssignments, $user->id);
    }
1192127
public function assignRole($roleName, $userId)
    {
        $role = $this->role->findByName($roleName);
        $user = $this->model->find($userId);

        $user->roles()->attach($role);
    }
963705
public function readScopes(int $userId): array
    {
        /** @var Connection $connection */
        $connection  = $this->getContainer()->get(Connection::class);
        $query       = $connection->createQueryBuilder();
        $users       = 'u';
        $uRoleId     = Model::FIELD_ID_ROLE;
        $rolesScopes = 'rs';
        $rsRoleId    = RoleScope::FIELD_ID_ROLE;
        $query
            ->select(RoleScope::FIELD_ID_SCOPE)
            ->from(Model::TABLE_NAME, $users)
            ->leftJoin($users, RoleScope::TABLE_NAME, $rolesScopes, "$users.$uRoleId = $rolesScopes.$rsRoleId")
            ->where(Model::FIELD_ID . '=' . $query->createPositionalParameter($userId, PDO::PARAM_INT));
        $statement = $query->execute();

        $scopes = [];
        while (($fetchedScope = $statement->fetchColumn()) !== false) {
            $scopes[] = $fetchedScope;
        }

        return $scopes;
    }
1141349
protected function loadUserRolesViaData($userId)
    {
        $crudRoles = $this->userRoleIdentifier->listEntries(['user' => $userId], ['user' => '=']);
        $roles = ['ROLE_USER'];
        if ($crudRoles !== null) {
            foreach ($crudRoles as $crudRole) {
                $role = $crudRole->get('role');
                $roles[] = $role['name'];
            }
        }
        return $roles;
    }
1000027
public function loadRoleAssignment($roleAssignmentId)
    {
        $query = $this->handler->createSelectQuery();
        $query->select(
            $this->handler->quoteColumn('id'),
            $this->handler->quoteColumn('contentobject_id'),
            $this->handler->quoteColumn('limit_identifier'),
            $this->handler->quoteColumn('limit_value'),
            $this->handler->quoteColumn('role_id')
        )->from(
            $this->handler->quoteTable('ezuser_role')
        )->where(
            $query->expr->eq(
                $this->handler->quoteColumn('id'),
                $query->bindValue($roleAssignmentId, null, \PDO::PARAM_INT)
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
1182155
public function getUserCapabilities(string $userId): array
    {
        if (empty($this->userCapabilities)) {
            $this->userCapabilities = Utils::fetchUserCapabilities($userId);
        }

        return $this->userCapabilities;
    }
113190
public static function get_contexts_for_userid(int $userid) : contextlist {
        $contextlist = new contextlist();
        $contextlist->add_from_sql("SELECT c.id
                  FROM {context} c
                  JOIN {tag} t ON t.userid = :userid
                 WHERE contextlevel = :contextlevel",
            ['userid' => $userid, 'contextlevel' => CONTEXT_SYSTEM]);
        return $contextlist;
    }
1122307
public function load($userId)
    {
        $data = $this->userGateway->load($userId);

        if (empty($data)) {
            throw new NotFound('user', $userId);
        }

        return $this->mapper->mapUser(reset($data));
    }
205073
protected function get_graders($userid) {
        // Potential graders should be active users only.
        $potentialgraders = get_enrolled_users($this->context, "mod/assign:grade", null, 'u.*', null, null, null, true);

        $graders = array();
        if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
            if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
                foreach ($groups as $group) {
                    foreach ($potentialgraders as $grader) {
                        if ($grader->id == $userid) {
                            // Do not send self.
                            continue;
                        }
                        if (groups_is_member($group->id, $grader->id)) {
                            $graders[$grader->id] = $grader;
                        }
                    }
                }
            } else {
                // User not in group, try to find graders without group.
                foreach ($potentialgraders as $grader) {
                    if ($grader->id == $userid) {
                        // Do not send self.
                        continue;
                    }
                    if (!groups_has_membership($this->get_course_module(), $grader->id)) {
                        $graders[$grader->id] = $grader;
                    }
                }
            }
        } else {
            foreach ($potentialgraders as $grader) {
                if ($grader->id == $userid) {
                    // Do not send self.
                    continue;
                }
                // Must be enrolled.
                if (is_enrolled($this->get_course_context(), $grader->id)) {
                    $graders[$grader->id] = $grader;
                }
            }
        }
        return $graders;
    }
904694
public function UserCacheRoles($UserID, $RoleIDs) {
      if (is_null($UserID) || !$UserID) return FALSE;
      
      $Cached = TRUE;
      
      $UserRolesKey = FormatString(self::USERROLES_KEY, array('UserID' => $UserID));
      $Cached = $Cached & Gdn::Cache()->Store($UserRolesKey, $RoleIDs);
      return $Cached;
   }
254156
public function findAllUsersByRoleId($roleId)
    {
        $qb = $this->createQueryBuilder('user')
            ->leftJoin('user.userRoles', 'userRole')
            ->leftJoin('userRole.role', 'role')
            ->where('role=:roleId');

        $query = $qb->getQuery();
        $query->setParameter('roleId', $roleId);

        return $query->getResult();
    }
567173
public function assign($userId, $name)
    {
        if ($this->searchRoleRecursive($this->roles, $name)) {
            $exists = $this->db->exists('rbac_user', ['user' => $userId, 'role' => $name]);
            if (!$exists) {
                return $this->db->insert('rbac_user', ['role' => $name, 'user' => $userId]);
            }
        }

        return false;
    }
28351
public function listRepositories($userId = null)
    {
        $parameters = [];
        if ($userId) {
            $parameters['user_id'] = $userId;
        }

        return $this->get('/installation/repositories', $parameters);
    }
1165098
public function assign($role, $userId) {
		
		$userId = $this->getId($userId);
		$entity = \App::$domain->account->login->oneById($userId);
		$assignEntity = $this->forgeEntity([
			'user_id' => $userId,
			'item_name' => $role,
		]);
		$this->insert($assignEntity);
		return AssignmentHelper::forge($userId, $role);
	}
384784
public function participantsUserIds($userId = null)
    {
        $users = $this->participants()->lists('user_id');

        if ($userId) {
            $users[] = $userId;
        }

        return $users;
    }
891222
public function loadRoleAssignmentsByRoleId($roleId)
    {
        $data = $this->roleGateway->loadRoleAssignmentsByRoleId($roleId);

        if (empty($data)) {
            return array();
        }

        return $this->mapper->mapRoleAssignments($data);
    }
1328701
public function loadUserDrafts($userId, Request $request)
    {
        $contentDrafts = $this->contentService->loadContentDrafts(
            $this->userService->loadUser($userId)
        );

        return new Values\VersionList($contentDrafts, $request->getPathInfo());
    }