--- webform-orig/webform.module	Sun Mar 21 05:44:44 2010 -0400
+++ webform-modified/webform.module	Sun Mar 21 05:46:05 2010 -0400
@@ -2138,6 +2138,17 @@
   global $user;
   static $replacements;
 
+  // Token module replacements
+  if (module_exists('token')) {
+      $reptypes = array('global' => NULL, 'user' => $user);
+      if(isset($node))
+          $reptypes += array('node' => $node);
+      if (module_exists('token_profile2'))
+          $reptypes += array('uprofile' => $user, 'profile' => $user);
+
+      $string = token_replace_multiple($string, $reptypes, '[[', ']]');
+  }
+
   // Setup default token replacements.
   if (!isset($replacements)) {
     $replacements['unsafe'] = array();
@@ -2229,6 +2240,7 @@
   foreach ($special_tokens as $safe_state => $tokens) {
     foreach (array_keys($tokens) as $token) {
       $string = preg_replace('/\\'. $token .'\[\w+\]/', '', $string);
+      $string = preg_replace('/\[\[[a-zA-Z0-9-]+\]\]/', '', $string);
     }
   }
 
@@ -2347,13 +2359,32 @@
     $output .= ' '. t('If you are using the profiles module, you can also access all profile data using the syntax %profile[form_name]. If you for example have a profile value named profile_city, add the variable %profile[profile_city].');
   }
 
-  $fieldset = array(
-    '#title' => t('Token values'),
-    '#type' => 'fieldset',
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#children' => '<div>'. $output .'</div>',
-  );
+
+  if (module_exists('token')) {
+      if (module_exists('token_profile2'))
+        $token_help = array('global', 'user', 'profile', 'uprofile');
+    
+      else
+        $token_help = array('global', 'user');
+
+      $fieldset = array(
+        '#title' => t('Token values'),
+        '#type' => 'fieldset',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#children' => '<div>'. $output .'</div><br><p>Additional tokens. Make sure to include the \'<b>[[</b>\' and \'<b>]]</b>\'. </p>' . theme('token_help', $token_help, '[[', ']]'),
+      );
+    }
+    else {
+      $fieldset = array(
+        '#title' => t('Token values'),
+        '#type' => 'fieldset',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#children' => '<div>'. $output .'</div>',
+      );
+  }
+
   return theme('fieldset', $fieldset);
 }
