More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / modules / admin / what-list_sponsor_pay.php
index b4636b937b3d8aa6e3cd204060f4efcb5bd72187..dee8f22e8c23bfecee08533590b697127b7622c3 100644 (file)
@@ -139,25 +139,14 @@ if (isFormSent('add')) {
        loadTemplate('admin_settings_saved', false, $message);
 } elseif ((isFormSent('edit')) || (isFormSent('del'))) {
        // Load all data
-       $OUT = ''; $SW = 2;
+       $OUT = '';
        foreach (postRequestParameter('id') as $id => $sel) {
                // Load entry
-               $result = SQL_QUERY_ESC("SELECT `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`='%s' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Load data
-                       list($name, $rate, $min, $curr) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
-
-                       // Transfer data to array
-                       $content = array(
-                               'id'   => bigintval($id),
-                               'sw'   => bigintval($SW),
-                               'name' => htmlspecialchars($name),
-                               'rate' => translateComma($rate),
-                               'min'  => bigintval($min),
-                               'curr' => htmlspecialchars($curr)
-                       );
+                       $content = SQL_FETCHARRAY($result);
 
                        if (isFormSent('edit')) {
                                // Edit entry
@@ -171,8 +160,8 @@ if (isFormSent('add')) {
                        $OUT .= loadTemplate('admin_list_sponsor_pay_404', true, $id);
                }
 
-               // Switch colors
-               $SW = 3 - $SW;
+               // Free result
+               SQL_FREERESULT($result);
        } // END - foreach
 
        // Load main template depending on mode (edit/delete)
@@ -194,27 +183,14 @@ ORDER BY
                __FILE__, __LINE__);
 
        // Do we have some paytypes setup?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Prepare variables for listing
-               $OUT = ''; $SW = 2;
+               $OUT = '';
 
                // List alle found payment types
                while ($content = SQL_FETCHARRAY($result)) {
-                       // Remember data in array
-                       $content = array(
-                               'sw'       => $SW,
-                               'id'       => $content['id'],
-                               'name'     => $content['pay_name'],
-                               'rate'     => translateComma($content['pay_rate']),
-                               'min'      => $content['pay_min_count'],
-                               'currency' => $content['pay_currency']
-                       );
-
                        // Add row
                        $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
-
-                       // Switch colors
-                       $SW = 3 - $SW;
                } // END - while
 
                // Load list template