Deprecated variables for templates removed, mor EL-rewrites, getMessage() rewritten:
[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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 // Exclude default referal id if set
49 // @TODO Rewrite those lines to filter
50 $EXCLUDE_LIST = '';
51 if (getConfig('def_refid') > 0) {
52         $EXCLUDE_LIST = ' AND d.userid != {?def_refid?}';
53 } // END - if
54
55 // Check for more extensions
56 if (isExtensionActive('beg'))                  $EXCLUDE_LIST .= ' AND d.userid != {?beg_userid?}';
57 if (isExtensionActive('bonus'))                $EXCLUDE_LIST .= ' AND d.userid != {?bonus_userid?}';
58 if (isExtensionActive('doubler'))              $EXCLUDE_LIST .= ' AND d.userid != {?doubler_userid?}';
59 if (isExtensionInstalledAndNewer('holiday', '0.1.3')) $EXCLUDE_LIST .= " AND d.holiday_active='N'";
60
61 // Check for all accounts
62 $result = SQL_QUERY("SELECT
63         d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
64 FROM
65         `{?_MYSQL_PREFIX?}_user_data` AS d
66 WHERE
67         d.`status`='CONFIRMED' AND
68         d.joined < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
69         d.last_online < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
70         d.ap_notified < (UNIX_TIMESTAMP() - {?ap_inactive_since?})
71         ".$EXCLUDE_LIST."
72 ORDER BY
73         d.userid ASC", __FILE__, __LINE__);
74
75 if (SQL_NUMROWS($result) > 0) {
76         // Ok, we have found some inactive accounts
77         $OUT = ''; $SW = 2;
78         while ($content = SQL_FETCHARRAY($result)) {
79                 // Prepare data for the row template
80                 $content = array(
81                         'sw'          => $SW,
82                         'userid'      => $content['userid'],
83                         'gender'      => $content['gender'],
84                         'surname'     => $content['surname'],
85                         'family'      => $content['family'],
86                         'email'       => '<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . $content['email'] . '</a>',
87                         'joined'      => generateDateTime($content['joined'], 2),
88                         'last_online' => generateDateTime($content['last_online'], 2),
89                         'notified'    => generateDateTime($content['ap_notified'], 2),
90                 );
91
92                 // Load row template
93                 $OUT .= loadTemplate('admin_list_autopurge_row', true, $content);
94                 $SW = 3 - $SW;
95         }
96
97         // Free memory
98         SQL_FREERESULT($result);
99         $content['rows'] = $OUT;
100
101         // Load main template
102         loadTemplate('admin_list_autopurge', false, $content);
103 } else {
104         // All members are active or you don't have any registered
105         loadTemplate('admin_settings_saved', false, '{--ADMIN_AUTOPURGE_ALL_ACTIVE--}');
106 }
107
108 // [EOF]
109 ?>