You are here

public function OAuthStoreOracle::getServer in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getServer()
  2. 7.2 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getServer()
  3. 7.3 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getServer()
  4. 7.4 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getServer()
  5. 7.6 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::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/OAuthStoreOracle.php, line 391

Class

OAuthStoreOracle

Code

public function getServer($consumer_key, $user_id, $user_is_admin = false) {

  //
  $sql = "BEGIN SP_GET_SERVER(:P_CONSUMER_KEY, :P_USER_ID, :P_ROWS, :P_RESULT); END;";

  // parse sql
  $stmt = oci_parse($this->conn, $sql) or die('Can not parse query');

  // Bind In and Out Variables
  oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $consumer_key, 255);
  oci_bind_by_name($stmt, ':P_USER_ID', $user_id, 40);
  oci_bind_by_name($stmt, ':P_RESULT', $result, 20);

  //Bind the ref cursor
  $p_row = oci_new_cursor($this->conn);
  oci_bind_by_name($stmt, ':P_ROWS', $p_row, -1, OCI_B_CURSOR);

  //Execute the statement
  oci_execute($stmt);

  // treat the ref cursor as a statement resource
  oci_execute($p_row, OCI_DEFAULT);
  oci_fetch_all($p_row, $getServerList, null, null, OCI_FETCHSTATEMENT_BY_ROW);
  $r = $getServerList;

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