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 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.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 // Query for referal levels and percents
49 $result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
52 $numDepths = 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')) $numDepths += 1;
57 if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $numDepths += 6;
58 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $numDepths += 4;
60 // Remember row count in constant
61 $content['rowspan'] = ($numDepths * 2 + 15);
63 // Initialize array elements
64 $content['part_points'] = '0.00000';
65 $content['part_referals'] = '0';
66 $content['part_locked'] = '0.00000';
67 $content['part_order'] = '0.00000';
68 $content['part_locked_order'] = '0.00000';
69 $content['counter'] = '0';
70 $content['points'] = '0.00000';
71 $content['order_points'] = '0.00000';
72 $content['locked_points'] = '0.00000';
73 $content['locked_order_points'] = '0.00000';
75 // And output variable
79 while ($data = SQL_FETCHARRAY($result_depths)) {
81 $content = merge_array($content, $data);
83 // Load referal points
84 $result_points = SQL_QUERY_ESC("SELECT
88 p.`locked_order_points`,
91 `{?_MYSQL_PREFIX?}_user_points` AS p
93 `{?_MYSQL_PREFIX?}_refsystem` AS r
95 p.`userid`=r.`userid` AND
96 p.`ref_depth`=r.`level`
103 bigintval($content['level'])
104 ), __FILE__, __LINE__);
106 // Do we have an entry?
107 if (SQL_NUMROWS($result_points) == 1) {
109 $content = merge_array($content, SQL_FETCHARRAY($result_points));
112 $content['part_points'] += $content['points'];
113 $content['part_order'] += $content['order_points'];
114 $content['part_locked'] += $content['locked_points'];
115 $content['part_locked_order'] += $content['locked_order_points'];
116 $content['part_referals'] += $content['counter'];
120 SQL_FREERESULT($result_points);
123 $OUT .= loadTemplate('member_points_row', true, $content);
127 SQL_FREERESULT($result_depths);
129 // Put rows to constant for the main template
130 $content['rows'] = $OUT;
132 // Remember several values in constants
133 $content['total_points'] = $content['part_points'] - getUserData('used_points') + $content['part_order'];
135 // Fixes a bug when there is no bonus extension installed
136 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) {
137 setConfigEntry('bonus_active', 'X');
140 // Members shall see no special rows here
141 $content['special_rows'] = '';
143 // Display login bonus and turbo-click bonus
144 if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) {
145 // Total bonus points
146 $content['bonus_total_points'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats');
149 $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
150 } elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) {
151 // Bonus active rallye deactivated
152 $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true);
153 } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
154 // Please upgrade your bonus extension to v0.2.2 or newer!
155 $content['special_rows'] = loadTemplate('member_points_upgrade');
158 // Load final template
159 if (isExtensionActive('user')) {
160 // Load template when required extension is there
161 loadTemplate('member_points', false, $content);
162 } elseif (isAdmin()) {
164 displayMessage(generateExtensionInactiveNotInstalledMessage('user'));
167 displayMessage('{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}');
170 if (isExtensionActive('payout')) {
171 // Payput extension is installed and active so we can check if the user has enougth points
172 outputPayoutList($content['part_points'] - getUserData('used_points'));