CronPurgeInactiveUsers() needs access to $bugsys.
[bugdar.git] / includes / cron / awaiting_email_confirmation.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2020 Blue Static
6 || # This program is free software; you can redistribute it and/or modify
7 || # it under the terms of the GNU General Public License as published by
8 || # the Free Software Foundation; version 2 of the License.
9 || #
10 || # This program is distributed in the hope that it will be useful, but
11 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 || # more details.
14 || #
15 || # You should have received a copy of the GNU General Public License along
16 || # with this program; if not, write to the Free Software Foundation, Inc.,
17 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 || ###################################################################
19 \*=====================================================================*/
20
21 require_once('./includes/api_user.php');
22
23 function CronPurgeInactiveUsers()
24 {
25 global $bugsys;
26 $thirty_days_ago = TIMENOW - (60 * 60 * 24 * 30);
27 $inactive_users = bugdar::$db->query("
28 SELECT user.displayname, user.userid, user.email,
29 useractivation.activator, useractivation.dateline
30 FROM " . TABLE_PREFIX . "user AS user
31 LEFT JOIN " . TABLE_PREFIX . "useractivation AS useractivation
32 ON (user.userid = useractivation.userid)
33 WHERE user.usergroupid = 3
34 AND useractivation.dateline <= $thirty_days_ago
35 ");
36 while ($user = $inactive_users->fetch()) {
37 $data = new UserAPI($bugsys);
38 $data->set('userid', $user['userid']);
39 $data->set_condition();
40 $data->delete();
41 }
42 }