X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-config_points.php;h=8c36a0770ba9caaad6e76643cf6410f14f8ea04c;hp=d5a7b23b927889e9c53a44f2d15a69cf82e27fd2;hb=57227d33e870ec5cd271209c4a978a52b45c2dd6;hpb=dbeb4ef1dc2e59d0c6bfab9d9666cdfa515f58e7 diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php index d5a7b23b92..8c36a0770b 100644 --- a/inc/modules/admin/what-config_points.php +++ b/inc/modules/admin/what-config_points.php @@ -1,7 +1,7 @@ $value) { - // Secure ID - $id = bigintval($id); + case 'ref': + switch (getRequestParameter('do')) + { + case 'add': + addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (`level`, `percents`) VALUES ('".postRequestParameter('level')."','".postRequestParameter('percents')."')"); + break; + + case 'edit': // Change entries + foreach (postRequestParameter('level') as $id => $value) { + // Secure id + $id = bigintval($id); - // Revert german commata - $_POST['perc'][$id] = REVERT_COMMA($_POST['perc'][$id]); + // Revert german commata + setPostRequestParameter('percents', array($id => convertCommaToDot(postRequestParameter('percents', $id)))); - // Update entry - $result = 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 entry + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refdepths` SET `level`='%s', `percents`='%s' WHERE `id`=%s LIMIT 1", + array(bigintval($value), postRequestParameter('percents', $id), $id), __FILE__, __LINE__); + } + $message = getMessage('REF_DEPTHS_SAVED'); + break; + + case 'del': + foreach (postRequestParameter('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; } - $TEXT = REF_DEPTHS_SAVED; - break; - case "del": - foreach ($_POST['id'] as $id => $value) { - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_refdepths WHERE id=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); + // Update cache file + if (getExtensionVersion('cache') >= '0.1.2') { + if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->removeCacheFile(); } - $TEXT = REF_DEPTHS_DELETED; break; - } - // Update cache file - if (GET_EXT_VERSION("cache") >= "0.1.2") { - if ($cacheInstance->cache_file("refdepths", true)) $cacheInstance->cache_destroy(); - } - break; - - case "settings": - $REF = bigintval($_POST['ref_payout']); - $SQL[] = 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 (($_CONFIG['ref_payout'] == 0) && ($_POST['ref_payout'] > 0)) - { - // Update account's ref_payout for "must-confirm" - $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=(%s - mails_confirmed) -WHERE mails_confirmed < %s", $REF, $REF); - } - elseif (($_CONFIG['ref_payout'] > 0) && ($_POST['ref_payout'] == 0)) - { - // Update account's ref_payout for "not-must-confirm" - $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=0 WHERE ref_payout > 0"; - $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET points=points+locked_points WHERE locked_points>0"; - $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET locked_points=0 WHERE locked_points>0"; - } - break; + case 'settings': + $REF = bigintval(postRequestParameter('ref_payout')); + updateConfiguration( + array('allow_direct_pay', 'reg_points_mode', 'ref_payout'), + array(postRequestParameter('allow_direct_pay'), postRequestParameter('reg_points_mode'), $REF) + ); + if ((getConfig('ref_payout') == '0') && (postRequestParameter('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) && (postRequestParameter('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"); + } + break; } - if ((isset($SQL)) && (is_array($SQL)) && (!empty($SQL[0]))) - { - if (strpos($SQL[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(postRequestParameter('level'))), __FILE__, __LINE__); SQL_FREERESULT($result); - } - if (count($SQL) > 0) - { + } // END - if + + if (countSqls() > 0) { // Run all SQL commands - foreach ($SQL as $s) - { - $result = SQL_QUERY($s, __FILE__, __LINE__); - } + runFilterChain('run_sqls'); - $content = "".SETTINGS_SAVED.""; + // Entry saved... + $message = getMessage('SETTINGS_SAVED'); // Destroy config cache file here... - REBUILD_CACHE("config", "config"); - } - else - { - $content = "".SETTINGS_NOT_SAVED.""; + rebuildCacheFile('config', 'config'); + } else { + // Prepare failed-message + $message = "{--SETTINGS_NOT_SAVED--}"; } - unset($SQL); - LOAD_TEMPLATE("admin_settings_saved", false, $content); - } - elseif (isset($TEXT)) - { - LOAD_TEMPLATE("admin_settings_saved", false, $TEXT); - } -} - elseif ($_GET['sub'] == "settings") -{ - // Setup some settings like direct pay and so on - // Including new add-mode for one-time referral bonus - switch ($_CONFIG['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; + + // Remove SQL queries + unsetSqls(); } - // One-time referral bonus add-mode - switch ($_CONFIG['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; + // Shall we display a message? + if (!empty($message)) { + // When do so... + loadTemplate('admin_settings_saved', false, $message); } +} elseif (getRequestParameter('sub') == 'settings') { + // Setup some settings like direct pay and so on + // Including new add-mode for one-time referal bonus + foreach (array('allow_direct_pay') as $entry) { + $content[$entry . '_y'] = ''; + $content[$entry . '_n'] = ''; + $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"'; + } // END - foreach - // Referral payout value - define('__REF_PAYOUT', round($_CONFIG['ref_payout'])); + // One-time referal bonus add-mode + 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'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) - { + loadTemplate('admin_config_point_settings', false, $content); +} elseif (getRequestParameter('sub') == 'ref') { + // 12 3 32 2 3 32 2 3 4 43 21 + if ((isPostRequestParameterSet('del')) && (isPostRequestParameterSet('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", - array(bigintval($id)), __FILE__, __LINE__); - list($lvl, $perc) = SQL_FETCHROW($result); + $OUT = ''; $SW = 2; + foreach (postRequestParameter('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($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'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) - { + loadTemplate('admin_points_del', false, $OUT); + } elseif ((isPostRequestParameterSet('edit')) && (isPostRequestParameterSet('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 (postRequestParameter('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($content['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"); - } - else - { - // Referral levels - $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) - { - // Make referral levels editable and deletable - $SW = 2; $OUT = ""; + loadTemplate('admin_points_edit', false, $OUT); + } else { + // Referal levels + $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 + $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 referral levels - LOAD_TEMPLATE("admin_add_reflvl"); + // Form for adding new referal levels + loadTemplate('admin_add_reflevel'); } -} - elseif ($_GET['sub'] == "points") -{ - // First points for registration and other fixed points including new add-mode for one-time referral bonus... - define('P_REG_VALUE', $_CONFIG['points_register']); - define('P_REF_VALUE', $_CONFIG['points_ref']); - - // Load templates - LOAD_TEMPLATE("admin_config_sub_points"); -} - else -{ +} elseif (getRequestParameter('sub') == 'points') { + // Load template + loadTemplate('admin_config_sub_points'); +} else { // Display selection box - LOAD_TEMPLATE("admin_config_points"); + loadTemplate('admin_config_points'); } -// +// [EOF] ?>