Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.5.2.14
diff -u -r1.5.2.14 token.module
--- token.module	14 Jul 2008 19:15:02 -0000	1.5.2.14
+++ token.module	30 Jul 2008 13:51:04 -0000
@@ -22,12 +22,17 @@
  *    The prefix your module will use when parsing tokens. Defaults to '['
  * @param suffix
  *    The suffix your module will use when parsing tokens. Defaults to ']'
+ * @param global
+ *    Optionally, whether global tokens should be included.
  * @return An HTML table containing the formatting docs.
  */
-function theme_token_help($type = 'all', $prefix = '[', $suffix = ']') {
+function theme_token_help($type = 'all', $prefix = '[', $suffix = ']', $global = TRUE) {
   token_include();
   $full_list = token_get_list($type);
-  
+  if (!$global) {
+    unset($full_list['global']);
+  }
+
   $headers = array(t('Token'), t('Replacement value'));
   $rows = array();
   foreach ($full_list as $key => $category) {
@@ -45,7 +50,7 @@
 }
 
 /**
- * Sample implementation of hook_token_values(). 
+ * Sample implementation of hook_token_values().
  *
  * @param type
  *   A flag indicating the class of substitution tokens to use. If an
@@ -135,8 +140,8 @@
  * at once see token_replace_multiple().
  *
  * @param original
- *  A string, or an array of strings, to perform token substitutions
- *  on.
+ *   A string, or an array of strings, to perform token substitutions
+ *   on.
  * @param type
  *   A flag indicating the class of substitution tokens to use. If an
  *   object is passed in the second param, 'type' should contain the
@@ -147,16 +152,18 @@
  *   Optionally, the object to use for building substitution values.
  *   A node, comment, user, etc.
  * @param leading
- *    Character(s) to prepend to the token key before searching for
- *    matches. Defaults to an open-bracket.
+ *   Character(s) to prepend to the token key before searching for
+ *   matches. Defaults to an open-bracket.
  * @param trailing
- *    Character(s) to append to the token key before searching for
- *    matches. Defaults to a close-bracket.
+ *   Character(s) to append to the token key before searching for
+ *   matches. Defaults to a close-bracket.
+ * @param global
+ *   Optionally, whether global tokens should be included.
  * @return The modified version of $original, with all substitutions
  *   made.
  */
-function token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array()) {
-  $full = token_get_values($type, $object, FALSE, $options);
+function token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array(), $global = TRUE) {
+  $full = token_get_values($type, $object, FALSE, $options, $global);
   return _token_replace_tokens($original, $full->tokens, $full->values, $leading, $trailing);
 }
 
@@ -166,8 +173,8 @@
  * this function supports replacing mutiple types.
  *
  * @param original
- *  A string, or an array of strings, to perform token substitutions
- *  on.
+ *   A string, or an array of strings, to perform token substitutions
+ *   on.
  * @param types
  *   An array of substitution classes and optional objects. The key is
  *   a flag indicating the class of substitution tokens to use.
@@ -176,19 +183,21 @@
  *   object will be used for building substitution values. If no type
  *   is specified, only 'global' site-wide substitution tokens are built.
  * @param leading
- *    Character(s) to prepend to the token key before searching for
- *    matches. Defaults to an open-bracket.
+ *   Character(s) to prepend to the token key before searching for
+ *   matches. Defaults to an open-bracket.
  * @param trailing
- *    Character(s) to append to the token key before searching for
- *    matches. Defaults to a close-bracket.
+ *   Character(s) to append to the token key before searching for
+ *   matches. Defaults to a close-bracket.
+ * @param global
+ *   Optionally, whether global tokens should be included.
  * @return The modified version of $original, with all substitutions
  *   made.
  */
-function token_replace_multiple($original, $types = array('global' => NULL), $leading = '[', $trailing = ']', $options = array()) {
+function token_replace_multiple($original, $types = array('global' => NULL), $leading = '[', $trailing = ']', $options = array(), $global = TRUE) {
   $full = new stdClass();
   $full->tokens = $full->values = array();
   foreach ($types as $type => $object) {
-    $temp = token_get_values($type, $object, FALSE, $options);
+    $temp = token_get_values($type, $object, FALSE, $options, $global);
     $full->tokens = array_merge($full->tokens, $temp->tokens);
     $full->values = array_merge($full->values, $temp->values);
   }
@@ -214,11 +223,13 @@
  * @param object
  *   Optionally, the object to use for building substitution values.
  *   A node, comment, user, etc.
+ * @param global
+ *   Optionally, whether global tokens should be included.
  * @return
  *   A keyed array containing the substitution tokens and the substition
  *   values for the passed-in type and object.
  */
-function token_get_values($type = 'global', $object = NULL, $flush = FALSE, $options = array()) {
+function token_get_values($type = 'global', $object = NULL, $flush = FALSE, $options = array(), $global = TRUE) {
   static $tokens;
   static $running;
 
@@ -246,7 +257,7 @@
     $result->values = array();
     return $result;
   }
-  
+
   $running = TRUE;
 
   token_include();
@@ -262,11 +273,11 @@
 
   // Special-case global tokens, as we always want to be able to process
   // those substitutions.
-  if (!isset($tokens['global']['default'])) {
+  if ($global && !isset($tokens['global']['default'])) {
     $tokens['global']['default'] = module_invoke_all('token_values', 'global');
   }
 
-  $all = array_merge($tokens['global']['default'], $tokens[$type][$id]);
+  $all = $global ? array_merge($tokens['global']['default'], $tokens[$type][$id]) : $tokens[$type][$id];
 
   $result = new stdClass();
   $result->tokens = array_keys($all);
