You are here

public function OAuthStoreSQL::setConsumerAccessTokenTtl in Lingotek Translation 7.2

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

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

Parameters

string token: * @param int ttl

Overrides OAuthStoreAbstract::setConsumerAccessTokenTtl

File

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

Class

OAuthStoreSQL

Code

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

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

    // Set maximum time to live for this token
    $this
      ->query('
						UPDATE oauth_server_token
						SET ost_token_ttl = DATE_ADD(NOW(), INTERVAL %d SECOND)
						WHERE ost_token 	 = \'%s\'
						  AND ost_token_type = \'access\'
						', $token_ttl, $token);
  }
}