Converts a User ID string to the Visitor ID Binary representation.

@param $userId
@return string
501283
public static function convertUserIdToVisitorIdBin($userId)
    {
        require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';
        $userIdHashed = \PiwikTracker::getUserIdHashed($userId);

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

        return;
    }
832026
public function findByUserId($userId)
    {
        $select = $this->getSelect();
        $select->where(array('user_id' => $userId));

        return $this->select($select);
    }
1127564
public function getGoogleServiceGmailForUserId(string $userId)
    {
        $email = $this->directory->resolvePrimaryEmailFromUserId($userId);
        if (array_key_exists($email, $this->googleServiceGmails)) {
            return $this->googleServiceGmails[$email];
        }

        $googleServiceGmail = new \Google_Service_Gmail($this->serviceAccount->getGoogleClientForEmail($email));
        $this->googleServiceGmails[$email] = $googleServiceGmail;

        return $googleServiceGmail;
    }
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;
    }
834056
public function getUser($userId)
    {
        // Make sure users have been 'got' already.
        $this->getUsers();

        // In most cases by far, we'll request an ID, and we can return it here.
        if ($userId && array_key_exists($userId, $this->users)) {
            return $this->users[$userId];
        }

        // Fallback: See if we can get it by username or email address.
        try {
            if ($userEntity = $this->getRepository()->getUser($userId)) {
                return $userEntity->toArray();
            }
        } catch (TableNotFoundException $e) {
            return false;
        }

        return false;
    }
1273992
public function getAvatarHome($userId)
    {
        $id = sprintf("%09d", $userId);
        $dir1 = substr($id, 0, 3);
        $dir2 = substr($id, 3, 2);
        $dir3 = substr($id, 5, 2);
        return $dir1 . '/' . $dir2 . '/' . $dir3 . '/';
    }
989152
public static function getCredential($userId)
    {
        $model = new User_Credential();
        $where = 'account_id = ' . $model->_toDb($userId, 'account_id');
        $creds = $model->getList(array(
            'filter' => $where
        ));
        if ($creds === false or count($creds) !== 1) {
            return false;
        }
        return $creds[0];
    }
1007654
public static function getAvatarPath($userId)
    {
        $id = sprintf("%09d", $userId);
        $dir1 = substr($id, 0, 3);
        $dir2 = substr($id, 3, 2);
        $dir3 = substr($id, 5, 2);
        return 'avatar' . '/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($userId, -2);
    }
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);
        }
    }
284831
protected function pkey(string $key, $userId): string
    {
        return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key);
    }
1018441
protected function getUser($userId)
    {
        $user = $this->users->read($userId);

        if (isset($user)) {
            $user['roles'] = $this->getRoles($userId);
        }

        return $user;
    }
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)
        );
    }
548188
public function addUser($userId)
    {
        if (true === is_numeric($userId) && false === in_array($userId, $this->users)) {
            $this->users[] = (int)$userId;
        }
        return $this;
    }
415937
private function _checkUserId($userId = null)
    {
        if (empty($userId) && $this->currentUser instanceof \Gems_User_User) {
            $userId = $this->currentUser->getUserId();
            if (0 === $userId) {
                $userId = null;
            }
        }
        return $userId;
    }
1112291
public function toOpenId($userId, $agentId)
    {
        $params = array(
                'userid' => $userId,
                'agentid' => $agentId,
            );

        return $this->http->jsonPost(self::API_TO_OPENID, $params);
    }
1085049
public static function anonymizeUserId($userId)
    {
        $trackerCache = Tracker\Cache::getCacheGeneral();
        $salt = '';
        if (!empty($trackerCache[PrivacyManager::OPTION_USERID_SALT])) {
            $salt = $trackerCache[PrivacyManager::OPTION_USERID_SALT];
        }
        if(empty($salt)) {
            return $userId;
        }
        return sha1($userId . $salt);
    }