69404cd4371d373a366448276859d2ae3a537110
[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, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.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 addMenuDescription('admin', __FILE__);
45
46 // Exclude default referal id if set
47 // @TODO Rewrite those lines to filter
48 $EXCLUDE_LIST = '';
49 if (getConfig('def_refid') > 0)                $EXCLUDE_LIST .= ' AND d.userid != {?def_refid?}';
50 if (isExtensionActive('beg'))                  $EXCLUDE_LIST .= ' AND d.userid != {?beg_userid?}';
51 if (isExtensionActive('bonus'))                $EXCLUDE_LIST .= ' AND d.userid != {?bonus_userid?}';
52 if (isExtensionActive('doubler'))              $EXCLUDE_LIST .= ' AND d.userid != {?doubler_userid?}';
53 if (isExtensionInstalledAndNewer('holiday', '0.1.3')) $EXCLUDE_LIST .= " AND d.holiday_active='N'";
54
55 // Check for all accounts
56 $result = SQL_QUERY("SELECT
57         d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
58 FROM
59         `{?_MYSQL_PREFIX?}_user_data` AS d
60 WHERE
61         d.`status`='CONFIRMED' AND
62         d.joined < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
63         d.last_online < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
64         d.ap_notified < (UNIX_TIMESTAMP() - {?ap_inactive_since?})
65         ".$EXCLUDE_LIST."
66 ORDER BY
67         d.userid ASC", __FILE__, __LINE__);
68
69 if (!SQL_HASZERONUMS($result)) {
70         // Ok, we have found some inactive accounts
71         $OUT = '';
72         while ($content = SQL_FETCHARRAY($result)) {
73                 // Prepare data for the row template
74                 $content = array(
75                         'userid'      => $content['userid'],
76                         'gender'      => $content['gender'],
77                         'surname'     => $content['surname'],
78                         'family'      => $content['family'],
79                         'email'       => '<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . $content['email'] . '</a>',
80                         'joined'      => generateDateTime($content['joined'], 2),
81                         'last_online' => generateDateTime($content['last_online'], 2),
82                         'notified'    => generateDateTime($content['ap_notified'], 2),
83                 );
84
85                 // Load row template
86                 $OUT .= loadTemplate('admin_list_autopurge_row', true, $content);
87         } // END - while
88
89         // Free memory
90         SQL_FREERESULT($result);
91         $content['rows'] = $OUT;
92
93         // Load main template
94         loadTemplate('admin_list_autopurge', false, $content);
95 } else {
96         // All members are active or you don't have any registered
97         loadTemplate('admin_settings_saved', false, '{--ADMIN_AUTOPURGE_ALL_ACTIVE--}');
98 }
99
100 // [EOF]
101 ?>