More use of EL, fix for admin links
[mailer.git] / inc / modules / admin / what-list_beg.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/22/2005 *
4  * ===================                          Last change: 10/22/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_beg.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : List members in begging-rallye                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder in Bettel-Rallye 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 }
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (getConfig('beg_rallye') == 'Y') {
49         // Shall I withdraw now?
50         if (isPostRequestParameterSet('withdraw')) {
51                 // Okay, let's prepare...
52                 $curr = date('m', time()) - 1;
53                 if (strlen($curr) == 1) $curr = '0' . $curr;
54                 updateConfiguration('last_month', $curr);
55                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_WITHDRAW_PREPARED'));
56         } // END - if
57
58         // Autopurge installed?
59         $lastOnline = '';
60         if (isExtensionActive('autopurge')) {
61                 // Use last online timestamp to keep inactive members away from here
62                 $lastOnline   = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})";
63         } // END - if
64
65         // Check if at least one is in the active rallye
66         $result = SQL_QUERY("SELECT `userid`, `gender`, `surname`, `family`, `email`, `beg_points`, `last_online`
67 FROM
68         `{?_MYSQL_PREFIX?}_user_data`
69 WHERE
70         `status`='CONFIRMED' AND beg_points > 0".$lastOnline."
71 ORDER BY
72         `beg_points` DESC,
73         `last_online` DESC,
74         `userid` ASC", __FILE__, __LINE__);
75
76         if (SQL_NUMROWS($result) > 0) {
77                 // List users
78                 $OUT = '';$SW = 2; $cnt = 1; $total = '0';
79                 while ($content = SQL_FETCHARRAY($result)) {
80                         // Init variables
81                         $WIN1 = ''; $WIN2 = '';
82
83                         // Maybe he can win his active beg?
84                         if ($cnt <= getConfig('beg_ranks')) {
85                                 // Mark him
86                                 $WIN1 = '<strong>';
87                                 $WIN2 = '</strong>';
88                         } // END - if
89
90                         // Prepare content
91                         $content = array(
92                                 'userid'      => $content['userid'],
93                                 'email'       => generateEmailLink($content['email'], 'user_data'),
94                                 'gender'      => $content['gender'],
95                                 'turbo'       => $content['beg_points'],
96                                 'last_online' => generateDateTime($content['last_online'], 2),
97                                 'sw'          => $SW,
98                                 'win1'        => $WIN1,
99                                 'win2'        => $WIN2,
100                                 'cnt'         => $cnt,
101                         );
102
103                         // Load template and add it
104                         $OUT .= loadTemplate('admin_list_beg_rows', true, $content);
105                         $SW = 3 - $SW; $cnt++; $total += $content['beg_points'];
106                 } // END - while
107
108                 $content['rows']  = $OUT;
109                 $content['total'] = translateComma($total);
110
111                 // Check if we need to display form or not with manuel withdraw
112                 if (getConfig('last_month') == date('m', time())) {
113                         // Load form
114                         $content['withdraw_form'] = loadTemplate('admin_list_beg_form', true);
115                 } else {
116                         // Display message "no manual withdraw possible"
117                         $content['withdraw_form'] = loadTemplate('admin_settings_saved', true, '<div class="admin_failed">{--ADMIN_BEG_ALREADY_WITHDRAW--}</div>');
118                 }
119
120                 // Prepare constant for timemark
121                 if (isExtensionActive('autopurge')) {
122                         $content['autopurge_timeout'] = generateDateTime(time() - getConfig('ap_inactive_since'), 2);
123                 } else {
124                         $content['autopurge_timeout'] = loadTemplate('admin_settings_saved', true, getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'autopurge'));
125                 }
126
127                 // Load final template
128                 loadTemplate('admin_list_beg', false, $content);
129         } else {
130                 // No one has joined the begging rallye...
131                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_NO_RALLYE'));
132         }
133 } else {
134         // Rallye deactivated
135         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_RALLYE_DEACTIVATED'));
136 }
137
138 // [EOF]
139 ?>