public function OAuthStoreOracle::getConsumer in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getConsumer()
- 7.2 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getConsumer()
- 7.3 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getConsumer()
- 7.4 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getConsumer()
- 7.6 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::getConsumer()
* Fetch a consumer of this server, by consumer_key. * *
Parameters
string consumer_key: * @param int user_id * @param boolean user_is_admin (optional) * @exception OAuthException2 when consumer not found * @return array
Overrides OAuthStoreAbstract::getConsumer
File
- lib/
oauth-php/ library/ store/ OAuthStoreOracle.php, line 880
Class
Code
public function getConsumer($consumer_key, $user_id, $user_is_admin = false) {
$sql = "BEGIN SP_GET_CONSUMER(:P_CONSUMER_KEY, :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_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, $getConsumerList, null, null, OCI_FETCHSTATEMENT_BY_ROW);
$consumer = $getConsumerList;
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;
}