function user_token_values in Token 6
Same name and namespace in other branches
- 5 token_user.inc \user_token_values()
Implementation of hook_token_values().
File
- ./
token_user.inc, line 42 - Implementations of token module hooks for the core user module.
Code
function user_token_values($type, $object = NULL, $options = array()) {
$values = array();
if ($type == 'user') {
// @todo Why do we all the current user object to be loaded?
$account = !empty($object) ? $object : user_load(array(
'uid' => $GLOBALS['user']->uid,
));
// Adjust for the anonymous user name.
if (!$account->uid && empty($account->name)) {
$account_name = variable_get('anonymous', 'Anonymous');
}
else {
$account_name = $account->name;
}
$values['user'] = check_plain($account_name);
$values['user-raw'] = $account_name;
$values['uid'] = $account->uid;
$values['mail'] = $account->uid ? $account->mail : '';
if ($account->uid) {
$values += token_get_date_token_values($account->created, 'user-created-');
$values += token_get_date_token_values($account->access, 'user-last-login-');
$values['reg-date'] = $values['user-created-small'];
$values['reg-since'] = $values['user-created-since'];
$values['log-date'] = $values['user-last-login-small'];
$values['log-since'] = $values['user-last-login-since'];
$values['date-in-tz'] = $account->uid ? format_date(time(), 'small', '', $account->timezone) : '';
}
$values['account-url'] = $account->uid ? url("user/{$account->uid}", array(
'absolute' => TRUE,
)) : '';
$values['account-edit-url'] = $account->uid ? url("user/{$account->uid}/edit", array(
'absolute' => TRUE,
)) : '';
$values['account-edit'] = $values['account-edit-url'];
}
return $values;
}