You are here

public function OAuthStorePostgreSQL::getConsumer in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::getConsumer()
  2. 7.2 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::getConsumer()
  3. 7.4 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::getConsumer()
  4. 7.5 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::getConsumer()
  5. 7.6 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::getConsumer()

Fetch a consumer of this server, by consumer_key.

@exception OAuthException2 when consumer not found

Parameters

string consumer_key:

int user_id:

boolean user_is_admin (optional):

Return value

array

Overrides OAuthStoreAbstract::getConsumer

File

lib/oauth-php/library/store/OAuthStorePostgreSQL.php, line 1119

Class

OAuthStorePostgreSQL

Code

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;
}