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 * -------------------------------------------------------------------- *
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 // User is not logged in
43 redirectToIndexMemberOnlyModule();
44 } elseif (!isRefbackEnabled()) {
46 displayMessage('{--MEMBER_REFBACK_DISABLED--}');
52 // Add description as navigation point
53 addYouAreHereLink('member', __FILE__);
55 if ((!isExtensionActive('refback')) && (!isAdmin())) {
56 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=refback%}');
60 // Was the form submitted?
61 if ((isFormSent('edit')) && (isPostRequestParameterSet('id'))) {
62 // Okay, has the user entered some values?
63 if (isPostRequestParameterSet('percents')) {
64 // Revert german commta for testing
65 $percents = convertCommaToDot(postRequestParameter('percents'));
68 if ((($percents >= getConfig('refback_min_perc')) || (round($percents) == 0)) && ($percents <= getConfig('refback_max_perc'))) {
69 // Change ref-back for this direct id
70 $status = updateMemberRefbackPercents(postRequestParameter('id'), postRequestParameter('percents'));
73 if (isset($status['ok'])) {
75 displayMessage('{--MEMBER_REFBACK_DONE--}');
76 } elseif (isset($status['message'])) {
77 // Something went wrong with error message
78 displayMessage('{%message,MEMBER_REFBACK_ERROR_MESSAGE=' . $status['message'] . '%}');
81 displayMessage('{--MEMBER_REFBACK_ERROR_EMPTY_MESSAGE--}');
84 // Percents out-of-bounds ;-)
85 displayMessage('{--MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS--}');
90 // Read data from refback table
91 $content = getArrayFromUserRefbackData(postRequestParameter('id'));
93 // Load form for editing
94 loadTemplate('member_refback_edit', false, $content);
98 // Load all referal levels
99 $result = SQL_QUERY('SELECT
102 `{?_MYSQL_PREFIX?}_refdepths` AS r
106 r.level ASC', __FILE__, __LINE__);
108 // Are there some entries? (Shall be!)
109 if (!SQL_HASZERONUMS($result)) {
112 while ($content = SQL_FETCHARRAY($result)) {
115 $content['counter'] = 0;
117 // Check for users ref in this level
118 foreach (getArrayFromRefbackUserRefs(getMemberId(), $content['level']) as $refRow) {
119 // Not-deleted account is default
121 if (is_null($refRow['status'])) $deleted = true;
123 // Add/"translate" more content
124 // @TODO UNUSED: $refRow['status'] = translateUserStatus($refRow['status']);
125 $refRow['joined'] = generateDateTime($refRow['joined'], '3');
128 if ($deleted === true) {
129 $rows .= loadTemplate('member_refback_list_row_deleted', true, $refRow);
131 $rows .= loadTemplate('member_refback_list_row', true, $refRow);
134 // Count this ref and switch color
135 $content['counter']++;
138 // Remember the content
139 $content['rows'] = $rows;
141 // Load level template
142 $OUT .= loadTemplate('member_refback_list_level', true, $content);
145 // Load main template
146 loadTemplate('member_refback_list', false, $OUT);
149 displayMessage('{--MEMBER_REFBACK_NO_ENTRIES--}');
153 SQL_FREERESULT($result);