Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.7.4.51
diff -u -p -r1.7.4.51 token.module
--- token.module	12 Jan 2011 04:06:43 -0000	1.7.4.51
+++ token.module	25 Jan 2011 02:34:06 -0000
@@ -93,16 +93,10 @@ function token_theme() {
  * Implements hook_token_values().
  */
 function token_token_values($type, $object = NULL) {
-  global $user;
   $values = array();
 
   switch ($type) {
     case 'global':
-      // Current user tokens.
-      $values['user-name']    = $user->uid ? $user->name : variable_get('anonymous', t('Anonymous'));
-      $values['user-id']      = $user->uid ? $user->uid : 0;
-      $values['user-mail']    = $user->uid ? $user->mail : '';
-
       // Site information tokens.
       $values['site-url']     = url('<front>', array('absolute' => TRUE));
       $values['site-name']    = check_plain(variable_get('site_name', t('Drupal')));
@@ -139,11 +133,6 @@ function token_token_list($type = 'all')
   $tokens = array();
 
   if ($type == 'global' || $type == 'all') {
-    // Current user tokens.
-    $tokens['global']['user-name']    = t('The name of the currently logged in user.');
-    $tokens['global']['user-id']      = t('The user ID of the currently logged in user.');
-    $tokens['global']['user-mail']    = t('The email address of the currently logged in user.');
-
     // Site information tokens.
     $tokens['global']['site-url']     = t("The URL of the site's front page.");
     $tokens['global']['site-name']    = t('The name of the site.');
Index: token_user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/Attic/token_user.inc,v
retrieving revision 1.3.4.12
diff -u -p -r1.3.4.12 token_user.inc
--- token_user.inc	11 Nov 2010 00:12:20 -0000	1.3.4.12
+++ token_user.inc	25 Jan 2011 02:34:07 -0000
@@ -15,14 +15,17 @@
  */
 
 /**
- * Implementation of hook_token_list().
+ * Implements hook_token_list() on behalf of user.module.
  */
 function user_token_list($type = 'all') {
+  $tokens = array();
+
+  // User account tokens.
   if ($type == 'user' || $type == 'all') {
     $tokens['user']['user']     = t("The login name of the user account.");
     $tokens['user']['user-raw'] = t("The login name of the user account.");
     $tokens['user']['uid']      = t("The unique ID of the user account.");
-    $tokens['user']['mail']     = t("The email address of the user account.");
+    $tokens['user']['mail']     = t("The e-mail address of the user account.");
 
     $tokens['user'] += token_get_date_token_info(t("User's registration"), 'user-created-');
     $tokens['user'] += token_get_date_token_info(t("User's last login"), 'user-last-login-');
@@ -30,50 +33,54 @@ function user_token_list($type = 'all') 
 
     $tokens['user']['account-url']      = t("The URL of the account profile page.");
     $tokens['user']['account-edit-url'] = t("The URL of the account edit page.");
+  }
 
-    return $tokens;
+  // Current user tokens.
+  if ($type == 'global' || $type == 'all') {
+    $tokens['global']['user-name'] = t('The name of the currently logged in user.');
+    $tokens['global']['user-id']   = t('The user ID of the currently logged in user.');
+    $tokens['global']['user-mail'] = t('The e-mail address of the currently logged in user.');
   }
+
+  return $tokens;
 }
 
 /**
- * Implementation of hook_token_values().
+ * Implemens hook_token_values() on behalf of user.module.
  */
 function user_token_values($type, $object = NULL, $options = array()) {
+  global $user;
   $values = array();
-  switch ($type) {
-    case 'user':
-      if (!empty($object)) {
-        $account = $object;
-      }
-      else {
-        $account = user_load(array('uid' => $GLOBALS['user']->uid));
-      }
-
-      // Adjust for the anonymous user name.
-      if (!$account->uid && !$account->name) {
-        $account->name = variable_get('anonymous', 'Anonymous');
-      }
-
-      $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'];
 
-      break;
+  // User account tokens.
+  if ($type == 'user' && !empty($object)) {
+    $account = $object;
+
+    $values['user-raw'] = !$account->uid && !$account->name ?  : $account->name;
+    $values['user']     = check_plain($values['user-raw']);
+    $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'] = format_date(time(), 'small', '', $account->timezone);
+      $values['account-url'] = url("user/$account->uid", array('absolute' => TRUE));
+      $values['account-edit-url'] = url("user/$account->uid/edit", array('absolute' => TRUE));
+      $values['account-edit'] = $values['account-edit-url'];
+    }
   }
+
+  // Current user tokens.
+  if ($type == 'global') {
+    $values['user-name'] = !$user->uid && !$user->name ? variable_get('anonymous', 'Anonymous') : $user->name;
+    $values['user-id']   = $user->uid;
+    $values['user-mail'] = $user->uid ? $user->mail : '';
+  }
+
   return $values;
 }
