--- inactive_user.module 2004/09/15 01:13:51 1.1 +++ inactive_user.module 2005/01/06 22:30:06 @@ -1,5 +1,6 @@ timestamp > time() - 604800) { + $u = db_fetch_object(db_query('SELECT changed, name from {users} WHERE uid = %d', $uid)); + if ($u->changed > time() - 604800) { // user activity in last week, remove from inactivity table db_query('DELETE FROM {inactive_users} WHERE uid = %d', $uid); watchdog('user', "recent user activity: '$u->name' removed from inactivity list", l(t('edit user'), "admin/user/edit/$uid")); @@ -65,7 +66,7 @@ // notify administrator of inactive user accounts if ($notify_time = variable_get('inactive_user_notify_admin', 0)) { - $result = db_query('SELECT uid, name, mail, timestamp FROM {users} WHERE timestamp < (%d - %d)', time(), $notify_time); + $result = db_query('SELECT uid, name, mail, changed FROM {users} WHERE changed < (%d - %d)', 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))) { db_query('UPDATE {inactive_users} SET notified_admin = 1 WHERE uid = %d', $user->uid); @@ -73,7 +74,7 @@ // must create a new row @db_query('INSERT INTO {inactive_users} (uid, notified_admin) VALUES(%d, 1)', $user->uid); } - $user_list .= "$user->name ($user->mail) last active on ". format_date($user->timestamp, 'large'). ".\n"; + $user_list .= "$user->name ($user->mail) last active on ". format_date($user->changed, 'large'). ".\n"; } } if ($user_list) { @@ -84,7 +85,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 timestamp < (%d - %d)', time(), $notify_time); + $result = db_query('SELECT * FROM {users} WHERE changed < (%d - %d)', 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))) { db_query('UPDATE {inactive_users} SET notified_user = 1 WHERE uid = %d', $user->uid); @@ -100,7 +101,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 timestamp < (%d - %d - %d)', time(), $warn_time, $block_time); + $result = db_query('SELECT * FROM {users} WHERE status != 0 AND changed < (%d - %d - %d)', 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))) { db_query('UPDATE {inactive_users} SET warned_user_block_timestamp = %d WHERE uid = %d', time() + $warn_time, $user->uid); @@ -115,7 +116,7 @@ // automatically block users if ($block_time = variable_get('inactive_user_auto_block', 0)) { - $result = db_query('SELECT * FROM {users} WHERE timestamp < (%d - %d) AND status != 0', time(), $block_time); + $result = db_query('SELECT * FROM {users} WHERE changed < (%d - %d) AND status != 0', 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()))) { @@ -140,7 +141,7 @@ if (!db_affected_rows()) { @db_query('INSERT INTO {inactive_users} (uid, notified_admin_block) VALUES(%d, 1)', $user->uid); } - $user_list .= "$user->name ($user->mail) last active on ". format_date($user->timestamp, 'large'). ".\n"; + $user_list .= "$user->name ($user->mail) last active on ". format_date($user->changed, 'large'). ".\n"; } } } @@ -154,7 +155,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 timestamp < (%d - %d - %d)', time(), $warn_time, $delete_time); + $result = db_query('SELECT * FROM {users} WHERE changed < (%d - %d - %d)', 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))) { if (variable_get('inactive_user_preserve_content', 1) && _inactive_user_with_content($user->uid)) { @@ -177,7 +178,7 @@ // automatically delete users if ($delete_time = variable_get('inactive_user_auto_delete', 0)) { - $result = db_query('SELECT * FROM {users} WHERE timestamp < %d - %d', time(), $delete_time); + $result = db_query('SELECT * FROM {users} WHERE changed < %d - %d', 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)))) { if (variable_get('inactive_user_preserve_content', 1) && _inactive_user_with_content($user->uid)) { @@ -197,7 +198,7 @@ _inactive_user_mail(t('[%sitename] Account removed', array('%sitename' => variable_get('site_name', 'drupal'))), variable_get('inactive_user_delete_notify_text', _inactive_user_mail_text('delete_notify_text')), $delete_time, $user, NULL); } if (variable_get('inactive_user_notify_delete_admin', 0)) { - $user_list .= "$user->name ($user->mail) last active on ". format_date($user->timestamp, 'large'). ".\n"; + $user_list .= "$user->name ($user->mail) last active on ". format_date($user->changedk, 'large'). ".\n"; } watchdog('user', "user '$user->name' deleted due to inactivity"); } @@ -253,7 +254,7 @@ elseif (isset($user->uid)) { // user email $to = $user->mail; - $variables = array('%username' => "$user->name", '%useremail' => "$user->mail", '%lastaccess' => format_date($user->timestamp, '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' => format_date($user->changed, 'custom', 'M d, Y'), '%period' => _format_interval($period), '%sitename' => variable_get('site_name', 'drupal'), '%siteurl' => "$base_url"); } else { // no valid email to send