<?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 *
* 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())) {
- addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'refback');
- return;
+ redirectToIndexMemberOnlyModule();
}
// Is the refback system enabled?
if (getConfig('refback_enabled') != 'Y') {
// Output message
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DISABLED'));
+ 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 ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST(('id')))) {
+if ((isPostRequestParameterSet('edit')) && (isPostRequestParameterSet('id'))) {
// Okay, has the user entered some values?
- if (REQUEST_ISSET_POST(('percents'))) {
+ if (isPostRequestParameterSet('percents')) {
// Revert german commta for testing
- $percents = REVERT_COMMA(REQUEST_POST('percents'));
+ $percents = convertCommaToDot(postRequestParameter('percents'));
// Validate percents
- if ((($percents >= getConfig('refback_min_perc')) || (round($percents) == 0)) && ($percents <= getConfig('refback_max_perc'))) {
+ 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(postRequestParameter('id'), postRequestParameter('percents'));
// Check status
if (isset($status['ok'])) {
// No message found
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_DONE'));
+ loadTemplate('admin_settings_saved', false, getMessage('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']));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('MEMBER_REFBACK_ERROR_MESSAGE', $status['message']));
} else {
// No message found
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_REFBACK_ERROR_EMPTY_MESSAGE'));
+ loadTemplate('admin_settings_saved', false, getMessage('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')));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('MEMBER_REFBACK_ERROR_OUT_OF_BOUNDS'));
}
// Insert line
} else {
// Read data from refback table
- $content = GET_USER_REF_ENTRY(REQUEST_POST('id'));
+ $content = getArrayFromUserRefbackData(postRequestParameter('id'));
// Translate comma
- $content['refback'] = TRANSLATE_COMMA($content['refback']);
- $content['min'] = TRANSLATE_COMMA(getConfig('refback_min_perc').".0");
- $content['max'] = TRANSLATE_COMMA(getConfig('refback_max_perc').".0");
+ $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(getUserId()), __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) {
while ($content = SQL_FETCHARRAY($result)) {
// Init variables
$rows = '';
- $counter = 0;
+ $counter = '0';
$SW = 2;
// 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;
// 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']);
+ $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, getMessage('MEMBER_REFBACK_NO_ENTRIES'));
+ loadTemplate('admin_settings_saved', false, getMessage('MEMBER_REFBACK_NO_ENTRIES'));
}
// Free result