Get the user fetch query.

@param string|int $userId

@return QueryBuilder
437468
public function getUserAuthDataQuery($userId)
    {
        $qb = $this->createQueryBuilder();
        $qb->select('id')
            ->addSelect('password')
            ->addSelect('shadowpassword')
            ->where('id = :userId')
            ->setParameter('userId', $userId);

        return $qb;
    }
543981
public function getItemsByUser($userId)
    {
        if (empty($userId)) {
            return [];
        }

        $query = (new Query)->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_id' => (string) $userId]);

        $roles = [];
        foreach ($query->all($this->db) as $row) {
            $roles[$row['name']] = $this->populateItem($row);
        }
        return $roles;
    }
817660
public function getAccessTokenList($userId)
    {
        $stmt = $this->db->prepare(
            'SELECT
                provider_id, issued_at, access_token, token_type, expires_in, refresh_token, scope
             FROM access_tokens
             WHERE
                user_id = :user_id'
        );

        $stmt->bindValue(':user_id', $userId, PDO::PARAM_STR);
        $stmt->execute();

        $accessTokenList = [];
        foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
            // convert expires_in to int if it is not NULL
            $row['expires_in'] = null !== $row['expires_in'] ? (int) $row['expires_in'] : null;
            $accessTokenList[] = new AccessToken($row);
        }

        return $accessTokenList;
    }
501014
public static function fetchUserCapabilities(string $userId): array
    {
        $entities = [];

        if (array_key_exists($userId, static::$userCapabilities)) {
            return static::$userCapabilities[$userId];
        }

        $table = TableRegistry::get('RolesCapabilities.Capabilities');
        Assert::isInstanceOf($table, CapabilitiesTable::class);

        $userGroups = $table->getUserGroups($userId);
        if (empty($userGroups)) {
            return $entities;
        }

        $userRoles = $table->getGroupsRoles($userGroups);
        if (empty($userRoles)) {
            return $entities;
        }

        static::$userCapabilities[$userId] = $table->getUserRolesEntities($userRoles);

        return static::$userCapabilities[$userId];
    }
1238394
public static function getUser($user_id)
    {
        $sql = new Pluf_SQL('login=%s', array($user_id));
        return Pluf::factory('User')->getOne($sql->gen());
    }
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;
    }
181552
public static function get_children_of_user($userid) {
        global $DB;

        // Get users that the user has role assignments to.
        $allusernames = get_all_user_name_fields(true, 'u');
        $sql = "SELECT u.id, $allusernames
                  FROM {role_assignments} ra, {context} c, {user} u
                 WHERE ra.userid = :userid
                       AND ra.contextid = c.id
                       AND c.instanceid = u.id
                       AND c.contextlevel = :contextlevel";
        $params = [
            'userid' => $userid,
            'contextlevel' => CONTEXT_USER
        ];

        // The final list of users that we will return.
        $finalresults = [];

        // Our prospective list of users.
        if ($candidates = $DB->get_records_sql($sql, $params)) {
            foreach ($candidates as $key => $child) {
                $childcontext = \context_user::instance($child->id);
                if (has_capability('tool/dataprivacy:makedatarequestsforchildren', $childcontext, $userid)) {
                    $finalresults[$key] = $child;
                }
            }
        }
        return $finalresults;
    }
437438
static function fetchListForUser( $userID )
    {
        return eZPersistentObject::fetchObjectList( eZContentBrowseRecent::definition(),
                                                    null, array( 'user_id' => $userID ),
                                                    array( 'created' => 'desc' ), null, true );
    }
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);
        }
    }
452850
public function getUser($userId)
    {
        // Check if we've already retrieved this user.
        if (isset($this->userEntities[$userId])) {
            return $this->userEntities[$userId];
        }

        $query = $this->getUserQuery($userId);
        /** @var Entity\Users $userEntity */
        if ($userEntity = $this->findOneWith($query)) {
            $this->unsetSensitiveFields($userEntity);
        }

        // Remember the user
        $this->userEntities[$userId] = $userEntity;

        return $userEntity;
    }
1363714
public function getUser($userId, $groupId, $options=array()){

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

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

        return $this->request($this->userGetUrl, $data);
    }
461890
private function getUserNameById(int $userId): ?string
    {
        try {
            $user = $this->userService->loadUser($userId);

            return $user->getName();
        } catch (\Exception $e) {
            return $this->translator->trans(
                /** @Desc("another user") */
                'content_type.user_name.can_not_be_fetched',
                [],
                'content_type'
            );
        }
    }
832026
public function findByUserId($userId)
    {
        $select = $this->getSelect();
        $select->where(array('user_id' => $userId));

        return $this->select($select);
    }
1046220
public function getUserApplications($userId, $limit = null)
    {
        $qb = $this->createQueryBuilder(null)
            ->field('user')->equals($userId)
            ->sort(['date' => -1]);
    
        if (isset($limit)) {
            $qb->limit($limit);
        }
    
        return $qb->getQuery()->execute();
    }
413137
public function loadUser($userId)
    {
        $user = $this->userService->loadUser($userId, Language::ALL);

        $userContentInfo = $user->getVersionInfo()->getContentInfo();
        $contentType = $this->contentTypeService->loadContentType($userContentInfo->contentTypeId);

        try {
            $userMainLocation = $this->locationService->loadLocation($userContentInfo->mainLocationId);
            $relations = $this->contentService->loadRelations($user->getVersionInfo());
        } catch (UnauthorizedException $e) {
            // TODO: Hack for special case to allow current logged in user to load him/here self (but not relations)
            if ($user->id == $this->repository->getCurrentUser()->id) {
                $userMainLocation = $this->repository->sudo(
                    function () use ($userContentInfo) {
                        return $this->locationService->loadLocation($userContentInfo->mainLocationId);
                    }
                );
                // user may not have permissions to read related content, for security reasons do not use sudo().
                $relations = array();
            } else {
                throw $e;
            }
        }

        return new Values\CachedValue(
            new Values\RestUser(
                $user,
                $contentType,
                $userContentInfo,
                $userMainLocation,
                $relations
            ),
            array('locationId' => $userContentInfo->mainLocationId)
        );
    }
1111653
public function load($userId)
    {
        try {
            return $this->innerGateway->load($userId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
511607
static function fetchByUserId( $userId, $asObject = true )
    {
        return eZPersistentObject::fetchObject(
            self::definition(), null,
            array( 'user_id' => $userId ), $asObject
        );
    }