function tokenauth_get_token in Token authentication 7
Same name and namespace in other branches
- 5 tokenauth.module \tokenauth_get_token()
- 6.2 tokenauth.inc \tokenauth_get_token()
- 6 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_tokens in ./
tokenauth.module - Implements hook_tokens().
- tokenauth_url_outbound_alter in ./
tokenauth.module - Implements hook_url_outbound_alter().
- tokenauth_user_profile_form in ./
tokenauth.pages.inc - Menu callback. Prints the token and instructions.
File
- ./
tokenauth.inc, line 94 - 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) {
$sql = "SELECT token FROM {tokenauth_tokens} WHERE uid = :uid";
$tokens[$uid] = db_query($sql, array(
':uid' => $uid,
))
->fetchField();
}
return $tokens[$uid];
}