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__);
54 $numDepths = SQL_NUMROWS($result_depths);
56 // Add many more rows for the login/turbo/ref/order bonus
57 // @TODO Should we rewrite this to a filter?
58 if (!isExtensionActive('bonus')) $numDepths += 1;
59 if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $numDepths += 6;
60 if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $numDepths += 4;
62 // Remember row count in constant
63 $content['rowspan'] = ($numDepths * 2 + 15);
66 $content['total_points'] = '0';
67 $content['total_referals'] = '0';
68 $content['total_locked'] = '0';
72 while ($data = SQL_FETCHARRAY($result_depths)) {
74 $content = merge_array($content, $data);
76 // Initialize array elements
77 $content['counter'] = '0';
78 $content['points'] = '0.00000';
79 $content['locked_points'] = '0.00000';
81 // Load referal points
82 $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
85 bigintval($content['level'])
86 ), __FILE__, __LINE__);
88 // Do we have an entry?
89 if (SQL_NUMROWS($result_points) == 1) {
91 $content = merge_array($content, SQL_FETCHARRAY($result_points));
94 $content['total_points'] += $content['points'];
95 $content['total_locked'] += $content['locked_points'];
99 SQL_FREERESULT($result_points);
101 // Load referal counts
102 $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1",
105 bigintval($content['level'])
106 ), __FILE__, __LINE__);
108 // Do we have an entry?
109 if (SQL_NUMROWS($result_refs) == 1) {
111 $content = merge_array($content, SQL_FETCHARRAY($result_refs));
113 // Add them to total refs
114 $content['total_referals'] += $content['counter'];
118 SQL_FREERESULT($result_refs);
121 $OUT .= loadTemplate('member_points_row', true, $content);
125 SQL_FREERESULT($result_depths);
127 // Put rows to constant for the main template
128 $content['rows'] = $OUT;
130 // Remember several values in constants
131 $content['total_points'] = ($content['total_points'] - getUserData('used_points'));
133 // Fixes a bug when there is no bonus extension installed
134 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X');
136 // Members shall see no special rows here
137 $content['special_rows'] = '';
139 // Display login bonus and turbo-click bonus
140 if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) {
141 // Total bonus points
142 $content['total'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats');
145 $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
146 } elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) {
147 // Bonus active rallye deactivated
148 $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true);
149 } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
150 // Please upgrade your bonus extension to v0.2.2 or newer!
151 $content['special_rows'] = loadTemplate('member_points_upgrade');
154 // Load final template
155 if (isExtensionActive('user')) {
156 // Load template when required extension is there
157 loadTemplate('member_points', false, $content);
158 } elseif (isAdmin()) {
160 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
163 loadTemplate('admin_settings_saved', false, '{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}');
166 if (isExtensionActive('payout')) {
167 // Payput extension is installed and active so we can check if the user has enougth points
168 outputPayoutList($content['total_points'] - getUserData('used_points'));