Index: advuser.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/advuser.module,v
retrieving revision 1.13.2.4
diff -u -p -r1.13.2.4 advuser.module
--- advuser.module	24 Mar 2008 16:20:12 -0000	1.13.2.4
+++ advuser.module	26 Mar 2008 19:45:53 -0000
@@ -11,39 +11,50 @@
 /**
  * @constants
  */
-define('ADVUSER_DEFAULT_NEW_MAIL', 
-"User email: %user_email
+define('ADVUSER_DEFAULT_NEW_MAIL', t(
+"=====  User Information:  =====
+%user_name created on %user_created with email address %user_email and status of%user_status.  The user prefers a timezone of %user_timezone, languange of %user_language and theme of %user_theme.
 
-If you want to check and edit the account go to %uri.
+=====  User Administration:  =====
+%uri
 
-Investigate User:
+=====  Investigate User:  =====
 Yahoo search  %user_email: %yahoo_user 
 Google search %user_email: %google_user
 
 --
-%site");
+%site"));
 
 define('ADVUSER_DEFAULT_MODIFY_MAIL', ADVUSER_DEFAULT_NEW_MAIL);
 
 define('ADVUSER_DEFAULT_NEW_ROLES', NULL);
 
-define('ADVUSER_DEFAULT_NEW_SUBJECT', 'A new user (%username) has just registered on %site.');
+define('ADVUSER_DEFAULT_NEW_SUBJECT', t('%site has a new user (%user_name).'));
 
-define('ADVUSER_DEFAULT_MODIFY_SUBJECT', 'A user (%username) has just modified their account on %site.');
+define('ADVUSER_DEFAULT_MODIFY_SUBJECT', t('%site user (%user_name) modified their account.'));
 
-define('ADVUSER_DEFAULT_NEW_NOTIFY', 1);
+define('ADVUSER_DEFAULT_NEW_NOTIFY', 0);
 
-define('ADVUSER_DEFAULT_MODIFY_NOTIFY', 1);
+define('ADVUSER_DEFAULT_MODIFY_NOTIFY', 0);
 
 define('ADVUSER_DEFAULT_LISTNO', 200);
 
 define('ADVUSER_DEFAULT_PROFILE_FIELDS', NULL);
 
+define('ADVUSER_ADMINISTRATOR_RID', 0);
+
+define('ADVUSER_SUBSTITUTION_TEXT', t('<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, %google_user (search google for user email), %yahoo_user (search yahoo for user email)</em>'));
+
 /**
  * Implementation of hook_perm().
  */
 function advuser_perm() {
-  return array('administer advuser', 'access advuser', 'email users advuser');
+  return array(
+    t('administer advuser'),
+    t('access advuser'),
+    t('send email advuser'),
+    t('receive email advuser'),
+  );
 }
 
 /**
@@ -107,8 +118,8 @@ function advuser_admin_account() {
     array('data' => t('Username'), 'field' => 'u.name'),
     array('data' => t('Status'), 'field' => 'u.status'),
   );
-  $roles = user_roles(1);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  $roles = advuser_user_roles();
+  unset ($roles[ADVUSER_ADMINISTRATOR_RID]);
   if (count($roles)) {
     $header[] = t('Roles');
   }
@@ -157,7 +168,8 @@ function advuser_admin_account() {
   $destination = drupal_get_destination();
 
   $status = array(t('blocked'), t('active'));
-  $roles = user_roles(1);
+  $roles = advuser_user_roles();
+  unset ($roles[ADVUSER_ADMINISTRATOR_RID]);
 
   while ($account = db_fetch_object($result)) {
     $accounts[$account->uid] = '';
@@ -200,8 +212,8 @@ function theme_advuser_admin_account($fo
     array('data' => t('Username'), 'field' => 'u.name'),
     array('data' => t('Status'), 'field' => 'u.status'),
   );
-  $roles = user_roles(1);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  $roles = advuser_user_roles();
+  unset ($roles[ADVUSER_ADMINISTRATOR_RID]);
   if (count($roles)) {
     $header[] = t('Roles');
   }
@@ -225,8 +237,8 @@ function theme_advuser_admin_account($fo
         drupal_render($form['name'][$key]),
         drupal_render($form['status'][$key]),
       );
-      $roles = user_roles(1);
-      unset($roles[DRUPAL_AUTHENTICATED_RID]);
+      $roles = advuser_user_roles();
+      unset ($roles[ADVUSER_ADMINISTRATOR_RID]);
       if (count($roles)) {
         $row[] = drupal_render($form['roles'][$key]);
       }
@@ -369,7 +381,7 @@ function advuser_multiple_email_confirm(
   $form['variables'] = array(
     '#type' => 'markup', 
     '#prefix' => '<div class="advuser-inset-panel">',
-    '#value' => '<strong>Substitution variables</strong> available in subject and email body<br/><em> %username, %site, %uri, %user_email, %google_user (search google for user email), %yahoo_user (search yahoo for user email)</em>',
+    '#value' => ADVUSER_SUBSTITUTION_TEXT,
     '#suffix' => '</div>' 
   );
 
@@ -425,7 +437,9 @@ function advuser_settings() {
 
   $form['advuser_mail']['variables'] = array(
     '#type' => 'markup', 
-    '#value' => '<div class="advuser-inset-panel"><strong>Substitution variables</strong> available in subject and email body<br/><em> %username, %site, %uri, %user_email, %google_user (search google for user email), %yahoo_user (search yahoo for user email)</em></div>'
+    '#prefix' => '<div class="advuser-inset-panel">',
+    '#value' => ADVUSER_SUBSTITUTION_TEXT,
+    '#suffix' => '</div>',
   );
 
   //New User Notification
@@ -480,7 +494,7 @@ function advuser_settings() {
       '#default_value' => variable_get('advuser_listno', ADVUSER_DEFAULT_LISTNO),
     );
     
-  $roles = user_roles(1);
+  $roles = advuser_user_roles();
   $values = array();
   $options = variable_get('advuser_new_roles', ADVUSER_DEFAULT_NEW_ROLES);
   $sel_roles_count = 0;
@@ -547,11 +561,16 @@ function advuser_settings() {
  */
 function _advuser_get_variables(&$user) {
   $variables = array(
-    '%username' => $user->name,
+    '%user_name' => $user->name,
     '%site' => variable_get("site_name", "drupal"), 
     '%uri' => url('user/'. $user->uid, NULL, NULL, TRUE), 
     '%user_email' => $user->mail,
-    /* FUTURE: '%user_signature' => $user->signature, */
+    '%user_status' => $user->status,
+    '%user_theme' => $user->theme,
+    '%user_created' => strftime('%x %X', $user->created),
+    '%user_language' => $user->language,
+    '%user_timezone' => $user->timezone,
+    '%user_signature' => $user->signature,
     '%google_user' => "http:/www.google.com/search?q=%22$user->mail%22",
     '%yahoo_user' => "http://search.yahoo.com/search/?p=%22$user->mail%22", 
   );
@@ -561,8 +580,7 @@ function _advuser_get_variables(&$user) 
 
 /**
  * Construct a db query 'where' clause fragment so we can get a list of users to notify
- * TODO: this needs cleanup.  There should be a way to gather a list of users who are 
- * in roles.  
+ *** TODO: Rewrite to use the newly created "receive email advuser" permission.
  */
 function _advuser_get_roles_query_fragment($roles) {
   if (is_array($roles) ) {
@@ -586,6 +604,7 @@ function _advuser_get_roles_query_fragme
 }
 
 /**
+ *** TODO: Rewrite to use the newly created "receive email advuser" permission.
  * @private
  * Return a list of users to send notification of user changes.
  *
@@ -594,7 +613,7 @@ function _advuser_get_roles_query_fragme
  */
 function _advuser_dbquery_users_to_notify($roles) {
   $role_where = _advuser_get_roles_query_fragment($roles);
-  return db_query('SELECT u.mail, u.name FROM {users} u LEFT JOIN {users_roles} ur on u.uid = ur.uid '. (empty($role_where) ? NULL : 'WHERE '. $role_where) );
+  return empty($role_where) ? FALSE : db_query('SELECT u.mail, u.name FROM {users} u LEFT JOIN {users_roles} ur on u.uid = ur.uid WHERE '. $role_where);
 }
 
 
@@ -706,4 +725,16 @@ function advuser_profile_value($fid, $ui
   return $ret;
 }
 
+/**
+ * User Roles for use in ADVUSER.
+ *
+ * @return array
+ */
+function advuser_user_roles() {
+  $roles = user_roles(1);
+  unset ($roles[DRUPAL_AUTHENTICATED_RID]);
+  $roles[ADVUSER_ADMINISTRATOR_RID] = t('super user (uid = 1)');
+  return $roles;
+}
+
 // vim:ft=php:sts=2:sw=2:ts=2:et:ai:sta:ff=unix
Index: advuser_filters.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/Attic/advuser_filters.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 advuser_filters.inc
--- advuser_filters.inc	24 Mar 2008 16:20:13 -0000	1.1.2.6
+++ advuser_filters.inc	26 Mar 2008 19:45:53 -0000
@@ -303,8 +303,9 @@ function advuser_filters() {
     'form_type' => 'id',
   );
 
-  $roles = user_roles(1);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  $roles = advuser_user_roles();
+  //TODO: Add logic to handle the ADVUSER_ADMINISTRATOR_RID being selected.
+  unset ($roles[ADVUSER_ADMINISTRATOR_RID]);
   if (count($roles)) {
     $filters['user_roles'] = array(
       'title' => t('Role'),
