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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (!isMember()) {
42 redirectToIndexMemberOnlyModule();
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
48 // Extension ext-user is highly required
49 if ((!isExtensionActive('user')) && (!isAdmin())) {
50 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
54 // Query for referral levels and percents
55 $result_depths = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__);
58 $numDepths = SQL_NUMROWS($result_depths);
60 // Add many more rows for the login/turbo/ref/order bonus
61 // @TODO Should we rewrite this to a filter?
62 if (isExtensionActive('bonus')) {
63 // Extension ext-bonus is there, okay
64 if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $numDepths += 6;
65 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $numDepths += 4;
67 // Not installed ext-bonus
71 // Remember row count in constant
72 $content['rowspan'] = ($numDepths * 2 + 15);
74 // Initialize array elements
75 $content['part_points'] = '0.00000';
76 $content['part_referrals'] = '0';
77 $content['part_locked'] = '0.00000';
78 $content['part_order'] = '0.00000';
79 $content['part_locked_order'] = '0.00000';
81 // And output variable
85 while ($data = SQL_FETCHARRAY($result_depths)) {
86 // Init points and counter here
87 $content['counter'] = '0';
88 $content['points'] = '0.00000';
89 $content['order_points'] = '0.00000';
90 $content['locked_points'] = '0.00000';
91 $content['locked_order_points'] = '0.00000';
94 $content = merge_array($content, $data);
96 // Default for referral level > 0
97 $depth = 'p.`ref_depth`=%s';
98 if (is_null($content['level'])) {
99 $depth = 'p.`ref_depth` IS NULL';
102 // Load referral points
103 $result_points = SQL_QUERY_ESC('SELECT
104 ' . getAllPointColumns('p.', ',') . '
107 `{?_MYSQL_PREFIX?}_user_points` AS p
109 `{?_MYSQL_PREFIX?}_refsystem` AS r
111 p.`userid`=r.`userid` AND
112 p.`ref_depth`=r.`level`
119 convertZeroToNull($content['level'])
120 ), __FILE__, __LINE__);
122 // Is there an entry?
123 if (SQL_NUMROWS($result_points) == 1) {
125 $content = merge_array($content, SQL_FETCHARRAY($result_points));
127 // Add locked-/points
128 $content['part_points'] += $content['points'];
129 $content['part_locked'] += $content['locked_points'];
131 // For these columns, ext-order must be installed as well
132 if (isExtensionInstalled('order')) {
133 $content['part_order'] += $content['order_points'];
134 $content['part_locked_order'] += $content['locked_order_points'];
137 // Add referral counter
138 $content['part_referrals'] += $content['counter'];
142 SQL_FREERESULT($result_points);
145 $OUT .= loadTemplate('member_points_row', TRUE, $content);
149 SQL_FREERESULT($result_depths);
152 $content['userid'] = getMemberId();
154 // Put rows to constant for the main template
155 $content['rows'] = $OUT;
157 // Fixes a bug when there is no bonus extension installed
158 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) {
159 setConfigEntry('bonus_active', 'X');
162 // Members shall see no special rows here
163 $content['special_rows'] = '';
165 // Display login bonus and turbo-click bonus
166 if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) {
167 // Total bonus points
168 $content['bonus_total_points'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats');
171 $content['special_rows'] = loadTemplate('member_points_bonus_rows', TRUE, $content);
172 } elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) {
173 // Bonus active rallye deactivated
174 $content['special_rows'] = loadTemplate('member_points_bonus_disabled', TRUE);
175 } elseif ((isAdmin()) && (isExtensionInstalledAndOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
176 // Please upgrade your bonus extension to v0.2.2 or newer!
177 $content['special_rows'] = loadTemplate('member_points_upgrade');
180 // Load final template
181 if (isExtensionActive('user')) {
182 // Load template when required extension is there
183 loadTemplate('member_points', FALSE, $content);
184 } elseif (isAdmin()) {
186 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
189 displayMessage('{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}');
192 // Is ext-payout installed?
193 if (isExtensionActive('payout')) {
194 // Payput extension is installed and active so we can check if the user has enougth points
195 outputPayoutList($content['part_points'] - getUserData('used_points'));