Fetch a consumer of this server, by consumer_key.

@param string consumer_key
@param int user_id
@param boolean user_is_admin (optional)
@exception OAuthException2 when consumer not found
@return array
966468
public function getConsumer ( $consumer_key, $user_id, $user_is_admin = false )
    {
        $consumer = $this->query_row_assoc('
                        SELECT    *
                        FROM oauth_server_registry
                        WHERE osr_consumer_key = \'%s\'
                        ', $consumer_key);

        if (!is_array($consumer))
        {
            throw new OAuthException2('No consumer with consumer_key "'.$consumer_key.'"');
        }

        $c = array();
        foreach ($consumer as $key => $value)
        {
            $c[substr($key, 4)] = $value;
        }
        $c['user_id'] = $c['usa_id_ref'];

        if (!$user_is_admin && !empty($c['user_id']) && $c['user_id'] != $user_id)
        {
            throw new OAuthException2('No access to the consumer information for consumer_key "'.$consumer_key.'"');
        }
        return $c;
    }
89907
public function grantSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data, $user_save = FALSE, $reset = FALSE) {

    $role_name_lcase = $consumer_id;
    $role_name = empty($consumer['value']) ? $consumer_id : $consumer['value'];
    $rid = $this->getDrupalRoleIdFromRoleName($role_name);
    if (is_null($rid)) {
      watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.grantSingleAuthorization()
      failed to grant %username the role %role_name because role does not exist',
      array('%role_name' => $role_name, '%username' => $user->name),
      WATCHDOG_ERROR);
      return FALSE;
    }

    $user->roles[$rid] = $role_name;
    $user_edit = array('roles' => $user->roles);
    if ($this->detailedWatchdogLog) {
      watchdog('ldap_authorization', 'grantSingleAuthorization in drupal rold' . print_r($user, TRUE), array(), WATCHDOG_DEBUG);
    }

    $account = user_load($user->uid);
    $user = user_save($account, $user_edit);
    $result = ($user && !empty($user->roles[$rid]));

    if ($this->detailedWatchdogLog) {
      watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.grantSingleAuthorization()
        granted: rid=%rid, role_name=%role_name for username=%username, result=%result',
        array('%rid' => $rid, '%role_name' => $role_name, '%username' => $user->name,
          '%result' => $result), WATCHDOG_DEBUG);
    }

    return $result;

  }
127513
public function get( $key, $user_id = null, $single = true, $default = '' ) {
		if ( ! isset( $user_id ) ) {
			$user_id = $this->user_id;
		}
		if ( $user_id <= 0 ) {
			return $this->apply_filters( 'get_user_meta', $default, $key, $user_id, $single, $default );
		}

		return $this->apply_filters( 'get_user_meta', get_user_meta( $user_id, $this->get_meta_key( $key ), $single ), $key, $user_id, $single, $default, $this->get_user_prefix() );
	}
1310093
public function userGet(int $user_id)
    {
        $value = get_user_meta($user_id, $this->getName(), ! $this->getOption('multiple', false));

        if (! empty($value)) {
            $this->setValue($value);
        }
    }
551980
public function listServers ( $q = '', $user_id )
	{
		$q    = trim(str_replace('%', '', $q));
		$args = array();

		if (!empty($q))
		{
			$where = ' WHERE (	ocr_consumer_key like \'%%%s%%\'
						  	 OR ocr_server_uri like \'%%%s%%\'
						  	 OR ocr_server_uri_host like \'%%%s%%\'
						  	 OR ocr_server_uri_path like \'%%%s%%\')
						 AND (ocr_usa_id_ref = %d OR ocr_usa_id_ref IS NULL)
					';
			
			$args[] = $q;
			$args[] = $q;
			$args[] = $q;
			$args[] = $q;
			$args[] = $user_id;
		}
		else
		{
			$where  = ' WHERE ocr_usa_id_ref = %d OR ocr_usa_id_ref IS NULL';
			$args[] = $user_id;
		}

		$servers = $this->query_all_assoc('
					SELECT	ocr_id					as id,
							ocr_usa_id_ref			as user_id,
							ocr_consumer_key 		as consumer_key,
							ocr_consumer_secret 	as consumer_secret,
							ocr_signature_methods	as signature_methods,
							ocr_server_uri			as server_uri,
							ocr_server_uri_host		as server_uri_host,
							ocr_server_uri_path		as server_uri_path,
							ocr_request_token_uri	as request_token_uri,
							ocr_authorize_uri		as authorize_uri,
							ocr_access_token_uri	as access_token_uri
					FROM oauth_consumer_registry
					'.$where.'
					ORDER BY ocr_server_uri_host, ocr_server_uri_path
					', $args);
		return $servers;
	}
520743
public function getUser($user_name)
    {
        $url          = $this->url.'users/'.$user_name;
        $option       = [];
        $access_token = $this->getToken();
        $header []    = 'Authorization: Bearer '.$access_token;

        return Http::postCurl($url, $option, $header, 'GET');
    }
1314119
private function get_token(&$request, $consumer, $token_type="access") {
    $token_field = @$request->get_parameter('oauth_token');
    if ( !$token_field) return false;
    $token = $this->data_store->lookup_token(
      $consumer, $token_type, $token_field
    );
    if (!$token) {
      throw new OAuthException("Invalid $token_type token: $token_field");
    }
    return $token;
  }
847815
static function fetchListForUser( $userID, $offset = false, $limit = false )
    {
        $objectList = eZPersistentObject::fetchObjectList( eZContentBrowseBookmark::definition(),
                                                            null,
                                                            array( 'user_id' => $userID ),
                                                            array( 'id' => 'desc' ),
                                                            array( 'offset' => $offset, 'length' => $limit ),
                                                            true );
        return $objectList;
    }
461651
public function getUserCount( $userId, $consumed = false, $admin = false ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$siteId = Yii::$app->core->siteId;

		$conditions = [ "$modelTable.consumed" => $consumed, 'siteId' => $siteId ];

		if( $admin ) {

			$conditions[ "$modelTable.admin" ] = $admin;
		}
		else {

			$conditions[ "$modelTable.type" ] = CoreGlobal::TYPE_USER;
		}

		return $modelClass::queryByUserId( $userId )
			->andWhere( $conditions )
			->count();
	}
901428
public function deleteConsumer ( $consumer_key, $user_id, $user_is_admin = false )
	{
		
                //
                $sql = "BEGIN SP_DELETE_CONSUMER(:P_CONSUMER_KEY, :P_USER_ID, :P_USER_IS_ADMIN, :P_RESULT); END;";

                // parse sql
                $stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');

                // Bind In and Out Variables
                oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $consumer_key, 255);
                oci_bind_by_name($stmt, ':P_USER_ID', $user_id, 40);
                oci_bind_by_name($stmt, ':P_USER_IS_ADMIN', $user_is_admin, 40);
                oci_bind_by_name($stmt, ':P_RESULT', $result, 20);               

                //Execute the statement
                oci_execute($stmt);
                //
        }
678105
public function findOauthConsumerResource($consumer_key)
	{
		$returnValue = null;

		$class = $this->getClass(self::CLASS_URI_OAUTH_CONSUMER);
		$instances = $class->searchInstances(array(self::PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
		if (count($instances) == 0) {
			throw new \tao_models_classes_oauth_Exception('No Credentials for consumer key '.$consumer_key);
		}
		if (count($instances) > 1) {
			throw new \tao_models_classes_oauth_Exception('Multiple Credentials for consumer key '.$consumer_key);
		}
		$returnValue	= current($instances);

		return $returnValue;
	}
43021
def get_client(self, request=None):
        """"""

        if not isinstance(request, oauth.Request):
            request = self.get_oauth_request()
        client_key = request.get_parameter('oauth_consumer_key')
        if not client_key:
            raise Exception('Missing "oauth_consumer_key" parameter in ' \
                'OAuth "Authorization" header')

        client = models.Client.get_by_key_name(client_key)
        if not client:
            raise Exception('Client "%s" not found.' % client_key)

        return client
1348743
public function getConsumerAccessToken ( $token, $user_id )
    {
        $rs = $this->query_row_assoc('
                SELECT    ost_token                as token,
                        ost_token_secret        as token_secret,
                        ost_referrer_host        as token_referrer_host,
                        osr_consumer_key        as consumer_key,
                        osr_consumer_secret        as consumer_secret,
                        osr_application_uri        as application_uri,
                        osr_application_title    as application_title,
                        osr_application_descr    as application_descr,
                        osr_callback_uri        as callback_uri
                FROM oauth_server_token
                        JOIN oauth_server_registry
                        ON ost_osr_id_ref = osr_id
                WHERE ost_token_type = \'access\'
                  AND ost_token      = \'%s\'
                  AND ost_usa_id_ref = \'%d\'
                  AND ost_token_ttl  >= NOW()
                ', $token, $user_id);

        if (empty($rs))
        {
            throw new OAuthException2('No server_token "'.$token.'" for user "'.$user_id.'"');
        }
        return $rs;
    }
1112656
public function authorizeConsumerRequestToken ( $token, $user_id, $referrer_host = '' )
	{
 		// 1.0a Compatibility : create a token verifier
 		$verifier = substr(md5(rand()),0,10);
		
		$sql = "BEGIN SP_AUTH_CONSUMER_REQ_TOKEN(:P_USER_ID, :P_REFERRER_HOST, :P_VERIFIER, :P_TOKEN, :P_RESULT); END;";

			// parse sql
		$stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');

		// Bind In and Out Variables
		oci_bind_by_name($stmt, ':P_USER_ID', $user_id, 255);
		oci_bind_by_name($stmt, ':P_REFERRER_HOST', $referrer_host, 255);
		oci_bind_by_name($stmt, ':P_VERIFIER', $verifier, 255);
		oci_bind_by_name($stmt, ':P_TOKEN', $token, 255);
		oci_bind_by_name($stmt, ':P_RESULT', $result, 20);


		//Execute the statement
		oci_execute($stmt);

		return $verifier;
	}
548515
public function member($group_id, $user = null)
	{
		// if it's not a group id, fetch it from the object
		if ( ! is_numeric($group_id))
		{
			$group_id = $group_id->id;
		}

		// do we know this group?
		if (isset(static::$_valid_groups[$group_id]))
		{
			// if no user is given
			if ($user === null)
			{
				// get the groups of the logged-in user
				$groups = \Auth::instance()->get_groups();
			}
			else
			{
				// get the groups if the given user instance
				$groups = \Auth::instance($user[0])->get_groups();
			}

			// if no group info could be retrieved, the user can't be a member
			if ( ! $groups)
			{
				return false;
			}

			// check for membership
			foreach($groups as $group)
			{
				if ($group[0] === $this->id and $group_id === (int) $group[1]->id)
				{
					return true;
				}
			}
		}

		return false;
	}
1049369
public static function collectByUser($user_id)
    {
        $user = AclUser::find($user_id);
        if ($user === null) {
            return collect([]);
        }

        return (new static)->where('group_id', $user->acl_group_id)->get();
    }
247442
public function getTokenAndUser()
    {
        $adapter = $this->getAdapter();

        $isOAuth2 = $this->version === self::OAUTH_VERSION_2;
        $token = $adapter->getAccessToken($this->provider);
        $user = $this->provider->getUser($token);

        return [
            'adapterKey' => $this->provider->getProviderName(),
            'token' => $token->getTokenValue(),
            'version' => $token->getTokenVersion(),
            'scope' => $isOAuth2 ? $token->getScope() : null,
            'refreshToken' => $isOAuth2 ? $token->getRefreshToken() : null,
            'expireTime' => $isOAuth2 ? gmdate('Y-m-d H:i:s', $token->getExpireTimestamp()) : null,
            'remoteUserId' => $user->getId(),
            'remoteUserName' => $user->getName(),
            'remoteEmail' => $user->getEmail(),
            'remoteImageUrl' => $user->getAvatar(),
            'remoteExtra' => json_encode($user->getExtra()),
        ];
    }