X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-config_points.php;h=53cbc18472f81738df2793b05152e057a2391392;hb=eb301334eb0960dd060cc0d59e6021260a41f835;hp=357d1222048eae0738aa16607e9e3f6d1944e133;hpb=747c49b9f46a3d7d1d881c9e1c273ecf107f8d8b;p=mailer.git
diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php
index 357d122204..53cbc18472 100644
--- a/inc/modules/admin/what-config_points.php
+++ b/inc/modules/admin/what-config_points.php
@@ -10,9 +10,14 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Einstellen der Willkommensgutschrift usw. *
* -------------------------------------------------------------------- *
- * *
+ * $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 *
@@ -32,261 +37,234 @@
************************************************************************/
// Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
}
// Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+addMenuDescription('admin', __FILE__);
// Init variables
-$message = "";
+$message = '';
// Is the 'sub' parameter set?
-if (!empty($_GET['sub'])) {
+if (isGetRequestElementSet('sub')) {
// Yes, then do some sanity-checks
- switch ($_GET['sub'])
- {
- case "points":
- if ((empty($_POST['points_register'])) || (empty($_POST['points_ref']))) {
- unset($_POST['ok']);
- }
- break;
+ switch (getRequestElement('sub')) {
+ case 'points':
+ if ((!isPostRequestElementSet(('points_register'))) || (!isPostRequestElementSet(('points_ref')))) {
+ unsetPostRequestElement('ok');
+ }
+ break;
- case "ref":
- if (isset($_GET['do'])) {
- if (((empty($_POST['lvl'])) || (empty($_POST['perc']))) && ($_GET['do'] == "add")) {
- unset($_POST['ok']);
+ case 'ref':
+ if (isGetRequestElementSet('do')) {
+ if (((!isPostRequestElementSet(('level'))) || (!isPostRequestElementSet(('perc')))) && (getRequestElement('do') == 'add')) {
+ unsetPostRequestElement('ok');
+ }
}
- }
- break;
+ break;
}
} else {
// Display overview
- $_GET['sub'] = "overview";
+ setRequestGetElement('sub', 'overview');
}
-if (isset($_POST['ok'])) {
- $SQLs = array();
- switch ($_GET['sub'])
- {
- case "points":
- $SQLs[] = "UPDATE `{!MYSQL_PREFIX!}_config` SET points_register='".$_POST['points_register']."', points_ref='".$_POST['points_ref']."' WHERE config=0 LIMIT 1";
- break;
-
- case "ref":
- switch ($_GET['do'])
- {
- case "add":
- $SQLs[] = "INSERT INTO `{!MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".$_POST['lvl']."','".$_POST['perc']."')";
+if (isFormSent()) {
+ initSqls();
+ switch (getRequestElement('sub')) {
+ case 'points':
+ updateConfiguration(array('points_register', 'points_ref'), array(postRequestElement('points_register'), postRequestElement('points_ref')));
break;
- case "edit": // Change entries
- foreach ($_POST['lvl'] as $id => $value) {
- // Secure ID
- $id = bigintval($id);
-
- // Revert german commata
- $_POST['perc'][$id] = REVERT_COMMA($_POST['perc'][$id]);
+ case 'ref':
+ switch (getRequestElement('do'))
+ {
+ case 'add':
+ addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (level, percents) VALUES ('".postRequestElement('level')."','".postRequestElement('perc')."')");
+ break;
+
+ case 'edit': // Change entries
+ foreach (postRequestElement('level') as $id => $value) {
+ // Secure ID
+ $id = bigintval($id);
+
+ // Revert german commata
+ setRequestPostElement('perc', array($id => convertCommaToDot(postRequestElement('perc', $id))));
+
+ // Update entry
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refdepths` SET level='%s', percents='%s' WHERE `id`=%s LIMIT 1",
+ array(bigintval($value), postRequestElement('perc', $id), $id), __FILE__, __LINE__);
+ }
+ $message = getMessage('REF_DEPTHS_SAVED');
+ break;
+
+ case 'del':
+ foreach (postRequestElement('id') as $id => $value) {
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
+ }
+ $message = getMessage('REF_DEPTHS_DELETED');
+ break;
+ }
- // Update entry
- SQL_QUERY_ESC("UPDATE `{!MYSQL_PREFIX!}_refdepths` SET level='%s', percents='%s' WHERE id=%s LIMIT 1",
- array(bigintval($value), $_POST['perc'][$id], $id), __FILE__, __LINE__);
+ // Update cache file
+ if (getExtensionVersion('cache') >= '0.1.2') {
+ if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->removeCacheFile();
}
- $message = REF_DEPTHS_SAVED;
break;
- case "del":
- foreach ($_POST['id'] as $id => $value) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!MYSQL_PREFIX!}_refdepths` WHERE id=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ case 'settings':
+ $REF = bigintval(postRequestElement('ref_payout'));
+ updateConfiguration(
+ array('allow_direct_pay', 'reg_points_mode', 'ref_payout'),
+ array(postRequestElement('allow_direct_pay'), postRequestElement('reg_points_mode'), $REF)
+ );
+ if ((getConfig('ref_payout') == 0) && (postRequestElement('ref_payout') > 0)) {
+ // Update account's ref_payout for "must-confirm"
+ addSql(sprintf("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=(%s - `mails_confirmed`)
+WHERE `mails_confirmed` < %s", $REF, $REF));
+ } elseif ((getConfig('ref_payout') > 0) && (postRequestElement('ref_payout') == 0)) {
+ // Update account's ref_payout for "not-must-confirm"
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=0 WHERE `ref_payout` > 0");
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `points`=`points`+`locked_points` WHERE `locked_points` > 0");
+ addSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `locked_points`=0 WHERE `locked_points` > 0");
}
- $message = REF_DEPTHS_DELETED;
break;
- }
-
- // Update cache file
- if (GET_EXT_VERSION("cache") >= "0.1.2") {
- if ($cacheInstance->loadCacheFile("refdepths")) $cacheInstance->destroyCacheFile();
- }
- break;
-
- case "settings":
- $REF = bigintval($_POST['ref_payout']);
- $SQLs[] = sprintf("UPDATE `{!MYSQL_PREFIX!}_config` SET
-allow_direct_pay='%s',
-reg_points_mode='%s',
-ref_payout='%s'
-WHERE config=0 LIMIT 1",
- $_POST['allow_direct_pay'],
- $_POST['reg_points_mode'],
- $REF
- );
- if ((getConfig('ref_payout') == 0) && ($_POST['ref_payout'] > 0)) {
- // Update account's ref_payout for "must-confirm"
- $SQLs[] = sprintf("UPDATE `{!MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed)
-WHERE mails_confirmed < %s", $REF, $REF);
- } elseif ((getConfig('ref_payout') > 0) && ($_POST['ref_payout'] == 0)) {
- // Update account's ref_payout for "not-must-confirm"
- $SQLs[] = "UPDATE `{!MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0";
- $SQLs[] = "UPDATE `{!MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0";
- $SQLs[] = "UPDATE `{!MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0";
- }
- break;
}
- if ((isset($SQLs)) && (is_array($SQLs)) && (!empty($SQLs[0]))) {
- if (strpos($SQLs[0], "INSERT") > -1) {
- $result = SQL_QUERY_ESC("SELECT id FROM `{!MYSQL_PREFIX!}_refdepths` WHERE level='%s' LIMIT 1",
- array(bigintval($_POST['lvl'])), __FILE__, __LINE__);
+ if ((isSqlsValid()) && (isSqlsValid())) {
+ if (strpos($GLOBALS['sqls'][0], 'INSERT') > -1) {
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE level='%s' LIMIT 1",
+ array(bigintval(postRequestElement('level'))), __FILE__, __LINE__);
SQL_FREERESULT($result);
} // END - if
- if (count($SQLs) > 0) {
+ if (countSqls() > 0) {
// Run all SQL commands
- RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
+ runFilterChain('run_sqls');
// Entry saved...
- $message = SETTINGS_SAVED;
+ $message = getMessage('SETTINGS_SAVED');
// Destroy config cache file here...
- REBUILD_CACHE("config", "config");
+ rebuildCacheFile('config', 'config');
} else {
// Prepare failed-message
- $message = "".SETTINGS_NOT_SAVED."";
+ $message = "{--SETTINGS_NOT_SAVED--}";
}
// Remove SQL queries
- unset($SQLs);
+ unsetSqls();
}
// Shall we display a message?
if (!empty($message)) {
// When do so...
- LOAD_TEMPLATE("admin_settings_saved", false, $message);
+ loadTemplate('admin_settings_saved', false, $message);
}
-} elseif ($_GET['sub'] == "settings") {
+} elseif (getRequestElement('sub') == 'settings') {
// Setup some settings like direct pay and so on
// Including new add-mode for one-time referal bonus
- switch (getConfig('allow_direct_pay')) {
- case "Y":
- define('__DIRECT_Y', " checked=\"checked\"");
- define('__DIRECT_N', "");
- break;
-
- case "N":
- define('__DIRECT_Y', "");
- define('__DIRECT_N', " checked=\"checked\"");
- break;
- }
+ foreach (array('allow_direct_pay') as $entry) {
+ $content[$entry . '_y'] = '';
+ $content[$entry . '_n'] = '';
+ $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"';
+ } // END - foreach
// One-time referal bonus add-mode
- switch (getConfig('reg_points_mode')) {
- case "ref" : define('__MODE_REF', " checked=\"checked\""); define('__MODE_DIRECT', ""); break;
- case "direct": define('__MODE_REF', ""); define('__MODE_DIRECT', " checked=\"checked\""); break;
- }
-
- // Referal payout value
- define('__REF_PAYOUT', round(getConfig('ref_payout')));
+ foreach (array('reg_points_mode_ref','reg_points_mode_direct') as $entry) {
+ $content[$entry] = '';
+ } // END - if
+ $content['reg_points_mode_' . strtolower(getConfig('reg_points_mode'))] = ' checked="checked"';
// Load template
- LOAD_TEMPLATE("admin_config_point_settings");
-} elseif ($_GET['sub'] == "ref") {
- if ((isset($_POST['del'])) && (isset($_POST['sel'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {
+ loadTemplate('admin_config_point_settings', false, $content);
+} elseif (getRequestElement('sub') == 'ref') {
+ // 12 3 32 2 3 32 2 3 4 43 21
+ if ((isPostRequestElementSet('del')) && (isPostRequestElementSet('sel')) && (countPostSelection() > 0)) {
// Delete entries
- $SW = 2; $OUT = "";
- foreach ($_POST['sel'] as $id => $value) {
- $result = SQL_QUERY_ESC("SELECT level, percents FROM `{!MYSQL_PREFIX!}_refdepths` WHERE id=%s LIMIT 1",
+ $OUT = ''; $SW = 2;
+ foreach (postRequestElement('sel') as $id => $value) {
+ $result = SQL_QUERY_ESC("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- list($lvl, $perc) = SQL_FETCHROW($result);
+ $content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
// Prepare data for the row template
$content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'lvl' => $lvl,
- 'per' => TRANSLATE_COMMA($perc),
+ 'sw' => $SW,
+ 'id' => $id,
+ 'level' => $content['level'],
+ 'percents' => translateComma($content['percents']),
);
// Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_points_del_row", true, $content);
+ $OUT .= loadTemplate('admin_points_del_row', true, $content);
$SW = 3 - $SW;
}
- define('__LEVEL_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_points_del");
- } elseif ((isset($_POST['edit'])) && (isset($_POST['sel'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {
+ loadTemplate('admin_points_del', false, $OUT);
+ } elseif ((isPostRequestElementSet('edit')) && (isPostRequestElementSet('sel')) && (countPostSelection() > 0)) {
// Edit entries
- $SW = 2; $OUT = "";
- foreach ($_POST['sel'] as $id => $value) {
- $result = SQL_QUERY_ESC("SELECT level, percents FROM `{!MYSQL_PREFIX!}_refdepths` WHERE id=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
- list($lvl, $perc) = SQL_FETCHROW($result);
+ $OUT = ''; $SW = 2;
+ foreach (postRequestElement('sel') as $id => $value) {
+ $result = SQL_QUERY_ESC("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
+ $content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
// Prepare data for the row template
$content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'lvl' => $lvl,
- 'per' => TRANSLATE_COMMA($perc),
+ 'sw' => $SW,
+ 'id' => $id,
+ 'level' => $content['level'],
+ 'percents' => translateComma($contentp['percents']),
);
// Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_points_edit_row", true, $content);
+ $OUT .= loadTemplate('admin_points_edit_row', true, $content);
$SW = 3 - $SW;
}
- define('__LEVEL_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_points_edit");
+ loadTemplate('admin_points_edit', false, $OUT);
} else {
// Referal levels
- $result = SQL_QUERY("SELECT id, level, percents FROM `{!MYSQL_PREFIX!}_refdepths` ORDER BY level", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT `id`, `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0) {
// Make referal levels editable and deletable
- $SW = 2; $OUT = "";
+ $OUT = ''; $SW = 2;
// List already existing categories for editing
- while (list($id, $lvl, $perc) = SQL_FETCHROW($result)) {
+ while ($content = SQL_FETCHARRAY($result)) {
// Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'lvl' => $lvl,
- 'per' => TRANSLATE_COMMA($perc),
- );
+ $content['sw'] = $SW;
+ $content['percents'] = translateComma($content['percents']);
// Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_points_row", true, $content);
+ $OUT .= loadTemplate('admin_points_row', true, $content);
$SW = 3 - $SW;
}
// Free memory
SQL_FREERESULT($result);
- define('__LEVEL_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_points");
+ loadTemplate('admin_points', false, $OUT);
}
// Form for adding new referal levels
- LOAD_TEMPLATE("admin_add_reflvl");
+ loadTemplate('admin_add_reflevel');
}
-} elseif ($_GET['sub'] == "points") {
- // First points for registration and other fixed points including new add-mode for one-time referal bonus...
- define('P_REG_VALUE', getConfig('points_register'));
- define('P_REF_VALUE', getConfig('points_ref'));
-
- // Load templates
- LOAD_TEMPLATE("admin_config_sub_points");
+} elseif (getRequestElement('sub') == 'points') {
+ // Load template
+ loadTemplate('admin_config_sub_points');
} else {
// Display selection box
- LOAD_TEMPLATE("admin_config_points");
+ loadTemplate('admin_config_points');
}
-//
+// [EOF]
?>