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