654f7eccca0a90e6a3598fdfeb5bb7f17af8bf4b
[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 - 2011 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 addYouAreHereLink('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                 displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}');
54         } // END - if
55
56         // Init variable
57         $lastOnline = '';
58
59         // Autopurge installed?
60         if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) {
61                 // Use last online timestamp to keep inactive members away from here
62                 $lastOnline   = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?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
71         `beg_points` > 0
72         " . $lastOnline . "
73 ORDER BY
74         `beg_points` DESC,
75         `last_online` DESC,
76         `userid` ASC", __FILE__, __LINE__);
77
78         if (!SQL_HASZERONUMS($result)) {
79                 // List users
80                 $OUT = ''; $count = 1; $total = '0';
81                 while ($content = SQL_FETCHARRAY($result)) {
82                         // Init variables
83                         $WIN1 = ''; $WIN2 = '';
84
85                         // Maybe he can win his active beg?
86                         if ($count <= getBegRanks()) {
87                                 // Mark him
88                                 $WIN1 = '<strong>';
89                                 $WIN2 = '</strong>';
90                         } // END - if
91
92                         // Prepare content
93                         $content = array(
94                                 'userid'      => $content['userid'],
95                                 'email'       => generateEmailLink($content['email'], 'user_data'),
96                                 'gender'      => $content['gender'],
97                                 'turbo'       => $content['beg_points'],
98                                 'last_online' => generateDateTime($content['last_online'], 2),
99                                 'win1'        => $WIN1,
100                                 'win2'        => $WIN2,
101                                 'cnt'         => $count,
102                         );
103
104                         // Load template and add it
105                         $OUT .= loadTemplate('admin_list_beg_rows', true, $content);
106                         $count++; $total += $content['beg_points'];
107                 } // END - while
108
109                 $content['rows']  = $OUT;
110                 $content['total'] = $total;
111
112                 // Check if we need to display form or not with manuel withdraw
113                 if (getLastMonth() == getMonth()) {
114                         // Load form
115                         $content['withdraw_form'] = loadTemplate('admin_list_beg_form', true);
116                 } else {
117                         // Display message "no manual withdraw possible"
118                         $content['withdraw_form'] = displayMessage('{--ADMIN_BEG_ALREADY_WITHDRAW--}', true);
119                 }
120
121                 // Prepare constant for timemark
122                 if (isExtensionActive('autopurge')) {
123                         $content['autopurge_timeout'] = generateDateTime(time() - getApInactiveSince(), 2);
124                 } else {
125                         $content['autopurge_timeout'] = displayMessage(generateExtensionInactiveNotInstalledMessage('autopurge'), true);
126                 }
127
128                 // Load final template
129                 loadTemplate('admin_list_beg', false, $content);
130         } else {
131                 // No one has joined the begging rallye...
132                 displayMessage('{--ADMIN_BEG_NO_RALLYE--}');
133         }
134 } else {
135         // Rallye deactivated
136         displayMessage('{--ADMIN_BEG_RALLYE_DEACTIVATED--}');
137 }
138
139 // [EOF]
140 ?>