2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/19/2003 *
4 * =============== Last change: 11/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-points.php *
8 * -------------------------------------------------------------------- *
9 * Short description : All your collected points... *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Ihrer gesammelten Punkte *
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')) {
42 } elseif (!isMember()) {
43 redirectToIndexMemberOnlyModule();
46 // Add description as navigation point
47 addMenuDescription('member', __FILE__);
49 // Query for referal levels and percents
50 $result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
51 $depths = SQL_NUMROWS($result_depths);
53 // Add many more rows for the login/turbo/ref/order bonus
54 // @TODO Should we rewrite this to a filter?
55 if (!isExtensionActive('bonus')) $depths += 1;
56 if (getExtensionVersion('bonus') >= '0.2.2') $depths += 6;
57 if (getExtensionVersion('bonus') >= '0.4.4') $depths += 4;
59 // Remember row count in constant
60 $content['rowspan'] = ($depths*2+15);
63 $totalPoints = 0; $TREF = 0; $TLOCK = 0; $OUT = '';
66 while ($data = SQL_FETCHARRAY($result_depths)) {
68 $content = merge_array($content, $data);
70 // Initialize ref-count
73 // Load referal points
74 $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
75 if (SQL_NUMROWS($result_points) == 1) {
76 list($points, $locked) = SQL_FETCHROW($result_points);
77 // Also count locked points
78 $totalPoints += $points; $TLOCK += $locked;
80 $points = '0.00000'; $locked = '0.00000';
84 SQL_FREERESULT($result_points);
86 // Load referal counts
87 $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1",
88 array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
89 if (SQL_NUMROWS($result_refs) == 1) {
90 list($REFS) = SQL_FETCHROW($result_refs);
97 SQL_FREERESULT($result_refs);
99 // Transfer data to array for template
101 'level' => $content['level'],
102 'percents' => translateComma($content['percents']),
103 'points' => translateComma($points),
104 'refs' => translateComma($REFS),
108 $OUT .= loadTemplate('member_points_row', true, $row);
112 SQL_FREERESULT($result_depths);
114 // Put rows to constant for the main template
115 $content['rows'] = $OUT;
117 // Fetch user account
118 if (!fetchUserData(getMemberId())) {
119 // Something really bad happened
120 debug_report_bug('User account ' . getMemberId() . ' not found.');
123 // Initialize variables
124 $CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
126 // Only user >= v0.1.2: Fetch confirmed mails counter
127 if (getExtensionVersion('user') >= '0.1.2') {
129 $CONFIRMED = getUserData('mails_confirmed');
131 if (getExtensionVersion('user') >= '0.1.4') {
132 $SENT = getUserData('emails_sent');
133 $RECEIVED = getUserData('emails_received');
136 // Please update the user extension if you see 3 dashes
137 if (empty($SENT)) $SENT = '---';
138 if (empty($RECEIVED)) $RECEIVED = '---';
144 // If TLOCK is 0 add 3 zeros for floating
145 if ($TLOCK == 0) $TLOCK = '0.00000';
147 // Remember several values in constants
148 $content['used'] = translateComma(getUserData('used_points'));
149 $content['sum'] = translateComma($totalPoints - getUserData('used_points'));
150 $content['tref'] = $TREF;
151 $content['tlock'] = translateComma($TLOCK);
153 // Fixes a bug when there is no bonus extension installed
154 if (isExtensionOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', "X");
156 // Members shall see no special rows here
157 $content['special_rows'] = '';
159 // Display login bonus and turbo-click bonus
160 if ((getExtensionVersion('bonus') >= '0.2.2') && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) {
161 // Fetch some data and init others (to avoid a notice here)
162 $content['login'] = getUserData('login_bonus');
163 $content['turbo'] = getUserData('turbo_bonus');
164 $content['ref'] = '0.00000';
165 $content['order'] = '0.00000';
166 $content['stats'] = '0.00000';
168 // Get more data if ext-bonus is newer
169 if (getExtensionVersion('bonus') >= '0.4.4') {
170 $content['ref'] = getUserData('bonus_ref');
171 $content['order'] = getUserData('bonus_order');
172 $content['stats'] = getUserData('bonus_stats');
175 // Total bonus points
176 $content['ttotal'] = translateComma($content['turbo'] + $content['login'] + $content['ref'] + $content['order'] + $content['stats']);
178 // Translate more data
179 $content['turbo'] = translateComma($content['turbo']);
180 $content['login'] = translateComma($content['login']);
182 if (getExtensionVersion('bonus') >= '0.4.4') {
183 // Add referal, stats and order bonys
184 $content['ref'] = translateComma($content['ref']);
185 $content['order'] = translateComma($content['order']);
186 $content['stats'] = translateComma($content['stats']);
190 $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
191 } elseif (getConfig('bonus_active') != 'Y') {
192 // Bonus active rallye deactivated
193 $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true);
194 } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
195 // Please upgrade your bonus extension to v0.2.2 or newer!
196 $content['special_rows'] = loadTemplate('member_points_upgrade');
199 // Remeber values for the final template
200 $content['receive'] = $RECEIVED;
201 $content['pay'] = getUserData('ref_payout');
202 $content['confirmed'] = $CONFIRMED;
203 $content['sent'] = $SENT;
205 // Load final template
206 if (isExtensionActive('user')) {
207 // Load template when required extension is there
208 loadTemplate('member_points', false, $content);
209 } elseif (isAdmin()) {
211 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
214 loadTemplate('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE'));
217 if (isExtensionActive('payout')) {
218 // Payput extension is installed and active so we can check if the user has enougth points
219 outputPayoutList(convertCommaToDot(($totalPoints - getUserData('used_points'))));