<?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:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-} elseif (!IS_MEMBER()) {
+ die();
+} 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();
}
+// Is the refback system enabled?
+if (getConfig('refback_enabled') != 'Y') {
+ // Output message
+ loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DISABLED'));
+ // Abort here
+ return false;
+} // END - if
+
// Add description as navigation point
-ADD_DESCR("member", __FILE__);
+addMenuDescription('member', __FILE__);
+
+if ((!isExtensionActive('refback')) && (!isAdmin())) {
+ loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('refback'));
+ return;
+} // END - if
// Was the form submitted?
-if ((isset($_POST['edit'])) && (isset($_POST['id']))) {
+if ((isPostRequestParameterSet('edit')) && (isPostRequestParameterSet('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 (isPostRequestParameterSet('percents')) {
+ // Revert german commta for testing
+ $percents = convertCommaToDot(postRequestParameter('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(postRequestParameter('id'), postRequestParameter('percents'));
+
+ // Check status
+ if (isset($status['ok'])) {
+ // No message found
+ loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DONE'));
+ } elseif (isset($status['message'])) {
+ // Something went wrong with error message
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('MEMBER_REFBACK_ERROR_MESSAGE', $status['message']));
+ } else {
+ // No message found
+ loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_ERROR_EMPTY_MESSAGE'));
+ }
} else {
- // No message found
- LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_ERROR_EMPTY_MESSAGE);
+ // Percents out-of-bounds ;-)
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS'));
}
// Insert line
- OUTPUT_HTML("<br />");
} else {
// Read data from refback table
- $content = GET_USER_REF_ENTRY($_POST['id']);
+ $content = getArrayFromUserRefbackData(postRequestParameter('id'));
// Translate comma
- $content['refback'] = TRANSLATE_COMMA($content['refback']);
+ $content['refback'] = translateComma($content['refback']);
// Load form for editing
- LOAD_TEMPLATE("member_refback_edit", false, $content);
+ loadTemplate('member_refback_edit', 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__);
+$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(getMemberId()), __FILE__, __LINE__);
// Are there some entries? (Shall be!)
if (SQL_NUMROWS($result) > 0) {
// List all levels
- $OUT = "";
+ $OUT = '';
while ($content = SQL_FETCHARRAY($result)) {
// Init variables
- $rows = "";
- $counter = 0;
+ $rows = '';
+ $counter = '0';
$SW = 2;
// 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;
// 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['sw'] = $SW;
+ $refRow['points'] = translateComma($refRow['points']);
+ $refRow['refback'] = translateComma($refRow['refback']);
+ // UNUSED: $refRow['status'] = translateUserStatus($refRow['status']);
+ $refRow['joined'] = generateDateTime($refRow['joined'], '3');
+ if (empty($refRow['nickname'])) $refRow['nickname'] = '---';
// Load row template
- if ($deleted) {
- $rows .= LOAD_TEMPLATE("member_refback_list_row_deleted", true, $refRow);
+ if ($deleted === true) {
+ $rows .= loadTemplate('member_refback_list_row_deleted', true, $refRow);
} else {
- $rows .= LOAD_TEMPLATE("member_refback_list_row", true, $refRow);
+ $rows .= loadTemplate('member_refback_list_row', true, $refRow);
}
// Count this ref and switch color
} // END - foreach
// Remember the content
- $content['counter'] = TRANSLATE_COMMA($counter);
- $content['percents'] = TRANSLATE_COMMA($content['percents']);
+ $content['counter'] = translateComma($counter);
+ $content['percents'] = translateComma($content['percents']);
$content['rows'] = $rows;
// Load level template
- $OUT .= LOAD_TEMPLATE("member_refback_list_level", true, $content);
+ $OUT .= loadTemplate('member_refback_list_level', true, $content);
} // END - while
// Load main template
- LOAD_TEMPLATE("member_refback_list", false, $OUT);
+ loadTemplate('member_refback_list', false, $OUT);
} else {
// No entries
- LOAD_TEMPLATE("admin_settings_saved", false, MEMBER_REFBACK_NO_ENTRIES);
+ loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_NO_ENTRIES'));
}
// Free result