Fixed bad naming of variable
[mailer.git] / inc / modules / admin / what-list_autopurge.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/26/2004 *
4  * ===================                          Last change: 06/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_autopurge.php                          *
8  * -------------------------------------------------------------------- *
9  * Short description : Find inactive accounts and just list them        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Inaktive Accounts finden und dann auflisten      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Exclude default referral id if set
47 $userExcludeSql = ' ';
48 $excludedUserids = runFilterChain('config_userid_exclusion_sql', array());
49 if (isFilledArray($excludedUserids)) {
50         // Exclude all
51         $userExcludeSql = ' AND `d`.`userid` NOT IN (' . implode(', ', $excludedUserids) . ')';
52 } // END - if
53
54 // Check for all accounts
55 $result = sqlQuery("SELECT
56         `d`.`userid`,
57         `d`.`gender`,
58         `d`.`surname`,
59         `d`.`family`,
60         `d`.`email`,
61         `d`.`joined`,
62         `d`.`last_online`,
63         `d`.`ap_notified`
64 FROM
65         `{?_MYSQL_PREFIX?}_user_data` AS `d`
66 WHERE
67         `d`.`status`='CONFIRMED' AND
68         (UNIX_TIMESTAMP() - `d`.`joined`) >= {?ap_inactive_since?} AND
69         (UNIX_TIMESTAMP() - `d`.`last_online`) >= {?ap_inactive_since?} AND
70         (UNIX_TIMESTAMP() - `d`.`ap_notified`) >= {?ap_inactive_since?}
71         " . runFilterChain('user_exclusion_sql', ' ' . $userExcludeSql) . "
72 ORDER BY
73         `d`.`userid` ASC", __FILE__, __LINE__);
74
75 if (!ifSqlHasZeroNums($result)) {
76         // Ok, we have found some inactive accounts
77         $OUT = '';
78         while ($content = sqlFetchArray($result)) {
79                 // Prepare data for the row template
80                 $content = array(
81                         'userid'      => $content['userid'],
82                         'gender'      => $content['gender'],
83                         'surname'     => $content['surname'],
84                         'family'      => $content['family'],
85                         'email'       => '<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . $content['email'] . '</a>',
86                         'joined'      => generateDateTime($content['joined'], 2),
87                         'last_online' => generateDateTime($content['last_online'], 2),
88                         'ap_notified' => generateDateTime($content['ap_notified'], 2),
89                 );
90
91                 // Load row template
92                 $OUT .= loadTemplate('admin_list_autopurge_row', TRUE, $content);
93         } // END - while
94
95         // Free memory
96         sqlFreeResult($result);
97         $content['rows'] = $OUT;
98
99         // Load main template
100         loadTemplate('admin_list_autopurge', FALSE, $content);
101 } else {
102         // All members are active or you don't have any registered
103         displayMessage('{--ADMIN_AUTOPURGE_ALL_ACTIVE--}');
104 }
105
106 // [EOF]
107 ?>