You are here

public function OAuthStoreSQL::setServerTokenTtl in Lingotek Translation 7.2

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

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

Parameters

string consumer_key: * @param string token * @param int token_ttl

File

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

Class

OAuthStoreSQL

Code

public function setServerTokenTtl($consumer_key, $token, $token_ttl) {
  if ($token_ttl <= 0) {

    // Immediate delete when the token is past its ttl
    $this
      ->deleteServerToken($consumer_key, $token, 0, true);
  }
  else {

    // Set maximum time to live for this token
    $this
      ->query('
						UPDATE oauth_consumer_token, oauth_consumer_registry
						SET ost_token_ttl = DATE_ADD(NOW(), INTERVAL %d SECOND)
						WHERE ocr_consumer_key	= \'%s\'
						  AND oct_ocr_id_ref    = ocr_id
						  AND oct_token 	    = \'%s\'
						', $token_ttl, $consumer_key, $token);
  }
}