Index: inactive_user.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/inactive_user/inactive_user.module,v retrieving revision 1.7.2.4 diff -u -r1.7.2.4 inactive_user.module --- inactive_user.module 9 Jun 2008 16:04:31 -0000 1.7.2.4 +++ inactive_user.module 1 Jul 2008 21:35:36 -0000 @@ -246,7 +246,7 @@ // notify administrator of inactive user accounts if ($notify_time = variable_get('inactive_user_notify_admin', 0)) { - $result = db_query('SELECT uid, name, mail, access, created FROM {users} WHERE access < (%d - %d) AND uid <> 1', time(), $notify_time); + $result = db_query('SELECT uid, name, mail, access, created FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d)) OR (login = 0 AND created < (%d - %d))) AND uid <> 1', time(), $notify_time, time(), $notify_time); while ($user = db_fetch_object($result)) { if ($user->uid && !db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE uid = %d AND notified_admin = 1', $user->uid)) && ($user->created < (time() - $notify_time))) { db_query('UPDATE {inactive_users} SET notified_admin = 1 WHERE uid = %d', $user->uid); @@ -265,7 +265,7 @@ // notify users that their account has been inactive if ($notify_time = variable_get('inactive_user_notify', 0)) { - $result = db_query('SELECT * FROM {users} WHERE access < (%d - %d) AND status <> 0 AND uid <> 1', time(), $notify_time); + $result = db_query('SELECT * FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d)) OR (login = 0 AND created < (%d - %d))) AND status <> 0 AND uid <> 1', time(), $notify_time, time(), $notify_time); while ($user = db_fetch_object($result)) { if ($user->uid && !db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE notified_user = 1 AND uid = %d', $user->uid)) && ($user->created < (time() - $notify_time))) { db_query('UPDATE {inactive_users} SET notified_user = 1 WHERE uid = %d', $user->uid); @@ -281,7 +281,7 @@ // warn users when they are about to be blocked if (($warn_time = variable_get('inactive_user_auto_block_warn', 0)) && ($block_time = variable_get('inactive_user_auto_block', 0))) { - $result = db_query('SELECT * FROM {users} WHERE status <> 0 AND access < (%d - %d - %d) AND uid <> 1', time(), $warn_time, $block_time); + $result = db_queryd('SELECT * FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d - %d)) OR (login = 0 AND created < (%d - %d - %d))) AND status <> 0 AND uid <> 1', time(), $warn_time, $block_time, time(), $warn_time, $block_time); while ($user = db_fetch_object($result)) { if ($user->uid && !db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE uid = %d AND warned_user_block_timestamp > 0', $user->uid)) && ($user->created < (time() - $warn_time - $block_time))) { db_query('UPDATE {inactive_users} SET warned_user_block_timestamp = %d WHERE uid = %d', time() + $warn_time, $user->uid); @@ -296,7 +296,7 @@ // automatically block users if ($block_time = variable_get('inactive_user_auto_block', 0)) { - $result = db_query('SELECT * FROM {users} WHERE access < (%d - %d) AND status <> 0 AND uid <> 1', time(), $block_time); + $result = db_query('SELECT * FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d)) OR (login = 0 AND created < (%d - %d))) AND status <> 0 AND uid <> 1', time(), $block_time, time(), $block_time); while ($user = db_fetch_object($result)) { // don't block user yet if we sent a warning and it hasn't expired if ($user->uid && db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE uid = %d AND warned_user_block_timestamp < %d', $user->uid, time())) && ($user->created < (time() - $block_time))) { @@ -335,7 +335,7 @@ // warn users when they are about to be deleted if (($warn_time = variable_get('inactive_user_auto_delete_warn', 0)) && ($delete_time = variable_get('inactive_user_auto_delete', 0))) { - $result = db_query('SELECT * FROM {users} WHERE access < (%d - %d - %d)', time(), $warn_time, $delete_time); + $result = db_query('SELECT * FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d - %d)) OR (login = 0 AND created < (%d - %d - %d))) AND uid <> 1', time(), $warn_time, $delete_time, time(), $warn_time, $delete_time); while ($user = db_fetch_object($result)) { if ($user->uid && !db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE uid = %d AND warned_user_delete_timestamp > 0', $user->uid)) && ($user->created < (time() - $warn_time - $delete_time))) { if (variable_get('inactive_user_preserve_content', 1) && _inactive_user_with_content($user->uid)) { @@ -358,7 +358,7 @@ // automatically delete users if ($delete_time = variable_get('inactive_user_auto_delete', 0)) { - $result = db_query('SELECT * FROM {users} WHERE access < (%d - %d) AND uid <> 1', time(), $delete_time); + $result = db_query('SELECT * FROM {users} WHERE ((access <> 0 AND login <> 0 AND access < (%d - %d)) OR (login = 0 AND created < (%d - %d))) AND uid <> 1', time(), $delete_time, time(), $delete_time); while ($user = db_fetch_object($result)) { if ($user->uid && ((variable_get('inactive_user_auto_delete_warn', 0) && db_fetch_object(db_query('SELECT uid FROM {inactive_users} WHERE uid = %d AND warned_user_delete_timestamp < %d AND protected <> 1', $user->uid, time()))) || (!variable_get('inactive_user_auto_delete_warn', 0))) && ($user->created < (time() - $delete_time))) { if (variable_get('inactive_user_preserve_content', 1) && _inactive_user_with_content($user->uid)) { @@ -427,18 +427,30 @@ global $base_url; if ($user_list) { $to = _inactive_user_admin_mail(); - $variables = array('%period' => _format_interval($period), '%sitename' => variable_get('site_name', 'drupal'), '%siteurl' => "$base_url", "%userlist" => "$user_list"); + $variables = array( + '%period' => _format_interval($period), + '%sitename' => variable_get('site_name', 'drupal'), + '%siteurl' => $base_url, + "%userlist" => $user_list + ); } elseif (isset($user->uid)) { $to = $user->mail; - $variables = array('%username' => "$user->name", '%useremail' => "$user->mail", '%lastaccess' => format_date($user->access, 'custom', 'M d, Y'), '%period' => _format_interval($period), '%sitename' => variable_get('site_name', 'drupal'), '%siteurl' => "$base_url"); + $variables = array( + '%username' => $user->name, + '%useremail' => $user->mail, + '%lastaccess' => empty($user->access) ? t('never') : format_date($user->access, 'custom', 'M d, Y'), + '%period' => _format_interval($period), + '%sitename' => variable_get('site_name', 'drupal'), + '%siteurl' => $base_url + ); } if ($to) { $from = variable_get('site_mail', ini_get('sendmail_from')); $headers = array( 'Reply-to' => $from, 'Return-path' => "<$from>", - 'Errors-to' => $from, + 'Errors-to' => $from ); $recipients = explode(',', $to); foreach ($recipients as $recipient) {