You are here

public static function DrupalOAuthConsumer::loadById in OAuth 1.0 7.3

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

Gets a provider consumer with the specified id

Parameters

int $id: The id of the consumer to get

boolean $load_provider_data: Whether to load provider related data or not

Return value

DrupalOAuthConsumer The loaded consumer object or FALSE if load failed

4 calls to DrupalOAuthConsumer::loadById()
DrupalOAuthToken::fromResult in includes/DrupalOAuthToken.inc
Constructs a token from a db-result resource
DrupalOAuthToken::__construct in includes/DrupalOAuthToken.inc
key = the token secret = the token secret
oauth_common_consumer_load in ./oauth_common.module
Menu system wildcard loader for provider consumers.
oauth_common_page_authorized in ./oauth_common.pages.inc
Menu callback for when something has been authorized - used in both client and provider flow

File

includes/DrupalOAuthConsumer.inc, line 161

Class

DrupalOAuthConsumer

Code

public static function loadById($csid, $load_provider_data = TRUE) {
  $query = db_select('oauth_common_consumer', 'c');
  if (is_numeric($csid)) {
    $query
      ->condition('c.csid', $csid)
      ->fields('c', array(
      'csid',
      'consumer_key',
      'secret',
      'configuration',
    ));
    if ($load_provider_data) {
      $query
        ->leftJoin('oauth_common_provider_consumer', 'pc', 'pc.csid = c.csid');
      $query
        ->fields('pc', array(
        'created',
        'changed',
        'uid',
        'name',
        'context',
        'callback_url',
      ));
    }
    return self::fromResult($query
      ->execute());
  }
  else {
    return FALSE;
  }
}