diff -ur advuser.orig/advuser.info advuser/advuser.info
--- advuser.orig/advuser.info	2010-04-18 21:00:26.000000000 -0300
+++ advuser/advuser.info	2010-04-26 19:29:16.561569066 -0300
@@ -2,6 +2,7 @@
 name = Advanced User Management
 description = Advanced user management providing advanced filtering of users and providing mass actions of selected filtered users across multiple pages of the users list.
 core = 6.x
+dependencies[] = 'token'
 
 ; Information added by drupal.org packaging script on 2010-04-19
 version = "6.x-3.x-dev"
diff -ur advuser.orig/advuser.module advuser/advuser.module
--- advuser.orig/advuser.module	2010-04-27 10:28:54.600818024 -0300
+++ advuser/advuser.module	2010-04-27 09:45:07.863817270 -0300
@@ -12,33 +12,36 @@
  * @defgroup advuser_constants Advanced User constants
  * @{
  */
-define('ADVUSER_SUBSTITUTION_TEXT', '<strong>Substitution variables</strong> available in subject and email body<br/><em> %user_name, %user_email, %user_status, %user_created, %user_theme, %user_timezone, %user_language, %user_signature, %site, %uri</em>');
+define('ADVUSER_SUBSTITUTION_TEXT', '<strong>Substitution variables</strong> available in subject and email body:<br/>!tokens');
 
-define('ADVUSER_DEFAULT_NEW_SUBJECT', '[%site] On %user_created a new user registered as %user_name.');
+define('ADVUSER_DEFAULT_NEW_SUBJECT', '[!prefixsite-url!suffix] On !prefixadvuser-created!suffix a new user registered as !prefixuser!suffix.');
 
 define('ADVUSER_DEFAULT_NEW_MAIL', "=====  New User Information:  =====
-    User: %user_name 
-    Mail: %user_email
- Created: %user_created 
-  Status: %user_status
-Timezone: %user_timezone
-Language: %user_language
-   Theme: %user_theme
+    User: !prefixuser!suffix
+    Mail: !prefixmail!suffix
+ Created: !prefixadvuser-created!suffix
+  Status: !prefixadvuser-status!suffix
+Timezone: !prefixadvuser-timezone!suffix
+Language: !prefixadvuser-language!suffix
+   Theme: !prefixadvuser-theme!suffix
 
-Administor user at %uri for %site");
+Administor user at !prefixaccount-edit!suffix for !prefixsite-name!suffix");
 
-define('ADVUSER_DEFAULT_MODIFY_SUBJECT', '[%site] User %user_name has modified their account.');
+define('ADVUSER_DEFAULT_MODIFY_SUBJECT', '[!prefixsite-url!suffix] User !prefixuser!suffix has modified their account.');
 
 define('ADVUSER_DEFAULT_MODIFY_MAIL', "=====  Updated User Information:  =====
-    User: %user_name 
-    Mail: %user_email
- Created: %user_created 
-  Status: %user_status
-Timezone: %user_timezone
-Language: %user_language
-   Theme: %user_theme
+    User: !prefixuser!suffix
+    Mail: !prefixmail!suffix
+ Created: !prefixadvuser-created!suffix
+  Status: !prefixadvuser-status!suffix
+Timezone: !prefixadvuser-timezone!suffix
+Language: !prefixadvuser-language!suffix
+   Theme: !prefixadvuser-theme!suffix
 
-Administor user at %uri for %site");
+Administor user at !prefixaccount-edit!suffix for !prefixsite-name!suffix");
+
+define('ADVUSER_DEFAULT_TOKEN_PREFIX', '[');
+define('ADVUSER_DEFAULT_TOKEN_SUFFIX', ']');
 
 /**
  * @} End of "defgroup advuser_constants".
@@ -288,26 +291,6 @@
 }
 
 /**
- * Get a list of substitution variables for the user account
- * @param $user the user account
- * @return An associative array of substitution variables 
- */
-function _advuser_get_variables($user) {
-  return array(
-    '%user_name' => $user->name,
-    '%site' => variable_get("site_name", "drupal"), 
-    '%uri' => url('user/'. $user->uid, array('absolute' => TRUE)), 
-    '%user_email' => $user->mail,
-    '%user_status' => t($user->status ? 'Active' : 'Blocked'),
-    '%user_theme' => empty($user->theme) ? t('DEFAULT') : $user->theme,
-    '%user_created' => strftime('%x %X', $user->created),
-    '%user_language' => empty($user->language) ? t('DEFAULT') : $user->language,
-    '%user_timezone' => empty($user->timezone) ? '0' : "$user->timezone",
-    '%user_signature' => $user->signature,
-  );
-}
-
-/**
  * @private
  * Return a list of users to send notification of user changes.
  *
@@ -359,20 +342,21 @@
     case 'insert': {
       $notify = variable_get('advuser_new_notify', FALSE) &&
               ! user_access('administer users');
-      $body = variable_get('advuser_new_mail', t(ADVUSER_DEFAULT_NEW_MAIL));
-      $subject = variable_get('advuser_new_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT));
+      $body = variable_get('advuser_new_mail', t(ADVUSER_DEFAULT_NEW_MAIL, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX)));
+      $subject = variable_get('advuser_new_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX)));
     } break;
     case 'update': {
       $notify = variable_get('advuser_modify_notify', FALSE) &&
               ! user_access('administer users');
-      $body = variable_get('advuser_modify_mail', t(ADVUSER_DEFAULT_NEW_MAIL));
-      $subject = variable_get('advuser_modify_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT));
+      $body = variable_get('advuser_modify_mail', t(ADVUSER_DEFAULT_NEW_MAIL, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX)));
+      $subject = variable_get('advuser_modify_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX)));
     } break;
   }
 
-  $variables = _advuser_get_variables($account);
-  $subject = strtr($subject, $variables);
-  $body = strtr($body, $variables);
+  $types = array('global' => NULL, 'user' => $account);
+  $subject = token_replace_multiple($subject, $types, ADVUSER_DEFAULT_TOKEN_PREFIX, ADVUSER_DEFAULT_TOKEN_SUFFIX);
+  $body = token_replace_multiple($body, $types, ADVUSER_DEFAULT_TOKEN_PREFIX, ADVUSER_DEFAULT_TOKEN_SUFFIX);
+  unset($types);
 
   if ($notify) {
     if (variable_get('advuser_log_notifications', FALSE)) {
@@ -849,4 +833,39 @@
   $advuser['deselected'] = array();
 }
 
+/**
+ * hook_token_values implementation.
+ */
+function advuser_token_values($type, $object = NULL, $options = array()) {
+  if ($type == 'user') {
+    $user = $object;
+    $tokens = array();
+    $tokens['advuser-status'] = $user->status ? t('Active') : t('Blocked');
+    $tokens['advuser-theme'] = empty($user->theme) ? t('DEFAULT') : $user->theme;
+    $tokens['advuser-created'] = strftime('%x %X', $user->created);
+    $tokens['advuser-language'] = empty($user->language) ? t('DEFAULT') : $user->language;
+    $tokens['advuser-timezone'] = empty($user->timezone) ? '0' : "$user->timezone";
+    $tokens['advuser-signature'] = check_plain($user->signature);
+    $tokens['advuser-signature-raw'] = $user->signature;
+    return $tokens;
+  }
+}
+
+/**
+ * hook_token_list implementation.
+ */
+function advuser_token_list($type = 'all') {
+  if ($type == 'user' || $type == 'all') {
+    $tokens = array();
+    $tokens['user']['advuser-status'] = t("The advuser module user's status (either '!active' or '!blocked').", array('!active' => t('Active'), '!blocked' => t('Blocked')));
+    $tokens['user']['advuser-theme'] = t("The advuser module user's theme (or '!default' if not defined).", array('!default' => t('DEFAULT')));
+    $tokens['user']['advuser-created'] = t("The advuser module user's created date and time.");
+    $tokens['user']['advuser-language'] = t("The advuser module user's language (or '!default' if not defined).", array('!default' => t('DEFAULT')));
+    $tokens['user']['advuser-timezone'] = t("The advuser module user's timezone (or '0' if not defined).");
+    $tokens['user']['advuser-signature'] = t("The advuser module user's signature.");
+    $tokens['user']['advuser-signature-raw'] = t("The advuser module unfiltered user's signature. WARNING - raw user input.");
+    return $tokens;
+  }
+}
+
 // vim:ft=php:sts=2:sw=2:ts=2:et:ai:sta:ff=unix
diff -ur advuser.orig/forms/advuser_multiple_email_confirm.inc advuser/forms/advuser_multiple_email_confirm.inc
--- advuser.orig/forms/advuser_multiple_email_confirm.inc	2010-04-17 00:46:34.000000000 -0300
+++ advuser/forms/advuser_multiple_email_confirm.inc	2010-04-27 09:39:37.481692929 -0300
@@ -61,7 +61,7 @@
   $form['variables'] = array(
     '#type' => 'markup', 
     '#prefix' => '<div class="advuser-inset-panel">',
-    '#value' => t(ADVUSER_SUBSTITUTION_TEXT),
+    '#value' => t(ADVUSER_SUBSTITUTION_TEXT, array('!tokens' => _advuser_get_tokens_list())),
     '#suffix' => '</div>' 
   );
 
@@ -113,11 +113,10 @@
   if ($form_state['values']['confirm']) {
     foreach ($accounts as $uid => $value) {
       $account = user_load(array('uid' => $uid));
-      // these are invariant for all sent emails
-      $variables = _advuser_get_variables($account);
+      $types = array('global' => NULL, 'user' => $account);
       $from = $form_state['values']['mailfrom'];
-      $mail_subject = strtr($form_state['values']['mailsubject'], $variables);
-      $mail_body = strtr($form_state['values']['mailbody'], $variables);
+      $mail_subject = token_replace_multiple($form_state['values']['mailsubject'], $types, ADVUSER_DEFAULT_TOKEN_PREFIX, ADVUSER_DEFAULT_TOKEN_SUFFIX);
+      $mail_body = token_replace_multiple($form_state['values']['mailbody'], $types, ADVUSER_DEFAULT_TOKEN_PREFIX, ADVUSER_DEFAULT_TOKEN_SUFFIX);
       drupal_mail('advuser', 'advuser-mail', $account->mail, user_preferred_language($account), array('subject' => $mail_subject, 'body' => $mail_body), $from, TRUE);
     }
     drupal_set_message(t('The users have been mailed.'));
diff -ur advuser.orig/forms/advuser_settings.inc advuser/forms/advuser_settings.inc
--- advuser.orig/forms/advuser_settings.inc	2010-04-17 00:46:34.000000000 -0300
+++ advuser/forms/advuser_settings.inc	2010-04-27 09:41:27.675819352 -0300
@@ -85,7 +85,7 @@
   $form['advuser_mail']['registration']['variables'] = array(
     '#type' => 'markup', 
     '#prefix' => '<div class="advuser-inset-panel">',
-    '#value' => t(ADVUSER_SUBSTITUTION_TEXT),
+    '#value' => t(ADVUSER_SUBSTITUTION_TEXT, array('!tokens' => _advuser_get_tokens_list())),
     '#suffix' => '</div>',
   );
 
@@ -102,7 +102,7 @@
     '#type' => 'textfield',
     '#title' => t('Mail subject'),
     '#description' => t('The subject of the mail that is going to be sent to the user.  You may insert substitution variables within this item.'),
-    '#default_value' => variable_get('advuser_new_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT)),
+    '#default_value' => variable_get('advuser_new_subject', t(ADVUSER_DEFAULT_NEW_SUBJECT, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX))),
   );
 
   // The body of the mail.
@@ -110,7 +110,7 @@
     '#type' => 'textarea',
     '#title' => t('Mail body'),
     '#description' => t('The mail that is going to be sent to the selected roles.  You may insert substitution variables within this item.'),
-    '#default_value' => variable_get('advuser_new_mail', t(ADVUSER_DEFAULT_NEW_MAIL)),
+    '#default_value' => variable_get('advuser_new_mail', t(ADVUSER_DEFAULT_NEW_MAIL, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX))),
   );
 
   // Account change notifications.
@@ -125,7 +125,7 @@
   $form['advuser_mail']['update']['variables'] = array(
     '#type' => 'markup', 
     '#prefix' => '<div class="advuser-inset-panel">',
-    '#value' => t(ADVUSER_SUBSTITUTION_TEXT),
+    '#value' => t(ADVUSER_SUBSTITUTION_TEXT, array('!tokens' => _advuser_get_tokens_list())),
     '#suffix' => '</div>',
   );
 
@@ -142,7 +142,7 @@
     '#type' => 'textfield',
     '#title' => t('Mail subject'),
     '#description' => t('The subject of the mail that is going to be sent when a user modifies their profiles.  You may insert substitution variables within this item.'),
-    '#default_value' => variable_get('advuser_modify_subject', t(ADVUSER_DEFAULT_MODIFY_SUBJECT)),
+    '#default_value' => variable_get('advuser_modify_subject', t(ADVUSER_DEFAULT_MODIFY_SUBJECT, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX))),
   );
 
   // The body of the mail.
@@ -150,7 +150,7 @@
     '#type' => 'textarea',
     '#title' => t('Mail body'),
     '#description' => t('The mail that is going to be sent to the selected roles when a user modifies their account.  You may insert substitution variables within this item.'),
-    '#default_value' => variable_get('advuser_modify_mail', t(ADVUSER_DEFAULT_MODIFY_MAIL)),
+    '#default_value' => variable_get('advuser_modify_mail', t(ADVUSER_DEFAULT_MODIFY_MAIL, array('!prefix' => ADVUSER_DEFAULT_TOKEN_PREFIX, '!suffix' => ADVUSER_DEFAULT_TOKEN_SUFFIX))),
   );
         
   // Provide checkboxes for available profile fields.
@@ -243,4 +243,19 @@
   return system_settings_form($form);
 }
 
+/**
+ * Returns the HTML representation of the available tokens list.
+ *
+ * @return string The HTML representation of the list of usable tokens and their descriptions, organized by
+ *   token type.
+ */
+function _advuser_get_tokens_list() {
+  static $tokens_list = '';
+
+  if(!$tokens_list) {
+		$tokens_list = theme('token_help', 'user');
+  }
+  return $tokens_list;
+}
+
 // vim:ft=php:sts=2:sw=2:ts=2:et:ai:sta:ff=unix
