You are here

public function OAuthStorePostgreSQL::getServer in Lingotek Translation 7.5

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

Get a server from the consumer registry using the consumer key

@exception OAuthException2 when server is not found

Parameters

string consumer_key:

int user_id:

boolean user_is_admin (optional):

Return value

array

Overrides OAuthStoreAbstract::getServer

File

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

Class

OAuthStorePostgreSQL

Code

public function getServer($consumer_key, $user_id, $user_is_admin = false) {
  $r = $this
    ->query_row_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_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 ocr_consumer_key = \'%s\'
                  AND (ocr_usa_id_ref = \'%d\' OR ocr_usa_id_ref IS NULL)
                ', $consumer_key, $user_id);
  if (empty($r)) {
    throw new OAuthException2('No server with consumer_key "' . $consumer_key . '" has been registered (for this user)');
  }
  if (isset($r['signature_methods']) && !empty($r['signature_methods'])) {
    $r['signature_methods'] = explode(',', $r['signature_methods']);
  }
  else {
    $r['signature_methods'] = array();
  }
  return $r;
}