You are here

function tokenauth_get_token in Token authentication 6

Same name and namespace in other branches
  1. 5 tokenauth.module \tokenauth_get_token()
  2. 6.2 tokenauth.inc \tokenauth_get_token()
  3. 7 tokenauth.inc \tokenauth_get_token()

API function for retrieving the token for a given user.

Parameters

string $uid : Assumes current user if no user is provided.

$reset: Whether to reset the internal cache.

Return value

The user's token.

4 calls to tokenauth_get_token()
tokenauth_reset_user in ./tokenauth.inc
API Function to reset a user's token.
tokenauth_token_values in ./tokenauth.module
Implementation of hook_token_values()
tokenauth_url_outbound_alter in ./tokenauth.module
Implementation of hook_url_outbound_alter(). Appends the current user's token to any path run through url() that also passes tokenauth's allowed pages filter.
tokenauth_user_profile_form in ./tokenauth.pages.inc
Menu callback. Prints the token and instructions.

File

./tokenauth.inc, line 101
Provides tokenauth API for Token Authentication module.

Code

function tokenauth_get_token($uid = NULL, $reset = FALSE) {
  static $tokens;
  if (is_null($uid)) {
    $uid = $GLOBALS['user']->uid;
  }
  if (!isset($tokens[$uid]) || $reset) {
    $tokens[$uid] = db_result(db_query("SELECT tt.token FROM {tokenauth_tokens} tt WHERE tt.uid = %d", $uid));
  }
  return $tokens[$uid];
}