RevBomb patch applied (thanks to profi-concept)
[mailer.git] / inc / modules / admin / what-list_beg.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44 // Add description as navigation point
45 ADD_DESCR("admin", __FILE__);
46
47 if (getConfig('beg_rallye') == "Y") {
48         // Shall I withdraw now?
49         if (REQUEST_ISSET_POST(('withdraw'))) {
50                 // Okay, let's prepare...
51                 $curr = date("m", time()) - 1;
52                 if (strlen($curr) == 1) $curr = "0".$curr;
53                 UPDATE_CONFIG("last_month", $curr);
54                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_BEG_WITHDRAW_PREPARED'));
55         } // END - if
56
57         // Autopurge installed?
58         $lastOnline = "%s"; $ONLINE = "";
59         if (EXT_IS_ACTIVE("autopurge")) {
60                 // Use last online timestamp to keep inactive members away from here
61                 $lastOnline   = " AND last_online >= (UNIX_TIMESTAMP() - %s)";
62                 $ONLINE = getConfig('ap_inactive_since');
63         } // END - if
64
65         // Check if at least one is in the active rallye
66         $result = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, beg_points, last_online
67 FROM `{!_MYSQL_PREFIX!}_user_data`
68 WHERE `status`='CONFIRMED' AND beg_points > 0".$lastOnline."
69 ORDER BY beg_points DESC, last_online DESC, userid",
70          array($ONLINE), __FILE__, __LINE__);
71
72         if (SQL_NUMROWS($result) > 0) {
73                 // List users
74                 $OUT = "";$SW = 2; $cnt = 1; $total = 0;
75                 while ($content = SQL_FETCHARRAY($result)) {
76                         // Init variables
77                         $WIN1 = ""; $WIN2 = "";
78                         if ($cnt <= getConfig('beg_ranks')) {
79                                 // Maybe he can win his active beg?
80                                 $WIN1 = "<strong>";
81                                 $WIN2 = "</strong>";
82                         } // END - if
83
84                         // Prepare content
85                         // @TODO Rewrite templates so s/fname will be replaced by surname/family
86                         // @TODO to shorten this block. Please also do so with uid->userid
87                         $content = array(
88                                 'uid'    => $content['userid'],
89                                 'email'  => CREATE_EMAIL_LINK($content['email'], "user_data"),
90                                 'gender' => TRANSLATE_GENDER($content['gender']),
91                                 'sname'  => $content['surname'],
92                                 'fname'  => $content['family'],
93                                 'turbo'  => TRANSLATE_COMMA($content['beg_points']),
94                                 'last'   => MAKE_DATETIME($content['last_online'], "2"),
95                                 'sw'     => $SW,
96                                 'win1'   => $WIN1,
97                                 'win2'   => $WIN2,
98                                 'cnt'    => $cnt,
99                         );
100
101                         // Load template and add it
102                         $OUT .= LOAD_TEMPLATE("admin_list_beg_rows", true, $content);
103                         $SW = 3 - $SW; $cnt++; $total += $content['beg_points'];
104                 }
105                 define('__BEG_ROWS', $OUT);
106                 define('__TOTAL', TRANSLATE_COMMA($total));
107
108                 // Check if we need to display form or not with manuel withdraw
109                 if (getConfig('last_month') == date("m", time())) {
110                         // Load form
111                         define('__BEG_WITHDRAW_FORM', LOAD_TEMPLATE("admin_list_beg_form", true));
112                 } else {
113                         // Display message "no manual withdraw possible"
114                         define('__BEG_WITHDRAW_FORM', "<div class=\"admin_failed\">{--ADMIN_BEG_ALREADY_WITHDRAW--}</div>");
115                 }
116
117                 // Prepare constant for timemark
118                 if (EXT_IS_ACTIVE("autopurge")) {
119                         define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - getConfig('ap_inactive_since'), "2"));
120                 } else {
121                         define('__AUTOPURGE_TIMEOUT', sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), "autopurge"));
122                 }
123
124                 // Load final template
125                 LOAD_TEMPLATE("admin_list_beg");
126         } else {
127                 // No one has joined the begging rallye...
128                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_BEG_NO_RALLYE'));
129         }
130 } else {
131         // Rallye deactivated
132         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_BEG_RALLYE_DEACTIVATED'));
133 }
134
135 //
136 ?>