Code style changed, ext-user continued:
[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 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://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 (isPostRequestElementSet('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
67         `userid`,
68         `email`,
69         `beg_points`,
70         `last_online`
71 FROM
72         `{?_MYSQL_PREFIX?}_user_data`
73 WHERE
74         `status`='CONFIRMED' AND
75         `beg_points` > 0
76         " . $lastOnline . "
77         " . runFilterChain('user_exclusion_sql', ' ') . "
78 ORDER BY
79         `beg_points` DESC,
80         `last_online` DESC,
81         `userid` ASC", __FILE__, __LINE__);
82
83         if (!SQL_HASZERONUMS($result)) {
84                 // List users
85                 $OUT = ''; $count = 1; $total = '0';
86                 while ($content = SQL_FETCHARRAY($result)) {
87                         // Init variables
88                         $WIN1 = '';
89                         $WIN2 = '';
90
91                         // Maybe he can win his active beg?
92                         if ($count <= getBegRanks()) {
93                                 // Mark him
94                                 $WIN1 = '<strong>';
95                                 $WIN2 = '</strong>';
96                         } // END - if
97
98                         // Prepare content
99                         $row = array(
100                                 'userid'      => $content['userid'],
101                                 'email'       => generateEmailLink($content['email'], 'user_data'),
102                                 'last_online' => generateDateTime($content['last_online'], '2'),
103                                 'win1'        => $WIN1,
104                                 'win2'        => $WIN2,
105                                 'count'       => $count,
106                         );
107
108                         // Load template and add it
109                         $OUT .= loadTemplate('admin_list_beg_rows', TRUE, $row);
110                         $count++;
111                         $total += $content['beg_points'];
112                 } // END - while
113
114                 $content['rows']  = $OUT;
115                 $content['total_points'] = $total;
116
117                 // Check if we need to display form or not with manuel withdraw
118                 if (getLastMonth() == getMonth()) {
119                         // Load form
120                         $content['withdraw_form'] = loadTemplate('admin_list_beg_form', TRUE);
121                 } else {
122                         // Display message "no manual withdraw possible"
123                         $content['withdraw_form'] = displayMessage('{--ADMIN_BEG_ALREADY_WITHDRAW--}', TRUE);
124                 }
125
126                 // Prepare constant for timemark
127                 if (isExtensionActive('autopurge')) {
128                         $content['autopurge_timeout'] = generateDateTime(time() - getApInactiveSince(), 2);
129                 } else {
130                         $content['autopurge_timeout'] = displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=autopurge%}', TRUE);
131                 }
132
133                 // Load final template
134                 loadTemplate('admin_list_beg', FALSE, $content);
135         } else {
136                 // No one has joined the begging rallye...
137                 displayMessage('{--ADMIN_BEG_NO_RALLYE--}');
138         }
139 } else {
140         // Rallye deactivated
141         displayMessage('{--ADMIN_BEG_RALLYE_DEACTIVATED--}');
142 }
143
144 // [EOF]
145 ?>