2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
43 } elseif (!isMember()) {
44 redirectToIndexMemberOnlyModule();
47 // Add description as navigation point
48 addMenuDescription('member', __FILE__);
50 // Query for referal levels and percents
51 $result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
52 $depths = SQL_NUMROWS($result_depths);
54 // Add many more rows for the login/turbo/ref/order bonus
55 // @TODO Should we rewrite this to a filter?
56 if (!isExtensionActive('bonus')) $depths += 1;
57 if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $depths += 6;
58 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $depths += 4;
60 // Remember row count in constant
61 $content['rowspan'] = ($depths*2+15);
70 while ($data = SQL_FETCHARRAY($result_depths)) {
72 $content = merge_array($content, $data);
74 // Initialize array elements
75 $content['counter'] = '0';
76 $content['points'] = '0.00000';
77 $content['locked_points'] = '0.00000';
79 // Load referal points
80 $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
83 bigintval($content['level'])
84 ), __FILE__, __LINE__);
86 // Do we have an entry?
87 if (SQL_NUMROWS($result_points) == 1) {
89 $content = merge_array($content, SQL_FETCHARRAY($result_points));
92 $totalPoints += $content['points'];
93 $totalLocked += $content['locked_points'];
97 SQL_FREERESULT($result_points);
99 // Load referal counts
100 $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1",
103 bigintval($content['level'])
104 ), __FILE__, __LINE__);
106 // Do we have an entry?
107 if (SQL_NUMROWS($result_refs) == 1) {
109 $content = merge_array($content, SQL_FETCHARRAY($result_refs));
111 // Add them to total refs
112 $totalReferals += $content['counter'];
116 SQL_FREERESULT($result_refs);
118 // Transfer data to array for template
120 'level' => $content['level'],
121 'percents' => translateComma($content['percents']),
122 'points' => translateComma($content['points']),
123 'refs' => translateComma($content['counter']),
127 $OUT .= loadTemplate('member_points_row', true, $row);
131 SQL_FREERESULT($result_depths);
133 // Put rows to constant for the main template
134 $content['rows'] = $OUT;
136 // Initialize variables
137 $CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
139 // Only user >= v0.1.2: Fetch confirmed mails counter
140 if (isExtensionInstalledAndNewer('user', '0.1.2')) {
142 $CONFIRMED = getUserData('mails_confirmed');
144 if (isExtensionInstalledAndNewer('user', '0.1.4')) {
145 $SENT = getUserData('emails_sent');
146 $RECEIVED = getUserData('emails_received');
149 // Please update the user extension if you see 3 dashes
150 if (empty($SENT)) $SENT = '---';
151 if (empty($RECEIVED)) $RECEIVED = '---';
157 // If TLOCK is 0 add 3 zeros for floating
158 if ($totalLocked == '0') $totalLocked = '0.00000';
160 // Remember several values in constants
161 $content['sum'] = translateComma($totalPoints - getUserData('used_points'), false);
162 $content['tref'] = translateComma($totalReferals);
163 $content['tlock'] = translateComma($totalLocked);
165 // Fixes a bug when there is no bonus extension installed
166 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X');
168 // Members shall see no special rows here
169 $content['special_rows'] = '';
171 // Display login bonus and turbo-click bonus
172 if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) {
173 // Fetch some data and init others (to avoid a notice here)
174 $content['login'] = getUserData('login_bonus');
175 $content['turbo'] = getUserData('turbo_bonus');
176 $content['ref'] = '0.00000';
177 $content['order'] = '0.00000';
178 $content['stats'] = '0.00000';
180 // Get more data if ext-bonus is newer
181 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) {
182 $content['ref'] = getUserData('bonus_ref');
183 $content['order'] = getUserData('bonus_order');
184 $content['stats'] = getUserData('bonus_stats');
187 // Total bonus points
188 $content['ttotal'] = translateComma($content['turbo'] + $content['login'] + $content['ref'] + $content['order'] + $content['stats'], false);
190 // Translate more data
191 $content['turbo'] = translateComma($content['turbo']);
192 $content['login'] = translateComma($content['login']);
194 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) {
195 // Add referal, stats and order bonys
196 $content['ref'] = translateComma($content['ref']);
197 $content['order'] = translateComma($content['order']);
198 $content['stats'] = translateComma($content['stats']);
202 $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
203 } elseif ((isExtensionActive('bonus')) && (getConfig('bonus_active') != 'Y')) {
204 // Bonus active rallye deactivated
205 $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true);
206 } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
207 // Please upgrade your bonus extension to v0.2.2 or newer!
208 $content['special_rows'] = loadTemplate('member_points_upgrade');
211 // Remeber values for the final template
212 $content['receive'] = translateComma($RECEIVED);
213 $content['confirmed'] = translateComma($CONFIRMED);
214 $content['sent'] = translateComma($SENT);
216 // Load final template
217 if (isExtensionActive('user')) {
218 // Load template when required extension is there
219 loadTemplate('member_points', false, $content);
220 } elseif (isAdmin()) {
222 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
225 loadTemplate('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE'));
228 if (isExtensionActive('payout')) {
229 // Payput extension is installed and active so we can check if the user has enougth points
230 outputPayoutList(convertCommaToDot(($totalPoints - getUserData('used_points'))));