<?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 *
* $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 *
- * 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
- redirectToUrl('modules.php?module=index');
-} elseif ((!EXT_IS_ACTIVE('refback')) && (!IS_ADMIN())) {
- addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveMessage('refback'));
- return;
-}
-
-// Is the refback system enabled?
-if (getConfig('refback_enabled') != 'Y') {
+ redirectToIndexMemberOnlyModule();
+} elseif (!isRefbackEnabled()) {
// Output message
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DISABLED'));
+ displayMessage('{--MEMBER_REFBACK_DISABLED--}');
+
// Abort here
- return false;
+ return FALSE;
} // END - if
// Add description as navigation point
-ADD_DESCR('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
+
+if ((!isExtensionActive('refback')) && (!isAdmin())) {
+ displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=refback%}');
+ return;
+} // END - if
// Was the form submitted?
-if ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('id'))) {
+if ((isFormSent('edit')) && (isPostRequestElementSet('id'))) {
// Okay, has the user entered some values?
- if (REQUEST_ISSET_POST(('percents'))) {
+ if (isPostRequestElementSet('refback_percents')) {
// Revert german commta for testing
- $percents = convertCommaToDot(REQUEST_POST('percents'));
+ $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 = REFBACK_CHANGE_MEMBER_PERCENTS(REQUEST_POST('id'), REQUEST_POST('percents'));
+ $status = updateMemberRefbackPercents(postRequestElement('id'), postRequestElement('refback_percents'), postRequestElement('refback_notice'));
// Check status
if (isset($status['ok'])) {
// No message found
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DONE'));
+ displayMessage('{--MEMBER_REFBACK_DONE--}');
} elseif (isset($status['message'])) {
// Something went wrong with error message
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('MEMBER_REFBACK_ERROR_MESSAGE'), $status['message']));
+ displayMessage('{%message,MEMBER_REFBACK_ERROR_MESSAGE=' . getMessage($status['message']) . '%}');
} else {
// No message found
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_ERROR_EMPTY_MESSAGE'));
+ displayMessage('{--MEMBER_REFBACK_ERROR_EMPTY_MESSAGE--}');
}
} else {
// Percents out-of-bounds ;-)
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS'), getConfig('refback_min_perc'), getConfig('refback_max_perc')));
+ displayMessage('{--MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS--}');
}
// Insert line
} else {
// Read data from refback table
- $content = GET_USER_REF_ENTRY(REQUEST_POST('id'));
-
- // Translate comma
- $content['refback'] = translateComma($content['refback']);
- $content['min'] = translateComma(getConfig('refback_min_perc').".0");
- $content['max'] = translateComma(getConfig('refback_max_perc').".0");
+ $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(getUserId()), __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)) {
+ while ($content = sqlFetchArray($result)) {
// Init variables
$rows = '';
- $counter = 0;
- $SW = 2;
+ $content['counter'] = 0;
// Check for users ref in this level
- foreach (GET_USER_REFS(getUserId(), $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'] = translateComma($refRow['points']);
- $refRow['refback'] = translateComma($refRow['refback']);
- $refRow['status'] = translateUserStatus($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'] = translateComma($counter);
- $content['percents'] = translateComma($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, getMessage('MEMBER_REFBACK_NO_ENTRIES'));
+ displayMessage('{--MEMBER_REFBACK_NO_ENTRIES--}');
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
-//
+// [EOF]
?>