You are here

public function OAuthStoreSQL::getServer in Lingotek Translation 7.6

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

* Get a server from the consumer registry using the consumer key * *

Parameters

string consumer_key: * @param int user_id * @param boolean user_is_admin (optional) * @exception OAuthException2 when server is not found * @return array

Overrides OAuthStoreAbstract::getServer

File

lib/oauth-php/library/store/OAuthStoreSQL.php, line 434

Class

OAuthStoreSQL

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