2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/09/2008 *
4 * =================== Last change: 09/09/2008 *
6 * -------------------------------------------------------------------- *
7 * File : what-refback.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Refback setup *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Refback-Einstellungen *
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 // User is not logged in
44 redirectToIndexMemberOnlyModule();
47 // Is the refback system enabled?
48 if (getConfig('refback_enabled') != 'Y') {
50 loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DISABLED'));
55 // Add description as navigation point
56 addMenuDescription('member', __FILE__);
58 if ((!isExtensionActive('refback')) && (!isAdmin())) {
59 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('refback'));
63 // Was the form submitted?
64 if ((isPostRequestElementSet('edit')) && (isPostRequestElementSet('id'))) {
65 // Okay, has the user entered some values?
66 if (isPostRequestElementSet('percents')) {
67 // Revert german commta for testing
68 $percents = convertCommaToDot(postRequestElement('percents'));
71 if ((($percents >= getConfig('refback_min_perc')) || (round($percents) == '0')) && ($percents <= getConfig('refback_max_perc'))) {
72 // Change ref-back for this direct id
73 $status = updateMemberRefbackPercents(postRequestElement('id'), postRequestElement('percents'));
76 if (isset($status['ok'])) {
78 loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DONE'));
79 } elseif (isset($status['message'])) {
80 // Something went wrong with error message
81 loadTemplate('admin_settings_saved', false, sprintf(getMessage('MEMBER_REFBACK_ERROR_MESSAGE'), $status['message']));
84 loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_ERROR_EMPTY_MESSAGE'));
87 // Percents out-of-bounds ;-)
88 loadTemplate('admin_settings_saved', false, sprintf(getMessage('MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS'), getConfig('refback_min_perc'), getConfig('refback_max_perc')));
93 // Read data from refback table
94 $content = getArrayFromUserRefbackData(postRequestElement('id'));
97 $content['refback'] = translateComma($content['refback']);
98 $content['min'] = translateComma(getConfig('refback_min_perc').".0");
99 $content['max'] = translateComma(getConfig('refback_max_perc').".0");
101 // Load form for editing
102 loadTemplate('member_refback_edit', false, $content);
106 // Load all referal levels
107 $result = SQL_QUERY_ESC("SELECT
110 `{?_MYSQL_PREFIX?}_refdepths` AS r
115 array(getMemberId()), __FILE__, __LINE__);
117 // Are there some entries? (Shall be!)
118 if (SQL_NUMROWS($result) > 0) {
121 while ($content = SQL_FETCHARRAY($result)) {
127 // Check for users ref in this level
128 foreach (getArrayFromRefbackUserRefs(getMemberId(), $content['level']) as $refRow) {
129 // Not-deleted account is default
131 if (is_null($refRow['status'])) $deleted = true;
133 // Add/"translate" more content
135 $refRow['points'] = translateComma($refRow['points']);
136 $refRow['refback'] = translateComma($refRow['refback']);
137 $refRow['status'] = translateUserStatus($refRow['status']);
138 if (empty($refRow['nickname'])) $refRow['nickname'] = '---';
142 $rows .= loadTemplate('member_refback_list_row_deleted', true, $refRow);
144 $rows .= loadTemplate('member_refback_list_row', true, $refRow);
147 // Count this ref and switch color
152 // Remember the content
153 $content['counter'] = translateComma($counter);
154 $content['percents'] = translateComma($content['percents']);
155 $content['rows'] = $rows;
157 // Load level template
158 $OUT .= loadTemplate('member_refback_list_level', true, $content);
161 // Load main template
162 loadTemplate('member_refback_list', false, $OUT);
165 loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_NO_ENTRIES'));
169 SQL_FREERESULT($result);