Add a script to remove inactive users awaiting email confirmation.
Add a script to remove inactive users awaiting email confirmation.
* 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 @@
+<?php
+/*=====================================================================*\
+|| ###################################################################
+|| # Bugdar
+|| # Copyright (c) 2010 Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version 2 of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+require_once('./global.php');
+require_once('./includes/api_user.php');
+require_once('./includes/class_api_error.php');
+
+APIError(array(new API_Error_Handler($admin), 'admin_error'));
+
+NavLinks::usersPages();
+$navigator->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',
+ '<a href="user.php?do=edit&userid=' . $user['userid'] . '">[' . T('Edit') . ']</a>' => 'c'
+ ));
+ }
+
+ $admin->row_tfoot('<a href="purge_inactive.php?do=delete">[Remove All]</a>', 4);
+
+ $admin->table_end();
+
+ $admin->page_code($pagination->constructPageNav('purge_inactive.php'));
+
+ $admin->page_end();
+}