| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: token_user.inc,v 1.3.4.10 2010/08/10 04:01:05 davereid Exp $ 3 4 /** 5 * @file 6 * Implementations of token module hooks for the core user module. 7 * 8 * The token module requires specific hooks to be added to modules 9 * so that those modules can return data about their objects to the 10 * token API. Until and unless token becomes a part of core, the 11 * implementations of the token hooks for core modules are provided 12 * in the token module itself. 13 * 14 * @ingroup token 15 */ 16 17 /** 18 * Implementation of hook_token_values(). 19 */ 20 function user_token_values($type, $object = NULL, $options = array()) { 21 $values = array(); 22 switch ($type) { 23 case 'user': 24 if (isset($object)) { 25 $account = $object; 26 } 27 else { 28 global $user; 29 $account = user_load(array('uid' => $user->uid)); 30 } 31 32 // Adjust for the anonymous user name. 33 if (!$account->uid && !$account->name) { 34 $account->name = variable_get('anonymous', 'Anonymous'); 35 } 36 37 $values['user'] = check_plain($account->name); 38 $values['user-raw'] = $account->name; 39 $values['uid'] = $account->uid; 40 $values['mail'] = $account->uid ? $account->mail : ''; 41 $values['date-in-tz'] = $account->uid ? format_date(time(), 'small', '', $account->timezone) : ''; 42 $values['account-url'] = $account->uid ? url("user/$account->uid", array('absolute' => TRUE)) : ''; 43 $values['account-edit'] = $account->uid ? url("user/$account->uid/edit", array('absolute' => TRUE)) : ''; 44 45 if ($account->uid) { 46 $values += token_get_date_token_values($account->created, 'user-created-'); 47 $values += token_get_date_token_values($account->access, 'user-last-login-'); 48 $values['reg-date'] = $values['user-created-small']; 49 $values['reg-since'] = $values['user-created-since']; 50 $values['log-date'] = $values['user-last-login-small']; 51 $values['log-since'] = $values['user-last-login-since']; 52 } 53 54 break; 55 } 56 return $values; 57 } 58 59 /** 60 * Implementation of hook_token_list(). 61 */ 62 function user_token_list($type = 'all') { 63 if ($type == 'user' || $type == 'all') { 64 $tokens['user']['user'] = t("The login name of the user account."); 65 $tokens['user']['user-raw'] = t("The login name of the user account."); 66 67 $tokens['user']['uid'] = t("The unique ID of the user account."); 68 $tokens['user']['mail'] = t("The email address of the user account."); 69 70 $tokens['user'] += token_get_date_token_info(t("User's registration"), 'user-created-'); 71 $tokens['user'] += token_get_date_token_info(t("User's last login"), 'user-last-login-'); 72 $tokens['user']['date-in-tz'] = t("The current date in the user's timezone."); 73 $tokens['user']['account-url'] = t("The URL of the account profile page."); 74 $tokens['user']['account-edit'] = t("The URL of the account edit page."); 75 76 return $tokens; 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |