2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/22/2005 *
4 * ================ Last change: 10/22/2005 *
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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
44 // Add description as navigation point
45 ADD_DESCR('admin', __FILE__);
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 updateConfiguration('last_month', $curr);
54 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_BEG_WITHDRAW_PREPARED'));
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');
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__);
72 if (SQL_NUMROWS($result) > 0) {
74 $OUT = '';$SW = 2; $cnt = 1; $total = 0;
75 while ($content = SQL_FETCHARRAY($result)) {
77 $WIN1 = ''; $WIN2 = '';
78 if ($cnt <= getConfig('beg_ranks')) {
79 // Maybe he can win his active beg?
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
88 'uid' => $content['userid'],
89 'email' => generateMemberEmailLink($content['email'], "user_data"),
90 'gender' => translateGender($content['gender']),
91 'sname' => $content['surname'],
92 'fname' => $content['family'],
93 'turbo' => translateComma($content['beg_points']),
94 'last' => generateDateTime($content['last_online'], '2'),
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'];
105 define('__BEG_ROWS', $OUT);
106 define('__TOTAL', translateComma($total));
108 // Check if we need to display form or not with manuel withdraw
109 if (getConfig('last_month') == date('m', time())) {
111 define('__BEG_WITHDRAW_FORM', LOAD_TEMPLATE("admin_list_beg_form", true));
113 // Display message "no manual withdraw possible"
114 define('__BEG_WITHDRAW_FORM', "<div class=\"admin_failed\">{--ADMIN_BEG_ALREADY_WITHDRAW--}</div>");
117 // Prepare constant for timemark
118 if (EXT_IS_ACTIVE('autopurge')) {
119 define('__AUTOPURGE_TIMEOUT', generateDateTime(time() - getConfig('ap_inactive_since'), '2'));
121 define('__AUTOPURGE_TIMEOUT', sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'autopurge'));
124 // Load final template
125 LOAD_TEMPLATE("admin_list_beg");
127 // No one has joined the begging rallye...
128 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_BEG_NO_RALLYE'));
131 // Rallye deactivated
132 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_BEG_RALLYE_DEACTIVATED'));