2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 - 2009 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')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
47 if (getConfig('beg_rallye') == 'Y') {
48 // Shall I withdraw now?
49 if (isPostRequestElementSet(('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 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_WITHDRAW_PREPARED'));
57 // Autopurge installed?
58 $lastOnline = "%s"; $ONLINE = '';
59 if (isExtensionActive('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 = '';
79 // Maybe he can win his active beg?
80 if ($cnt <= getConfig('beg_ranks')) {
88 'userid' => $content['userid'],
89 'email' => generateEmailLink($content['email'], 'user_data'),
90 'gender' => translateGender($content['gender']),
91 'surname' => $content['surname'],
92 'family' => $content['family'],
93 'turbo' => translateComma($content['beg_points']),
94 'last_online' => generateDateTime($content['last_online'], 2),
101 // Load template and add it
102 $OUT .= loadTemplate('admin_list_beg_rows', true, $content);
103 $SW = 3 - $SW; $cnt++; $total += $content['beg_points'];
106 $content['rows'] = $OUT;
107 $content['total'] = translateComma($total);
109 // Check if we need to display form or not with manuel withdraw
110 if (getConfig('last_month') == date('m', time())) {
112 $content['withdraw_form'] = loadTemplate('admin_list_beg_form', true);
114 // Display message "no manual withdraw possible"
115 $content['withdraw_form'] = loadTemplate('admin_settings_saved', true, '<div class="admin_failed">{--ADMIN_BEG_ALREADY_WITHDRAW--}</div>');
118 // Prepare constant for timemark
119 if (isExtensionActive('autopurge')) {
120 $content['autopurge_timeout'] = generateDateTime(time() - getConfig('ap_inactive_since'), 2);
122 $content['autopurge_timeout'] = loadTemplate('admin_settings_saved', true, getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'autopurge'));
125 // Load final template
126 loadTemplate('admin_list_beg', false, $content);
128 // No one has joined the begging rallye...
129 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_NO_RALLYE'));
132 // Rallye deactivated
133 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_BEG_RALLYE_DEACTIVATED'));