65711bcf700fb3a86621091b29dd34e676ed15f1
[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  * -------------------------------------------------------------------- *
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 if (isBegRallyeEnabled()) {
47         // Shall I withdraw now?
48         if (isPostRequestParameterSet('withdraw')) {
49                 // Okay, let's prepare...
50                 $curr = getMonth() - 1;
51                 if (strlen($curr) == 1) $curr = '0' . $curr;
52                 updateConfiguration('last_month', $curr);
53                 loadTemplate('admin_settings_saved', false, '{--ADMIN_BEG_WITHDRAW_PREPARED--}');
54         } // END - if
55
56         // Autopurge installed?
57         $lastOnline = '';
58         if (isExtensionActive('autopurge')) {
59                 // Use last online timestamp to keep inactive members away from here
60                 $lastOnline   = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})";
61         } // END - if
62
63         // Check if at least one is in the active rallye
64         $result = SQL_QUERY("SELECT `userid`, `gender`, `surname`, `family`, `email`, `beg_points`, `last_online`
65 FROM
66         `{?_MYSQL_PREFIX?}_user_data`
67 WHERE
68         `status`='CONFIRMED' AND
69         `beg_points` > 0
70         " . $lastOnline . "
71 ORDER BY
72         `beg_points` DESC,
73         `last_online` DESC,
74         `userid` ASC", __FILE__, __LINE__);
75
76         if (!SQL_HASZERONUMS($result)) {
77                 // List users
78                 $OUT = ''; $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                                 'win1'        => $WIN1,
98                                 'win2'        => $WIN2,
99                                 'cnt'         => $cnt,
100                         );
101
102                         // Load template and add it
103                         $OUT .= loadTemplate('admin_list_beg_rows', true, $content);
104                         $cnt++; $total += $content['beg_points'];
105                 } // END - while
106
107                 $content['rows']  = $OUT;
108                 $content['total'] = $total;
109
110                 // Check if we need to display form or not with manuel withdraw
111                 if (getConfig('last_month') == getMonth()) {
112                         // Load form
113                         $content['withdraw_form'] = loadTemplate('admin_list_beg_form', true);
114                 } else {
115                         // Display message "no manual withdraw possible"
116                         $content['withdraw_form'] = loadTemplate('admin_settings_saved', true, '{--ADMIN_BEG_ALREADY_WITHDRAW--}');
117                 }
118
119                 // Prepare constant for timemark
120                 if (isExtensionActive('autopurge')) {
121                         $content['autopurge_timeout'] = generateDateTime(time() - getApInactiveSince(), 2);
122                 } else {
123                         $content['autopurge_timeout'] = loadTemplate('admin_settings_saved', true, generateExtensionInactiveNotInstalledMessage('autopurge'));
124                 }
125
126                 // Load final template
127                 loadTemplate('admin_list_beg', false, $content);
128         } else {
129                 // No one has joined the begging rallye...
130                 loadTemplate('admin_settings_saved', false, '{--ADMIN_BEG_NO_RALLYE--}');
131         }
132 } else {
133         // Rallye deactivated
134         loadTemplate('admin_settings_saved', false, '{--ADMIN_BEG_RALLYE_DEACTIVATED--}');
135 }
136
137 // [EOF]
138 ?>