You are here

public static function DrupalOAuthConsumer::loadProviderByKey in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 includes/DrupalOAuthConsumer.inc \DrupalOAuthConsumer::loadProviderByKey()
  2. 7.3 includes/DrupalOAuthConsumer.inc \DrupalOAuthConsumer::loadProviderByKey()

Gets a provider consumer with the specified key

Parameters

string $key: The key of the consumer to get

boolean $provider: Used internally for backwards compatibility with ::load()

Return value

DrupalOAuthConsumer The loaded consumer object or FALSE if load failed

4 calls to DrupalOAuthConsumer::loadProviderByKey()
DrupalOAuthConsumer::load in includes/DrupalOAuthConsumer.inc
Deprecated - Gets the consumer with the specified key
DrupalOAuthDataStore::lookup_consumer in includes/DrupalOAuthDataStore.inc
Check if consumer exists from a given consumer key.
oauth_common_context_from_request in ./oauth_common.module
Loads the context for a request.
oauth_common_verify_request in ./oauth_common.inc
Verifies the request

File

includes/DrupalOAuthConsumer.inc, line 181

Class

DrupalOAuthConsumer

Code

public static function loadProviderByKey($key, $provider = TRUE) {

  // Only INNER supported - LEFT is only for backwards compatability with deprecated DrupalOAuthConsumer::load() from 6.x-3.0-beta3
  $join = $provider ? 'INNER' : 'LEFT';

  // For backwards compatibility with deprecated DrupalOAuthConsumer::load() from 6.x-3.0-beta3
  $where = $provider ? '' : ' AND pc.csid IS NULL';

  // For backwards compatibility with deprecated DrupalOAuthConsumer::load() from 6.x-3.0-beta3
  $fields = $provider ? 'pc.*, c.secret, c.configuration' : 'c.csid, c.consumer_key, c.secret, c.configuration, pc.created, pc.changed, pc.uid, pc.name, pc.context, pc.callback_url';
  $query = "SELECT " . $fields . " FROM {oauth_common_consumer} c " . $join . " JOIN {oauth_common_provider_consumer} pc ON pc.csid = c.csid WHERE c.key_hash = '%s'" . $where;
  return self::fromResult(db_query($query, array(
    ':key_hash' => sha1($key),
  )));
}