class OAuthStoreAnymeta in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStoreAnyMeta.php \OAuthStoreAnymeta
- 7.2 lib/oauth-php/library/store/OAuthStoreAnyMeta.php \OAuthStoreAnymeta
- 7.3 lib/oauth-php/library/store/OAuthStoreAnyMeta.php \OAuthStoreAnymeta
- 7.4 lib/oauth-php/library/store/OAuthStoreAnyMeta.php \OAuthStoreAnymeta
- 7.6 lib/oauth-php/library/store/OAuthStoreAnyMeta.php \OAuthStoreAnymeta
Hierarchy
- class \OAuthStoreAbstract
- class \OAuthStoreSQL
- class \OAuthStoreMySQL
- class \OAuthStoreAnymeta
- class \OAuthStoreMySQL
- class \OAuthStoreSQL
Expanded class hierarchy of OAuthStoreAnymeta
File
- lib/
oauth-php/ library/ store/ OAuthStoreAnyMeta.php, line 38
View source
class OAuthStoreAnymeta extends OAuthStoreMySQL {
/**
* Construct the OAuthStoreAnymeta
*
* @param array options
*/
function __construct($options = array()) {
parent::__construct(array(
'conn' => any_db_conn(),
));
}
/**
* Add an entry to the log table
*
* @param array keys (osr_consumer_key, ost_token, ocr_consumer_key, oct_token)
* @param string received
* @param string sent
* @param string base_string
* @param string notes
* @param int (optional) user_id
*/
public function addLog($keys, $received, $sent, $base_string, $notes, $user_id = null) {
if (is_null($user_id) && isset($GLOBALS['any_auth'])) {
$user_id = $GLOBALS['any_auth']
->getUserId();
}
parent::addLog($keys, $received, $sent, $base_string, $notes, $user_id);
}
/**
* Get a page of entries from the log. Returns the last 100 records
* matching the options given.
*
* @param array options
* @param int user_id current user
* @return array log records
*/
public function listLog($options, $user_id) {
$where = array();
$args = array();
if (empty($options)) {
$where[] = 'olg_usa_id_ref = %d';
$args[] = $user_id;
}
else {
foreach ($options as $option => $value) {
if (strlen($value) > 0) {
switch ($option) {
case 'osr_consumer_key':
case 'ocr_consumer_key':
case 'ost_token':
case 'oct_token':
$where[] = 'olg_' . $option . ' = \'%s\'';
$args[] = $value;
break;
}
}
}
$where[] = '(olg_usa_id_ref IS NULL OR olg_usa_id_ref = %d)';
$args[] = $user_id;
}
$rs = any_db_query_all_assoc('
SELECT olg_id,
olg_osr_consumer_key AS osr_consumer_key,
olg_ost_token AS ost_token,
olg_ocr_consumer_key AS ocr_consumer_key,
olg_oct_token AS oct_token,
olg_usa_id_ref AS user_id,
olg_received AS received,
olg_sent AS sent,
olg_base_string AS base_string,
olg_notes AS notes,
olg_timestamp AS timestamp,
INET_NTOA(olg_remote_ip) AS remote_ip
FROM oauth_log
WHERE ' . implode(' AND ', $where) . '
ORDER BY olg_id DESC
LIMIT 0,100', $args);
return $rs;
}
/**
* Initialise the database
*/
public function install() {
parent::install();
any_db_query("ALTER TABLE oauth_consumer_registry MODIFY ocr_usa_id_ref int(11) unsigned");
any_db_query("ALTER TABLE oauth_consumer_token MODIFY oct_usa_id_ref int(11) unsigned not null");
any_db_query("ALTER TABLE oauth_server_registry MODIFY osr_usa_id_ref int(11) unsigned");
any_db_query("ALTER TABLE oauth_server_token MODIFY ost_usa_id_ref int(11) unsigned not null");
any_db_query("ALTER TABLE oauth_log MODIFY olg_usa_id_ref int(11) unsigned");
any_db_alter_add_fk('oauth_consumer_registry', 'ocr_usa_id_ref', 'any_user_auth(usa_id_ref)', 'on update cascade on delete set null');
any_db_alter_add_fk('oauth_consumer_token', 'oct_usa_id_ref', 'any_user_auth(usa_id_ref)', 'on update cascade on delete cascade');
any_db_alter_add_fk('oauth_server_registry', 'osr_usa_id_ref', 'any_user_auth(usa_id_ref)', 'on update cascade on delete set null');
any_db_alter_add_fk('oauth_server_token', 'ost_usa_id_ref', 'any_user_auth(usa_id_ref)', 'on update cascade on delete cascade');
any_db_alter_add_fk('oauth_log', 'olg_usa_id_ref', 'any_user_auth(usa_id_ref)', 'on update cascade on delete cascade');
}
/** Some simple helper functions for querying the mysql db **/
/**
* Perform a query, ignore the results
*
* @param string sql
* @param vararg arguments (for sprintf)
*/
protected function query($sql) {
list($sql, $args) = $this
->sql_args(func_get_args());
any_db_query($sql, $args);
}
/**
* Perform a query, ignore the results
*
* @param string sql
* @param vararg arguments (for sprintf)
* @return array
*/
protected function query_all_assoc($sql) {
list($sql, $args) = $this
->sql_args(func_get_args());
return any_db_query_all_assoc($sql, $args);
}
/**
* Perform a query, return the first row
*
* @param string sql
* @param vararg arguments (for sprintf)
* @return array
*/
protected function query_row_assoc($sql) {
list($sql, $args) = $this
->sql_args(func_get_args());
return any_db_query_row_assoc($sql, $args);
}
/**
* Perform a query, return the first row
*
* @param string sql
* @param vararg arguments (for sprintf)
* @return array
*/
protected function query_row($sql) {
list($sql, $args) = $this
->sql_args(func_get_args());
return any_db_query_row($sql, $args);
}
/**
* Perform a query, return the first column of the first row
*
* @param string sql
* @param vararg arguments (for sprintf)
* @return mixed
*/
protected function query_one($sql) {
list($sql, $args) = $this
->sql_args(func_get_args());
return any_db_query_one($sql, $args);
}
/**
* Return the number of rows affected in the last query
*
* @return int
*/
protected function query_affected_rows() {
return any_db_affected_rows();
}
/**
* Return the id of the last inserted row
*
* @return int
*/
protected function query_insert_id() {
return any_db_insert_id();
}
private function sql_args($args) {
$sql = array_shift($args);
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
return array(
$sql,
$args,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OAuthStoreAbstract:: |
public | function | * Generate a unique key * * | |
OAuthStoreAbstract:: |
protected | function | * Check to see if a string is valid utf8 * * | |
OAuthStoreAbstract:: |
protected | function | * Make a string utf8, replacing all non-utf8 chars with a '.' * * | |
OAuthStoreAnymeta:: |
public | function |
* Add an entry to the log table
*
* Overrides OAuthStoreSQL:: |
|
OAuthStoreAnymeta:: |
public | function |
* Initialise the database Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
public | function |
* Get a page of entries from the log. Returns the last 100 records
* matching the options given.
*
* Overrides OAuthStoreSQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Perform a query, ignore the results
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Return the number of rows affected in the last query
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Perform a query, ignore the results
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Return the id of the last inserted row
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Perform a query, return the first column of the first row
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Perform a query, return the first row
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
protected | function |
* Perform a query, return the first row
*
* Overrides OAuthStoreMySQL:: |
|
OAuthStoreAnymeta:: |
private | function | ||
OAuthStoreAnymeta:: |
function |
* Construct the OAuthStoreAnymeta
*
* Overrides OAuthStoreSQL:: |
||
OAuthStoreMySQL:: |
protected | property | * The MySQL connection | |
OAuthStoreMySQL:: |
protected | function |
Overrides OAuthStoreSQL:: |
1 |
OAuthStoreMySQL:: |
protected | function |
Overrides OAuthStoreSQL:: |
1 |
OAuthStoreMySQL:: |
protected | function |
Overrides OAuthStoreSQL:: |
1 |
OAuthStoreSQL:: |
protected | property | * Default ttl for request tokens | |
OAuthStoreSQL:: |
protected | property | * Maximum delta a timestamp may be off from a previous timestamp. * Allows multiple consumers with some clock skew to work with the same token. * Unit is seconds, default max skew is 10 minutes. | |
OAuthStoreSQL:: |
public | function |
* Add an unautorized request token to our server.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Add a request token we obtained from a server.
*
* @todo remove old tokens for this user and this ocr_id
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Upgrade a request token to be an authorized request token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Check an nonce/timestamp combination. Clears any nonce combinations
* that are older than the one received.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Count the consumer access tokens for the given consumer.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Count how many tokens we have for the given server
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Delete a consumer key. This removes access to our site for all applications using this key.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Delete a consumer access token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Delete a consumer token. The token must be a request or authorized token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Delete a server key. This removes access to that site.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Delete a token we obtained from a server.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Exchange an authorized request token for new access token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch a consumer of this server, by consumer_key.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch the consumer access token, by access token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch the consumer request token, by request token.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch the static consumer key for this provider. The user for the static consumer
* key is NULL (no user, shared key). If the key did not exist then the key is created.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Find the server details for signing a request, always looks for an access token.
* The returned credentials depend on which local user is making the request.
*
* The consumer_key must belong to the user or be public (user id is null)
*
*… Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Find stored credentials for the consumer key and token. Used by an OAuth server
* when verifying an OAuth request.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Get a server from the consumer registry using the consumer key
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Find the server details that might be used for a request
*
* The consumer_key must belong to the user or be public (user id is null)
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Get a specific server token for the given user
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Get the token and token secret we obtained from a server.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* List of all registered applications. Data returned has not sensitive
* information and therefore is suitable for public displaying.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch a list of all consumer keys, secrets etc.
* Returns the public (user_id is null) and the keys owned by the user
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Fetch a list of all consumer tokens accessing the account of the given user.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Get a list of all consumers from the consumer registry.
* The consumer keys belong to the user or are public (user id is null)
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Get a list of all server token this user has access to.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Set the ttl of a consumer access token. This is done when the
* server receives a valid request with a xoauth_token_ttl parameter in it.
*
* Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function | * Set the ttl of a server access token. This is done when the * server receives a valid request with a xoauth_token_ttl parameter in it. * * | |
OAuthStoreSQL:: |
public | function |
* Insert/update a new consumer with this server (we will be the server)
* When this is a new consumer, then also generate the consumer key and secret.
* Never updates the consumer key and secret.
* When the id is set, then the key and secret… Overrides OAuthStoreAbstract:: |
|
OAuthStoreSQL:: |
public | function |
* Register or update a server for our site (we will be the consumer)
*
* (This is the registry at the consumers, registering servers ;-) )
*
* Overrides OAuthStoreAbstract:: |