-if ((isset($_POST['edit'])) && (SELECTION_COUNT($_POST['sel']) > 0))
-{
- // Edit payout types
- if ((isset($_GET['ok'])) && ($_GET['ok'] == "ok"))
- {
- // Edit entries
- foreach ($_POST['sel'] as $id => $sel)
- {
- // Secure ID
- $id = bigintval($id);
-
- // Edit only if something is entered
- if ((!empty($_POST['title'][$id])) && ($_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(
- $_POST['title'][$id],
- bigintval(REVERT_COMMA($_POST['rate'][$id])),
- bigintval(REVERT_COMMA($_POST['mpoi'][$id])),
- $_POST['allow'][$id],
-),__FILE__, __LINE__);
- }
- }
- $msg = ADMIN_PAYOUT_ENTRIES_CHANGED;
- }
- else
- {
- $display = false; //Suppress any other outputs
- $SW = 2; $OUT = "";
- foreach ($_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);