You are here

public function OAuthStoreSQL::getConsumerStatic in Lingotek Translation 7.7

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

* 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. * *

Return value

string

Overrides OAuthStoreAbstract::getConsumerStatic

File

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

Class

OAuthStoreSQL

Code

public function getConsumerStatic() {
  $consumer = $this
    ->query_one('
						SELECT osr_consumer_key
						FROM oauth_server_registry
						WHERE osr_consumer_key LIKE \'sc-%%\'
						  AND osr_usa_id_ref IS NULL
						');
  if (empty($consumer)) {
    $consumer_key = 'sc-' . $this
      ->generateKey(true);
    $this
      ->query('
				INSERT INTO oauth_server_registry
				SET osr_enabled				= 1,
					osr_status				= \'active\',
					osr_usa_id_ref			= NULL,
					osr_consumer_key		= \'%s\',
					osr_consumer_secret		= \'\',
					osr_requester_name		= \'\',
					osr_requester_email		= \'\',
					osr_callback_uri		= \'\',
					osr_application_uri		= \'\',
					osr_application_title	= \'Static shared consumer key\',
					osr_application_descr	= \'\',
					osr_application_notes	= \'Static shared consumer key\',
					osr_application_type	= \'\',
					osr_application_commercial = 0,
					osr_timestamp			= NOW(),
					osr_issue_date			= NOW()
				', $consumer_key);

    // Just make sure that if the consumer key is truncated that we get the truncated string
    $consumer = $this
      ->getConsumerStatic();
  }
  return $consumer;
}