X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-config_points.php;h=48e98ec1453b79e48ed34784a0d783815bec3c3f;hp=f6fa31bbfa8ec9f7bf1e45c1b6387c47b5fa9926;hb=cd7d344ea7007cfa20413acd3e03e50f0ab86d86;hpb=a090e351c49fe021fb3064325694da03402332e0 diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php index f6fa31bbfa..48e98ec145 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); - - // Revert german commata - REQUEST_SET_POST(array('perc', $id), REVERT_COMMA(REQUEST_POST('perc', $id))); - - // Update entry - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refdepths` SET level='%s', percents='%s' WHERE id=%s LIMIT 1", - array(bigintval($value), REQUEST_POST('perc', $id), $id), __FILE__, __LINE__); - } - $message = getMessage('REF_DEPTHS_SAVED'); - break; - - case "del": - foreach (REQUEST_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', 'ref_payout'), + array(postRequestElement('allow_direct_pay'), $REF) + ); + if ((getRefPayout() == '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 ((getRefPayout() > 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"); + // @TODO Rewrite these two lines for new user_points columns (e.g. locked_order_points) with a filter + 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 = getMessage('REF_DEPTHS_DELETED'); break; - } - - // Update cache file - if (GET_EXT_VERSION('cache') >= '0.1.2') { - if ($GLOBALS['cache_instance']->loadCacheFile("refdepths")) $GLOBALS['cache_instance']->destroyCacheFile(); - } - break; - - case "settings": - $REF = bigintval(REQUEST_POST('ref_payout')); - ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET -allow_direct_pay='%s', -reg_points_mode='%s', -ref_payout='%s' -WHERE config=0 LIMIT 1", - REQUEST_POST('allow_direct_pay'), - REQUEST_POST('reg_points_mode'), - $REF - )); - if ((getConfig('ref_payout') == 0) && (REQUEST_POST('ref_payout') > 0)) { - // Update account's ref_payout for "must-confirm" - ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed) -WHERE mails_confirmed < %s", $REF, $REF)); - } elseif ((getConfig('ref_payout') > 0) && (REQUEST_POST('ref_payout') == 0)) { - // Update account's ref_payout for "not-must-confirm" - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0"); - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0"); - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0"); - } - break; - } + } // END - switch - if ((IS_SQLS_VALID()) && (IS_SQLS_VALID())) { - if (strpos($GLOBALS['sqls'][0], "INSERT") > -1) { - $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level='%s' LIMIT 1", - array(bigintval(REQUEST_POST('lvl'))), __FILE__, __LINE__); - SQL_FREERESULT($result); - } // END - if + // Is there an array? + if ((getRequestElement('sub') != 'points') && (isSqlsValid())) { + // Default is failed-message + $message = '{--SETTINGS_NOT_SAVED--}'; - if (COUNT_SQLS() > 0) { + if (countSqls() > 0) { // Run all SQL commands runFilterChain('run_sqls'); // Entry saved... - $message = getMessage('SETTINGS_SAVED'); + $message = '{--SETTINGS_SAVED--}'; // Destroy config cache file here... - rebuildCacheFiles("config", "config"); - } else { - // Prepare failed-message - $message = "{--SETTINGS_NOT_SAVED--}"; - } + rebuildCache('config', 'config'); + } // END - if // Remove SQL queries - UNSET_SQLS(); - } + unsetSqls(); + } // END - if // Shall we display a message? if (!empty($message)) { // When do so... - LOAD_TEMPLATE('admin_settings_saved', false, $message); - } -} elseif (REQUEST_GET('sub') == "settings") { + displayMessage($message); + } // END - if +} 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', ' chkecked="checked"'); - define('__DIRECT_N', ''); - break; - - case 'N': - define('__DIRECT_Y', ''); - define('__DIRECT_N', ' chkecked="checked"'); - break; - } - - // One-time referal bonus add-mode - switch (getConfig('reg_points_mode')) { - case "ref" : define('__MODE_REF', ' chkecked="checked"'); define('__MODE_DIRECT', ''); break; - case "direct": define('__MODE_REF', ''); define('__MODE_DIRECT', ' chkecked="checked"'); break; - } - - // Referal payout value - define('__REF_PAYOUT', round(getConfig('ref_payout'))); + // Including new add-mode for one-time referral bonus + foreach (array('allow_direct_pay') as $entry) { + $content[$entry . '_y'] = ''; + $content[$entry . '_n'] = ''; + $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"'; + } // END - foreach // Load template - LOAD_TEMPLATE("admin_config_point_settings"); -} elseif (REQUEST_GET('sub') == "ref") { - // 12 3 32 2 3 32 2 3 4 43 21 - if ((REQUEST_ISSET_POST('del')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { - // Delete entries - $OUT = ''; $SW = 2; - foreach (REQUEST_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); - SQL_FREERESULT($result); - - // Prepare data for the row template - $content = array( - 'sw' => $SW, - 'id' => $id, - 'lvl' => $lvl, - 'per' => TRANSLATE_COMMA($perc), - ); - - // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_points_del_row", true, $content); - $SW = 3 - $SW; - } - define('__LEVEL_ROWS', $OUT); - - // Load main template - LOAD_TEMPLATE("admin_points_del"); - } elseif ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { - // Edit entries - $OUT = ''; $SW = 2; - foreach (REQUEST_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); - SQL_FREERESULT($result); - - // Prepare data for the row template - $content = array( - 'sw' => $SW, - 'id' => $id, - 'lvl' => $lvl, - 'per' => TRANSLATE_COMMA($perc), - ); - - // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_points_edit_row", true, $content); - $SW = 3 - $SW; - } - define('__LEVEL_ROWS', $OUT); - - // Load main template - LOAD_TEMPLATE("admin_points_edit"); - } else { - // Referal levels - $result = SQL_QUERY("SELECT id, level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` ORDER BY level", __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) { - // Make referal levels editable and deletable - $OUT = ''; $SW = 2; - - // List already existing categories for editing - while ($content = SQL_FETCHARRAY($result)) { - // Prepare data for the row template - // @TODO Rewritings: lvl->level, per->percents in template - $content = array( - 'sw' => $SW, - 'id' => $content['id'], - 'lvl' => $content['level'], - 'per' => TRANSLATE_COMMA($content['percents']), - ); - - // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_points_row", true, $content); - $SW = 3 - $SW; - } - - // Free memory - SQL_FREERESULT($result); - define('__LEVEL_ROWS', $OUT); - - // Load main template - LOAD_TEMPLATE("admin_points"); - } - - // Form for adding new referal levels - LOAD_TEMPLATE("admin_add_reflvl"); - } -} elseif (REQUEST_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"); + loadTemplate('admin_config_point_settings', FALSE, $content); +} 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] ?>