From 9dc09fef9ba33af4d9be661e9e57fe1927a79f6c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 27 Jan 2010 23:48:28 -0500 Subject: [PATCH] Add a script to remove inactive users awaiting email confirmation. * admin/purge_inactive.php --- admin/purge_inactive.php | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 admin/purge_inactive.php diff --git a/admin/purge_inactive.php b/admin/purge_inactive.php new file mode 100644 index 0000000..7ea9202 --- /dev/null +++ b/admin/purge_inactive.php @@ -0,0 +1,114 @@ +set_focus('tab', 'users', null); + +if (!can_perform('canadminusers')) +{ + admin_login(); +} + +$thirty_days_ago = time() - (60 * 60 * 24 * 30); +$query = " + SELECT user.displayname, user.userid, user.email, useractivation.activator, useractivation.dateline FROM " . TABLE_PREFIX . "user AS user + LEFT JOIN " . TABLE_PREFIX . "useractivation AS useractivation + ON (user.userid = useractivation.userid) + WHERE user.usergroupid = 3 + OR useractivation.dateline <= $thirty_days_ago"; + +// ################################################################### + +if (empty($_REQUEST['do'])) +{ + $_REQUEST['do'] = 'modify'; +} + +// ################################################################### + +if ($_REQUEST['do'] == 'kill') +{ + $users = $db->query($query); + while ($user = $db->fetch_array($users)) + { + $data = new UserAPI($bugsys); + $data->set('userid', $user['userid']); + $data->set_condition(); + $data->delete(); + } + + $admin->redirect('purge_inactive.php'); +} + +// ################################################################### + +if ($_REQUEST['do'] == 'delete') +{ + $admin->page_confirm(T('Are you sure you want to remove all users who within the past thirty days have not verified their accounts via email?'), 'purge_inactive.php', 'kill', array()); +} + +// ################################################################### + +if ($_REQUEST['do'] == 'modify') +{ + NavLinks::usersAdd(); + + LoadPaginationFramework(); + $pagination->setBitProcessor('AdminPageNavigatorBitCallback'); + $pagination->setNavigatorProcessor('AdminPageNavigatorCallback'); + + $admin->page_start(T('Inactive Users')); + $admin->table_start(); + $admin->table_head(T('Users Awaiting Email Confirmation for more than 30 Days'), 4); + $admin->table_column_head(array(T('Display Name'), T('Email'), T('User ID'), T('Actions'))); + + $count = $db->query_first("SELECT COUNT(*) AS count FROM ($query) AS inactive"); + $pagination->setTotal($count['count']); + $pagination->splitPages(); + + $users = $db->query(" + $query + ORDER BY userid ASC LIMIT " . $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage() + ); + while ($user = $db->fetch_array($users)) + { + $admin->row_multi_item(array( + $user['displayname'] => 'l', + $user['email'] => 'c', + $user['userid'] => 'c', + '[' . T('Edit') . ']' => 'c' + )); + } + + $admin->row_tfoot('[Remove All]', 4); + + $admin->table_end(); + + $admin->page_code($pagination->constructPageNav('purge_inactive.php')); + + $admin->page_end(); +} -- 2.43.5