-if ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
- // Edit payout types
- if ((REQUEST_ISSET_GET('ok')) && (REQUEST_GET('ok') == "ok")) {
- // Edit entries
- foreach (REQUEST_POST('sel') as $id => $sel) {
- // Secure ID
- $id = bigintval($id);
-
- // Edit only if something is entered
- if ((REQUEST_ISSET_POST(('title', $id))) && (REQUEST_POST('rate', $id) > 0)) {
- // Update entry
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_payout_types` SET
-type='%s',
-rate=%s,
-min_points=%s,
-allow_url='%s'
-WHERE id='".$id."' LIMIT 1",
- array(
- REQUEST_POST('title', $id),
- bigintval(REVERT_COMMA(REQUEST_POST('rate', $id))),
- bigintval(REVERT_COMMA(REQUEST_POST('mpoi' , $id))),
- REQUEST_POST('allow', $id),
-),__FILE__, __LINE__);
- }
- }
- $msg = getMessage('ADMIN_PAYOUT_ENTRIES_CHANGED');
- } else {
- $display = false; //Suppress any other outputs
- $SW = 2; $OUT = "";
- foreach (REQUEST_POST('sel') as $id => $sel) {
- // Load data
- $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url FROM `{!_MYSQL_PREFIX!}_payout_types` WHERE id=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
- list($title, $rate, $mpoi, $allow) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- // Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'title' => COMPILE_CODE($title),
- 'rate' => TRANSLATE_COMMA($rate),
- 'mpoi' => TRANSLATE_COMMA($mpoi),
- 'allow' => ADD_SELECTION("yn", $allow, "allow[".$id."]"),
- );
-
- // Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_config_payouts_edit_row", true, $content);
- $SW = 3 - $SW;
- }
- define('__PAYOUT_ROWS', $OUT);
+if ((isFormSent('edit')) && (ifPostContainsSelections())) {
+ // Make payouts configurable
+ $display = false; //Suppress any other outputs
+ $OUT = '';
+ foreach (postRequestElement('sel') as $id => $sel) {
+ // Load data
+ $result = SQL_QUERY_ESC("SELECT `id`,`type`,`rate`,`min_points`,`allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
+ $content = SQL_FETCHARRAY($result);
+ SQL_FREERESULT($result);