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 - 2015 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 // 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')) && (isPostRequestElementSet('id'))) {
62 // Okay, has the user entered some values?
63 if (isPostRequestElementSet('refback_percents')) {
64 // Revert german commta for testing
65 $percents = convertCommaToDot(postRequestElement('refback_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(postRequestElement('id'), postRequestElement('refback_percents'), postRequestElement('refback_notice'));
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=' . getMessage($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(postRequestElement('id'));
93 // Load form for editing
94 loadTemplate('member_edit_refback', FALSE, $content);
98 // Load all referral levels
99 $result = sqlQuery('SELECT
103 `{?_MYSQL_PREFIX?}_refdepths` AS `r`
107 `r`.`level` ASC', __FILE__, __LINE__);
109 // Are there some entries? (Shall be!)
110 if (!ifSqlHasZeroNumRows($result)) {
113 while ($content = sqlFetchArray($result)) {
116 $content['counter'] = 0;
118 // Check for users ref in this level
119 foreach (getArrayFromRefbackUserRefs(getMemberId(), $content['level']) as $refRow) {
120 // Not-deleted account is default
122 if (is_null($refRow['status'])) {
126 // Add/"translate" more content
127 $refRow['joined'] = generateDateTime($refRow['joined'], '3');
130 if ($deleted === TRUE) {
131 $rows .= loadTemplate('member_list_refback_deleted_row', TRUE, $refRow);
133 $rows .= loadTemplate('member_list_refback_row', TRUE, $refRow);
136 // Count this ref and switch color
137 $content['counter']++;
140 // Remember the content
141 $content['rows'] = $rows;
143 // Load level template
144 $OUT .= loadTemplate('member_list_refback_level', TRUE, $content);
147 // Load main template
148 loadTemplate('member_list_refback', FALSE, $OUT);
151 displayMessage('{--MEMBER_REFBACK_NO_ENTRIES--}');
155 sqlFreeResult($result);