Get the user ID (which may be a compound of the tool consumer and resource link IDs).

@param int $idScope Scope to use for user ID (optional, default is null for consumer default setting)

@return string User ID value
433792
public function getId($idScope = null)
    {

        if (empty($idScope)) {
            if (!is_null($this->resourceLink)) {
                $idScope = $this->resourceLink->getConsumer()->idScope;
            } else {
                $idScope = ToolProvider::ID_SCOPE_ID_ONLY;
            }
        }
        switch ($idScope) {
            case ToolProvider::ID_SCOPE_GLOBAL:
                $id = $this->getResourceLink()->getKey() . ToolProvider::ID_SCOPE_SEPARATOR . $this->ltiUserId;
                break;
            case ToolProvider::ID_SCOPE_CONTEXT:
                $id = $this->getResourceLink()->getKey();
                if ($this->resourceLink->ltiContextId) {
                    $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->resourceLink->ltiContextId;
                }
                $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->ltiUserId;
                break;
            case ToolProvider::ID_SCOPE_RESOURCE:
                $id = $this->getResourceLink()->getKey();
                if ($this->resourceLink->ltiResourceLinkId) {
                    $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->resourceLink->ltiResourceLinkId;
                }
                $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->ltiUserId;
                break;
            default:
                $id = $this->ltiUserId;
                break;
        }

        return $id;

    }
230119
public function getByIdentifier($identifier)
    {
        switch (APP_NATIVE_LOGIN_USING) {

            case 'EMAIL':
                $user = $this->getByEmail($identifier);
                break;

            case 'USERNAME':
                $user = $this->getByUsername($identifier);
                break;

            default:
                Factory::helper('email');
                if (valid_email($identifier)) {
                    $user = $this->getByEmail($identifier);
                } else {
                    $user = $this->getByUsername($identifier);
                }
                break;
        }

        return $user;
    }
550424
public function getMostRecentVisitorId($idSite, $segment = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        // for faster performance search for a visitor within the last 7 days first
        $minTimestamp = Date::now()->subDay(7)->getTimestamp();

        $dataTable = $this->loadLastVisitsDetailsFromDatabase(
            $idSite, $period = false, $date = false, $segment, $offset = 0, $limit = 1, $minTimestamp
        );

        if (0 >= $dataTable->getRowsCount()) {
            $minTimestamp = Date::now()->subYear(1)->getTimestamp();
            // no visitor found in last 7 days, look further back for up to 1 year. This query will be slower
            $dataTable = $this->loadLastVisitsDetailsFromDatabase(
                $idSite, $period = false, $date = false, $segment, $offset = 0, $limit = 1, $minTimestamp
            );
        }

        if (0 >= $dataTable->getRowsCount()) {
            // no visitor found in last year, look over all logs. This query might be quite slow
            $dataTable = $this->loadLastVisitsDetailsFromDatabase(
                $idSite, $period = false, $date = false, $segment, $offset = 0, $limit = 1
            );
        }

        if (0 >= $dataTable->getRowsCount()) {
            return false;
        }

        $visitorFactory = new VisitorFactory();
        $visitDetails   = $dataTable->getFirstRow()->getColumns();
        $visitor        = $visitorFactory->create($visitDetails);

        return $visitor->getVisitorId();
    }
683964
public function scopeForUser(Builder $query, $userId)
    {
        $participantsTable = Models::table('participants');
        $threadsTable = Models::table('threads');

        return $query->join($participantsTable, $this->getQualifiedKeyName(), '=', $participantsTable . '.thread_id')
            ->where($participantsTable . '.user_id', $userId)
            ->where($participantsTable . '.deleted_at', null)
            ->select($threadsTable . '.*');
    }
1023542
public static function loggedId()
    {
        if (Podium::getInstance()->user->isGuest) {
            return null;
        }
        if (Podium::getInstance()->userComponent !== true) {
            $user = static::findMe();
            if (empty($user)) {
                return null;
            }
            return $user->id;
        }
        return Podium::getInstance()->user->id;
    }
178093
public static function get($identifier, $default = null)
    {
        $value = self::getInternal($identifier);

        if (is_null($value)) {
            return $default;
        }

        return $value;
    }
1033806
private function getScopeIdByScopeCode($scopeType, $scopeCode)
    {
        $scopeId = 0;

        $scopesByCode = $this->getScopesByCode($scopeType);

        if (isset($scopesByCode[$scopeCode])) {
            $scope = $scopesByCode[$scopeCode];
            $scopeId = $scope->getId();
        }

        return $scopeId;
    }
621244
public function getUser($id)
    {
        $response = $this->client->get($this->getResourceEndpoint() . '/' . (int)$id);

        return $response['Response'][0]['UserCompany'];
    }
367872
public function getUser($userIdentifier)
    {
        if ($this->apiVersionIsGreaterThanV3() && !is_numeric($userIdentifier)) {
            throw new InvalidIdentifierException('user');
        }

        return $this->get(sprintf('users/%s', $userIdentifier));
    }
1330137
public function getUserByProviderId($provider, $identifier)
    {
        $this->oDb->select('user_id');
        $this->oDb->where('provider', $provider);
        $this->oDb->where('identifier', $identifier);

        $oUser = $this->oDb->get(NAILS_DB_PREFIX . 'user_social')->row();

        if (empty($oUser)) {
            return false;
        }

        return $this->oUserModel->getById($oUser->user_id);
    }
958358
public static function getCurrentUser() {
    $email = UserServiceUtil::getUserEnvironmentVariable('USER_EMAIL');
    $userId = UserServiceUtil::getUserEnvironmentVariable('USER_ID');
    $federatedIdentity =
        UserServiceUtil::getUserEnvironmentVariable('FEDERATED_IDENTITY');
    $federatedProvider =
        UserServiceUtil::getUserEnvironmentVariable('FEDERATED_PROVIDER');

    if (!$email && !$federatedIdentity) {
      return null;
    }

    if (!$federatedIdentity) {
      $federatedIdentity = null;
    }

    if (!$federatedProvider) {
      $federatedProvider = null;
    }

    // We set this to maintain compatibility with the
    // datastore_types.FromPropertyPb creation of a User object, which will set
    // an empty string for the email (since it is a required field of the
    // underlying data representation of this class in the datastore.
    if ($email === false) {
      $email = '';
    }

    // User.user_id() should only return a
    // string of length > 0 or null.
    if (!$userId || $userId == '') {
      $userId = null;
    }

    return new User($email, $federatedIdentity, $federatedProvider, $userId);
  }
387571
public function retrieveByID($identifier)
	{
		$result = @ldap_read($this->conn, $identifier, '(objectclass=*)', $this->config['attributes']);
		if ($result === FALSE)
			return null;

		$entries = ldap_get_entries($this->conn, $result);
		if ($entries['count'] == 0 || $entries['count'] > 1)
			return null;

		return $this->clean($entries[0]);
	}
467357
public function getDomainByPageId($idPage)
	{
	    if (empty($idPage))
	        return null;
        
        // Retrieve cache version if front mode to avoid multiple calls
        $cacheKey = 'getDomainByPageId_' . $idPage;
        $cacheConfig = 'engine_page_services';
        $melisEngineCacheSystem = $this->serviceLocator->get('MelisEngineCacheSystem');
        $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig);
        if (!empty($results)) return $results;
	        
        $domainStr = '';
		$melisPage = $this->getServiceLocator()->get('MelisEnginePage');
		$datasPage = $melisPage->getDatasPage($idPage);
		$datasTemplate = $datasPage->getMelisTemplate();
		if (!empty($datasTemplate) && !empty($datasTemplate->tpl_site_id))
		{
			$melisEngineTableSite = $this->getServiceLocator()->get('MelisEngineTableSite');
			$datasSite = $melisEngineTableSite->getSiteById($datasTemplate->tpl_site_id, getenv('MELIS_PLATFORM'));
			if ($datasSite)
			{
				$datasSite = $datasSite->current();
				if (!empty($datasSite))
				{
					$scheme = 'http';
					if (!empty($datasSite->sdom_scheme))
						$scheme = $datasSite->sdom_scheme;
					
					$domain = $datasSite->sdom_domain;
					
					if ($domain != '')
						$domainStr = $scheme . '://' . $domain;
				}
			}
		}

		// Save cache key
		$melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $domainStr);
		
		return $domainStr;
	}
882667
protected function getUserId()
    {
        try {
            if (Auth::check()) {
                return Auth::user()->getAuthIdentifier();
            }
        } catch (Exception $e) {
            Log::emergency($e);
            return;
        }

        return;
    }
1308492
protected function getUserId()
    {
        if (Credentials::check()) {
            return Credentials::getUser()->id;
        } elseif (isset($this['user_id']) && $this['user_id']) {
            return $this['user_id'];
        }
    }
552300
public function get_default(): ?string
  {
    if (
      ($id_opt = $this->from_path('default')) &&
      ($all = $this->pref->get_all($id_opt))
    ){
      $id = false;
      foreach ( $all as $a ){
        if ( !empty($a['id_user']) ){
          $id = $a['id_alias'];
          break;
        }
        else if ( !empty($a['id_group']) ){
          $id = $a['id_alias'];
          break;
        }
        else if ( !empty($a['public']) ){
          $id = $a['id_alias'];
          break;
        }
      }
      return $id;
    }
	return null;
  }
526881
public function getUser($user)
    {
        $result = null;
        if ($user === 'current') {
            $u = new \User();
            if ($u->isRegistered()) {
                $result = $u;
            }
        } elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
            $result = \User::getByUserID($user);
        } elseif ($user instanceof UserService) {
            $result = $user;
        } elseif ($user instanceof UserEntity) {
            $result = \User::getByUserID($user->getUserID());
        }

        return $result;
    }