<?php
/************************************************************************
- * MXChange v0.2.1 Start: 09/09/2008 *
- * ================ Last change: 09/09/2008 *
+ * Mailer v0.2.1-FINAL Start: 09/09/2008 *
+ * =================== Last change: 09/09/2008 *
* *
* -------------------------------------------------------------------- *
* File : what-refback.php *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Refback-Einstellungen *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
- * For more information visit: http://www.mxchange.org *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
+ * For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-} elseif (!IS_MEMBER()) {
+ exit();
+} elseif (!isMember()) {
// User is not logged in
- LOAD_URL("modules.php?module=index");
-} elseif ((!EXT_IS_ACTIVE("refback")) && (!IS_ADMIN())) {
- // Extension "refback" is not active
- ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "refback");
- return;
-}
+ redirectToIndexMemberOnlyModule();
+} elseif (!isRefbackEnabled()) {
+ // Output message
+ displayMessage('{--MEMBER_REFBACK_DISABLED--}');
+
+ // Abort here
+ return FALSE;
+} // END - if
// Add description as navigation point
-ADD_DESCR("member", basename(__FILE__));
+addYouAreHereLink('member', __FILE__);
+
+if ((!isExtensionActive('refback')) && (!isAdmin())) {
+ displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=refback%}');
+ return;
+} // END - if
// Was the form submitted?
-if ((isset($_POST['edit'])) && (isset($_POST['id']))) {
+if ((isFormSent('edit')) && (isPostRequestElementSet('id'))) {
// Okay, has the user entered some values?
- if (isset($_POST['percents'])) {
- // Change ref-back for this direct id
- $status = REFBACK_CHANGE_MEMBER_PERCENTS($_POST['id'], $_POST['percents']);
-
- // Check status
- if (isset($status['ok'])) {
- // No message found
- LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_DONE);
- } elseif (isset($status['message'])) {
- // Something went wrong with error message
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(MEMBER_REFBACK_ERROR_MESSAGE, $status['message']));
+ if (isPostRequestElementSet('refback_percents')) {
+ // Revert german commta for testing
+ $percents = convertCommaToDot(postRequestElement('refback_percents'));
+
+ // Validate percents
+ if ((($percents >= getConfig('refback_min_perc')) || (round($percents) == 0)) && ($percents <= getConfig('refback_max_perc'))) {
+ // Change ref-back for this direct id
+ $status = updateMemberRefbackPercents(postRequestElement('id'), postRequestElement('refback_percents'), postRequestElement('refback_notice'));
+
+ // Check status
+ if (isset($status['ok'])) {
+ // No message found
+ displayMessage('{--MEMBER_REFBACK_DONE--}');
+ } elseif (isset($status['message'])) {
+ // Something went wrong with error message
+ displayMessage('{%message,MEMBER_REFBACK_ERROR_MESSAGE=' . getMessage($status['message']) . '%}');
+ } else {
+ // No message found
+ displayMessage('{--MEMBER_REFBACK_ERROR_EMPTY_MESSAGE--}');
+ }
} else {
- // No message found
- LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_ERROR_EMPTY_MESSAGE);
+ // Percents out-of-bounds ;-)
+ displayMessage('{--MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS--}');
}
// Insert line
- OUTPUT_HTML("<br />");
} else {
// Read data from refback table
- $content = GET_USER_REF_ENTRY($_POST['id']);
-
- // Translate comma
- $content['refback'] = TRANSLATE_COMMA($content['refback']);
+ $content = getArrayFromUserRefbackData(postRequestElement('id'));
// Load form for editing
- LOAD_TEMPLATE("member_refback_edit", false, $content);
+ loadTemplate('member_edit_refback', FALSE, $content);
}
} // END - if
-// Load all referal levels
-$result = SQL_QUERY_ESC("SELECT r.level, r.percents
-FROM "._MYSQL_PREFIX."_refdepths AS r
-WHERE r.level > 0
-ORDER BY r.level ASC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+// Load all referral levels
+$result = sqlQuery('SELECT
+ `r`.`level`,
+ `r`.`percents`
+FROM
+ `{?_MYSQL_PREFIX?}_refdepths` AS `r`
+WHERE
+ `r`.`level` > 0
+ORDER BY
+ `r`.`level` ASC', __FILE__, __LINE__);
// Are there some entries? (Shall be!)
-if (SQL_NUMROWS($result) > 0) {
+if (!ifSqlHasZeroNums($result)) {
// List all levels
- $OUT = "";
- while ($content = SQL_FETCHARRAY($result)) {
+ $OUT = '';
+ while ($content = sqlFetchArray($result)) {
// Init variables
- $rows = "";
- $counter = 0;
- $SW = 2;
+ $rows = '';
+ $content['counter'] = 0;
// Check for users ref in this level
- foreach (GET_USER_REFS($GLOBALS['userid'], $content['level']) as $refRow) {
+ foreach (getArrayFromRefbackUserRefs(getMemberId(), $content['level']) as $refRow) {
// Not-deleted account is default
- $deleted = false;
- if (is_null($refRow['status'])) $deleted = true;
+ $deleted = FALSE;
+ if (is_null($refRow['status'])) {
+ $deleted = TRUE;
+ } // END - if
// Add/"translate" more content
- $refRow['sw'] = $SW;
- $refRow['points'] = TRANSLATE_COMMA($refRow['points']);
- $refRow['refback'] = TRANSLATE_COMMA($refRow['refback']);
- $refRow['status'] = TRANSLATE_STATUS($refRow['status']);
- if (empty($refRow['nickname'])) $refRow['nickname'] = "---";
+ $refRow['joined'] = generateDateTime($refRow['joined'], '3');
// Load row template
- if ($deleted) {
- $rows .= LOAD_TEMPLATE("member_refback_list_row_deleted", true, $refRow);
+ if ($deleted === TRUE) {
+ $rows .= loadTemplate('member_list_refback_deleted_row', TRUE, $refRow);
} else {
- $rows .= LOAD_TEMPLATE("member_refback_list_row", true, $refRow);
+ $rows .= loadTemplate('member_list_refback_row', TRUE, $refRow);
}
// Count this ref and switch color
- $counter++;
- $SW = 3 - $SW;
+ $content['counter']++;
} // END - foreach
// Remember the content
- $content['counter'] = TRANSLATE_COMMA($counter);
- $content['percents'] = TRANSLATE_COMMA($content['percents']);
- $content['rows'] = $rows;
+ $content['rows'] = $rows;
// Load level template
- $OUT .= LOAD_TEMPLATE("member_refback_list_level", true, $content);
+ $OUT .= loadTemplate('member_list_refback_level', TRUE, $content);
} // END - while
// Load main template
- LOAD_TEMPLATE("member_refback_list", false, $OUT);
+ loadTemplate('member_list_refback', FALSE, $OUT);
} else {
// No entries
- LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_NO_ENTRIES);
+ displayMessage('{--MEMBER_REFBACK_NO_ENTRIES--}');
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
-//
+// [EOF]
?>