A lot code rewritten:
[mailer.git] / inc / modules / member / what-beg2.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-beg2.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : List all begging members                         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle moeglichen Gewinner der Bettel-Rallye aufl. *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } elseif (!isMember()) {
44         redirectToIndexMemberOnlyModule();
45 }
46
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
49
50 if ((!isExtensionActive('beg')) && (!isAdmin())) {
51         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('beg'));
52         return;
53 } // END - if
54
55 // Autopurge installed?
56 $lastOnline = '%s';
57 $ONLINE = '';
58
59 if (isExtensionActive('autopurge')) {
60         // Use last online timestamp to keep inactive members away from here
61         $lastOnline   = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})";
62 } // END - if
63
64 // Let's check if there are some points left we can 'pay'...
65 $result = SQL_QUERY_ESC("SELECT
66         `userid`, `beg_points` AS points, `last_online`
67 FROM
68         `{?_MYSQL_PREFIX?}_user_data`
69 WHERE
70         `beg_points` > 0 AND
71         `status`='CONFIRMED'
72         " . $lastOnline . "
73 ORDER BY
74         `beg_points` DESC,
75         `last_online` DESC,
76         `userid` ASC
77 LIMIT {?beg_ranks?}",
78         array(
79                 $ONLINE
80         ), __FILE__, __LINE__);
81
82 // Reset temporary variable and check for users
83 $OUT = '';
84 if (SQL_NUMROWS($result) > 0) {
85         // Load our winners...
86         $cnt = 1;
87         while ($content = SQL_FETCHARRAY($result)) {
88                 // Prepare data for the template
89                 $content = array(
90                         'cnt'         => $cnt,
91                         'userid'      => $content['userid'],
92                         'points'      => $content['points'],
93                         'last_online' => generateDateTime($content['last_online'], 2),
94                 );
95
96                 // Load row template
97                 $OUT .= loadTemplate('member_list_beg_row', true, $content);
98
99                 // Count one up
100                 $cnt++;
101         } // END - while
102 } else {
103         // No one is interested in our "active rallye" ! :-(
104         $OUT = loadTemplate('member_beg_404', true);
105 }
106
107 // Prepare content
108 $content['rows'] = $OUT;
109
110 // Free memory
111 SQL_FREERESULT($result);
112
113 // Load final template
114 loadTemplate('member_list_beg', false, $content);
115
116 // [EOF]
117 ?>