public function OAuthStoreOracle::updateServer in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::updateServer()
- 7.2 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::updateServer()
- 7.3 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::updateServer()
- 7.5 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::updateServer()
- 7.6 lib/oauth-php/library/store/OAuthStoreOracle.php \OAuthStoreOracle::updateServer()
* Register or update a server for our site (we will be the consumer) * * (This is the registry at the consumers, registering servers ;-) ) * *
Parameters
array server: * @param int user_id user registering this server * @param boolean user_is_admin * @exception OAuthException2 when fields are missing or on duplicate consumer_key * @return consumer_key
Overrides OAuthStoreAbstract::updateServer
File
- lib/
oauth-php/ library/ store/ OAuthStoreOracle.php, line 718
Class
Code
public function updateServer($server, $user_id, $user_is_admin = false) {
foreach (array(
'consumer_key',
'server_uri',
) as $f) {
if (empty($server[$f])) {
throw new OAuthException2('The field "' . $f . '" must be set and non empty');
}
}
$parts = parse_url($server['server_uri']);
$host = isset($parts['host']) ? $parts['host'] : 'localhost';
$path = isset($parts['path']) ? $parts['path'] : '/';
if (isset($server['signature_methods'])) {
if (is_array($server['signature_methods'])) {
$server['signature_methods'] = strtoupper(implode(',', $server['signature_methods']));
}
}
else {
$server['signature_methods'] = '';
}
// When the user is an admin, then the user can update the user_id of this record
if ($user_is_admin && array_key_exists('user_id', $server)) {
$flag = 1;
}
if ($flag) {
if (is_null($server['user_id'])) {
$ocr_usa_id_ref = NULL;
}
else {
$ocr_usa_id_ref = $server['user_id'];
}
}
else {
$flag = 0;
$ocr_usa_id_ref = $user_id;
}
//sp
$sql = "BEGIN SP_UPDATE_SERVER(:P_CONSUMER_KEY, :P_USER_ID, :P_OCR_ID, :P_USER_IS_ADMIN,\n :P_OCR_CONSUMER_SECRET, :P_OCR_SERVER_URI, :P_OCR_SERVER_URI_HOST, :P_OCR_SERVER_URI_PATH,\n :P_OCR_REQUEST_TOKEN_URI, :P_OCR_AUTHORIZE_URI, :P_OCR_ACCESS_TOKEN_URI, :P_OCR_SIGNATURE_METHODS,\n :P_OCR_USA_ID_REF, :P_UPDATE_P_OCR_USA_ID_REF_FLAG, :P_RESULT); END;";
// parse sql
$stmt = oci_parse($this->conn, $sql) or die('Can not parse query');
$server['request_token_uri'] = isset($server['request_token_uri']) ? $server['request_token_uri'] : '';
$server['authorize_uri'] = isset($server['authorize_uri']) ? $server['authorize_uri'] : '';
$server['access_token_uri'] = isset($server['access_token_uri']) ? $server['access_token_uri'] : '';
// Bind In and Out Variables
oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $server['consumer_key'], 255);
oci_bind_by_name($stmt, ':P_USER_ID', $user_id, 40);
oci_bind_by_name($stmt, ':P_OCR_ID', $server['id'], 40);
oci_bind_by_name($stmt, ':P_USER_IS_ADMIN', $user_is_admin, 40);
oci_bind_by_name($stmt, ':P_OCR_CONSUMER_SECRET', $server['consumer_secret'], 255);
oci_bind_by_name($stmt, ':P_OCR_SERVER_URI', $server['server_uri'], 255);
oci_bind_by_name($stmt, ':P_OCR_SERVER_URI_HOST', strtolower($host), 255);
oci_bind_by_name($stmt, ':P_OCR_SERVER_URI_PATH', $path, 255);
oci_bind_by_name($stmt, ':P_OCR_REQUEST_TOKEN_URI', $server['request_token_uri'], 255);
oci_bind_by_name($stmt, ':P_OCR_AUTHORIZE_URI', $server['authorize_uri'], 255);
oci_bind_by_name($stmt, ':P_OCR_ACCESS_TOKEN_URI', $server['access_token_uri'], 255);
oci_bind_by_name($stmt, ':P_OCR_SIGNATURE_METHODS', $server['signature_methods'], 255);
oci_bind_by_name($stmt, ':P_OCR_USA_ID_REF', $ocr_usa_id_ref, 40);
oci_bind_by_name($stmt, ':P_UPDATE_P_OCR_USA_ID_REF_FLAG', $flag, 40);
oci_bind_by_name($stmt, ':P_RESULT', $result, 20);
//Execute the statement
oci_execute($stmt);
return $server['consumer_key'];
}