? 0-user-text-field-tokens.txt
? field_token.tpl.php
? jquery-ui-tree
? jstree
? menu.tokens.inc
? patches
? theme
? token.inc
? treeTable
Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.56
diff -u -p -r1.56 token.module
--- token.module	13 Dec 2010 19:23:23 -0000	1.56
+++ token.module	18 Dec 2010 01:48:56 -0000
@@ -300,20 +300,26 @@ function token_get_info($token_type = NU
     else {
       $token_info = token_info();
 
+      foreach (array_keys($token_info['types']) as $type_key) {
+        if (isset($token_info['types'][$type_key]['type'])) {
+          // If this token type extends another token type, then merge in
+          // the base token type's tokens.
+          $token_info['tokens'] += array($type_key => array());
+          $token_info['tokens'][$type_key] += $token_info['tokens'][$token_info['types'][$type_key]['type']];
+        }
+        else {
+          // Add a 'type' value to each token type so we can properly use
+          // token_type_load().
+          $token_info['types'][$type_key]['type'] = $type_key;
+        }
+      }
+
       // Pre-sort tokens.
       uasort($token_info['types'], 'token_asort_tokens');
       foreach (array_keys($token_info['tokens']) as $type) {
         uasort($token_info['tokens'][$type], 'token_asort_tokens');
       }
 
-      // Add a 'type' value to each token type so we can properly use
-      // token_type_load().
-      foreach (array_keys($token_info['types']) as $type_key) {
-        if (!isset($token_info['types'][$type_key]['type'])) {
-          $token_info['types'][$type_key]['type'] = $type_key;
-        }
-      }
-
       // Store info in cache for future use.
       cache_set($cid, $token_info, 'cache_token');
     }
@@ -408,10 +414,6 @@ function token_get_invalid_tokens($type,
   $token_info = token_get_info();
   $invalid_tokens = array();
 
-  // Normalize the token type (e.g. if $type is 'current-user' we need to
-  // convert it to the 'user' type).
-  $type = $token_info['types'][$type]['type'];
-
   foreach ($tokens as $token => $full_token) {
     // Split token up if it has chains.
     $parts = explode(':', $token, 2);
@@ -716,8 +718,7 @@ function _token_build_tree($token_type, 
   }
 
   $tree = array();
-  $root_token_type = $info['types'][$token_type]['type'];
-  foreach ($info['tokens'][$root_token_type] as $token => $token_info) {
+  foreach ($info['tokens'][$token_type] as $token => $token_info) {
     // Build the raw token string.
     $token_parents = $options['parents'];
     if (empty($token_parents)) {
@@ -788,10 +789,11 @@ function token_find_duplicate_tokens() {
 }
 
 /**
- * Get a menu link by its mlid, access checked and link translated for rendering.
+ * Get a translated menu link by its mlid, without access checking.
  *
  * This function is a copy of menu_link_load() but with its own cache and a
- * simpler query to load the link.
+ * simpler query to load the link. This also skips normal menu link access
+ * checking by using _token_menu_link_translate().
  *
  * @param $mlid
  *   The mlid of the menu item.
@@ -820,6 +822,22 @@ function token_menu_link_load($mlid) {
   return $cache[$mlid];
 }
 
+/**
+ * Get a translated book menu link by its mlid, without access checking.
+ *
+ * This function is a copy of book_link_load() but with its own cache and a
+ * simpler query to load the link. This also skips normal menu link access
+ * checking by using _token_menu_link_translate().
+ *
+ * @param $mlid
+ *   The mlid of the book menu item.
+ *
+ * @return
+ *   A book menu link translated for rendering.
+ *
+ * @see book_link_load()
+ * @see _token_menu_link_translate()
+ */
 function token_book_link_load($mlid) {
   $cache = &drupal_static(__FUNCTION__, array());
 
Index: token.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.pages.inc,v
retrieving revision 1.12
diff -u -p -r1.12 token.pages.inc
--- token.pages.inc	25 Sep 2010 15:58:49 -0000	1.12
+++ token.pages.inc	18 Dec 2010 01:48:56 -0000
@@ -54,7 +54,6 @@ function theme_token_tree($variables) {
     if (!in_array($type, $token_types)) {
       continue;
     }
-    $type_info += array('type' => $type);
 
     if (count($token_types) > 1) {
       $row = _token_token_tree_format_row($type, $type_info, TRUE);
Index: token.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.test,v
retrieving revision 1.29
diff -u -p -r1.29 token.test
--- token.test	7 Dec 2010 18:43:49 -0000	1.29
+++ token.test	18 Dec 2010 01:48:56 -0000
@@ -70,7 +70,7 @@ class TokenTestHelper extends DrupalWebT
     $options += array('url_options' => array());
     $this->drupalGet($url, $options['url_options']);
     $this->refreshVariables();
-    $result = variable_get('token_page_tokens');
+    $result = variable_get('token_page_tokens', array());
 
     if (!isset($result['values']) || !is_array($result['values'])) {
       return $this->fail('Failed to generate tokens.');
@@ -114,6 +114,7 @@ class TokenUnitTestCase extends TokenTes
         '[site:slogan]',
         '[current-date:short]',
         '[current-user:name]',
+        '[current-user:ip-address]',
       ),
       'invalid tokens' => array(
         '[node:title:invalid]',
@@ -121,6 +122,7 @@ class TokenUnitTestCase extends TokenTes
         '[node:created:short:invalid]',
         '[invalid:title]',
         '[site:invalid]',
+        '[user:ip-address]',
         // Deprecated tokens
         '[node:tnid]',
         '[node:type]',
@@ -389,6 +391,7 @@ class TokenUserTestCase extends TokenTes
     $user_tokens = array(
       'picture' => theme('user_picture', array('account' => $this->account)),
       'picture:fid' => $this->account->picture->fid,
+      'ip-address' => NULL,
     );
     $this->assertTokens('user', $this->account, $user_tokens);
 
@@ -399,8 +402,15 @@ class TokenUserTestCase extends TokenTes
     $user_tokens = array(
       'picture' => NULL,
       'picture:fid' => NULL,
+      'ip-address' => NULL,
     );
     $this->assertTokens('user', $this->account, $user_tokens);
+
+    // The ip address token should work for the current user token type.
+    $tokens = array(
+      'ip-address' => ip_address(),
+    );
+    $this->assertTokens('current-user', NULL, $tokens);
   }
 }
 
Index: token.tokens.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.tokens.inc,v
retrieving revision 1.35
diff -u -p -r1.35 token.tokens.inc
--- token.tokens.inc	2 Dec 2010 17:21:50 -0000	1.35
+++ token.tokens.inc	18 Dec 2010 01:48:56 -0000
@@ -116,6 +116,7 @@ function token_token_info() {
     'description' => t('The extension of the file.'),
   );
 
+  // User tokens.
   // Add information on the restricted user tokens.
   $info['tokens']['user']['cancel-url'] = array(
     'name' => t('Account cancellation URL'),
@@ -135,6 +136,12 @@ function token_token_info() {
     );
   }
 
+  // Current user tokens.
+  $info['tokens']['current-user']['ip-address'] = array(
+    'name' => t('IP address'),
+    'description' => 'The IP address of the current user.',
+  );
+
   // Menu link tokens (work regardless if menu module is enabled or not).
   $info['types']['menu-link'] = array(
     'name' => t('Menu links'),
@@ -348,6 +355,18 @@ function token_tokens($type, $tokens, ar
     }
   }
 
+  // Current user tokens.
+  if ($type == 'current-user') {
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        case 'ip-address':
+          $ip = ip_address();
+          $replacements[$original] = $sanitize ? check_plain($ip) : $ip;
+          break;
+      }
+    }
+  }
+
   // Menu link tokens.
   if ($type == 'menu-link' && !empty($data['menu-link'])) {
     $link = (array) $data['menu-link'];
