Index: advuser.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/advuser.info,v
retrieving revision 1.3.4.2
diff -u -p -r1.3.4.2 advuser.info
--- advuser.info	17 Apr 2010 02:09:31 -0000	1.3.4.2
+++ advuser.info	28 Apr 2010 16:17:52 -0000
@@ -2,3 +2,4 @@
 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'
Index: advuser.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/advuser.module,v
retrieving revision 1.14.2.7.2.15
diff -u -p -r1.14.2.7.2.15 advuser.module
--- advuser.module	27 Apr 2010 11:32:12 -0000	1.14.2.7.2.15
+++ advuser.module	28 Apr 2010 16:17:53 -0000
@@ -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', '[[site-url]] On [advuser-created] a new user registered as [user].');
 
 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: [user]
+    Mail: [mail]
+ Created: [advuser-created]
+  Status: [advuser-status]
+Timezone: [advuser-timezone]
+Language: [advuser-language]
+   Theme: [advuser-theme]
 
-Administor user at %uri for %site");
+Administor user at [account-edit] for [site-name]");
 
-define('ADVUSER_DEFAULT_MODIFY_SUBJECT', '[%site] User %user_name has modified their account.');
+define('ADVUSER_DEFAULT_MODIFY_SUBJECT', '[[site-url]] User [user] 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: [user]
+    Mail: [mail]
+ Created: [advuser-created]
+  Status: [advuser-status]
+Timezone: [advuser-timezone]
+Language: [advuser-language]
+   Theme: [advuser-theme]
 
-Administor user at %uri for %site");
+Administor user at [account-edit] for [site-name]");
+
+define('ADVUSER_TOKEN_PREFIX', '[');
+define('ADVUSER_TOKEN_SUFFIX', ']');
 
 /**
  * @} End of "defgroup advuser_constants".
@@ -288,26 +291,6 @@ function advuser_mail($key, &$message, $
 }
 
 /**
- * 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.
  *
@@ -370,9 +353,10 @@ function _advuser_receive_notification_b
     } break;
   }
 
-  $variables = _advuser_get_variables($account);
-  $subject = strtr($subject, $variables);
-  $body = strtr($body, $variables);
+  $types = array('user' => $account);
+  $subject = token_replace_multiple($subject, $types, ADVUSER_TOKEN_PREFIX, ADVUSER_TOKEN_SUFFIX);
+  $body = token_replace_multiple($body, $types, ADVUSER_TOKEN_PREFIX, ADVUSER_TOKEN_SUFFIX);
+  unset($types);
 
   if ($notify) {
     if (variable_get('advuser_log_notifications', FALSE)) {
@@ -849,4 +833,39 @@ function advuser_reset_variables() {
   $advuser['deselected'] = array();
 }
 
+/**
+ * Implementation of hook_token_values().
+ */
+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;
+  }
+}
+
+/**
+ * Implementation of hook_token_list().
+ */
+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
Index: forms/advuser_multiple_email_confirm.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/forms/Attic/advuser_multiple_email_confirm.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 advuser_multiple_email_confirm.inc
--- forms/advuser_multiple_email_confirm.inc	17 Apr 2010 03:46:58 -0000	1.1.2.4
+++ forms/advuser_multiple_email_confirm.inc	28 Apr 2010 16:17:54 -0000
@@ -61,7 +61,7 @@ function advuser_multiple_email_confirm(
   $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 @@ function advuser_multiple_email_confirm_
   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);
       $from = $form_state['values']['mailfrom'];
-      $mail_subject = strtr($form_state['values']['mailsubject'], $variables);
-      $mail_body = strtr($form_state['values']['mailbody'], $variables);
+      $types = array('user' => $account);
+      $mail_subject = token_replace_multiple($form_state['values']['mailsubject'], $types, ADVUSER_TOKEN_PREFIX, ADVUSER_TOKEN_SUFFIX);
+      $mail_body = token_replace_multiple($form_state['values']['mailbody'], $types, ADVUSER_TOKEN_PREFIX, ADVUSER_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.'));
Index: forms/advuser_settings.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/forms/Attic/advuser_settings.inc,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 advuser_settings.inc
--- forms/advuser_settings.inc	17 Apr 2010 03:46:58 -0000	1.1.2.8
+++ forms/advuser_settings.inc	28 Apr 2010 16:17:55 -0000
@@ -85,7 +85,7 @@ function advuser_settings() {
   $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>',
   );
 
@@ -125,7 +125,7 @@ function advuser_settings() {
   $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>',
   );
 
@@ -243,4 +243,19 @@ function advuser_settings() {
   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
