X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_sponsor_pay.php;h=61d759bff005f4646615430f4e7d274cbc886163;hp=ad8ff06b09af15e50387dbf9c7245cf2aaf0f47d;hb=0f3a135204757cc8750262871c8e62c42300acb4;hpb=64c8349613addc3da2242c5cd6b99d64e3fb5f8e diff --git a/inc/modules/admin/what-list_sponsor_pay.php b/inc/modules/admin/what-list_sponsor_pay.php index ad8ff06b09..61d759bff0 100644 --- a/inc/modules/admin/what-list_sponsor_pay.php +++ b/inc/modules/admin/what-list_sponsor_pay.php @@ -1,7 +1,7 @@ $sel) { - // Secure ID + foreach (postRequestParameter('id') as $id => $sel) { + // Secure id $id = bigintval($id); // Save entry @@ -79,86 +78,75 @@ SET `pay_min_count`='%s', `pay_currency`='%s' WHERE - `id`='%s' + `id`=%s LIMIT 1", array( - postRequestElement('name', $id), - postRequestElement('rate', $id), - bigintval(postRequestElement('min', $id)), - postRequestElement('curr', $id), + postRequestParameter('name', $id), + postRequestParameter('rate', $id), + bigintval(postRequestParameter('min', $id)), + postRequestParameter('curr', $id), $id ), __FILE__, __LINE__); } // Generate message - $message = getMessage('SPONSOR_PAY_ENTRIES_CHANGED'); - } elseif (isPostRequestElementSet('remove')) { + $message = '{--SPONSOR_PAY_ENTRIES_CHANGED--}'; + } elseif (isFormSent('do_delete')) { // Remove entries here... - foreach (postRequestElement('id') as $id => $sel) { + foreach (postRequestParameter('id') as $id => $sel) { // Remove entry - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`='%s' LIMIT 1", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); } // Generate message - $message = getMessage('SPONSOR_PAY_ENTRIES_REMOVED'); + $message = '{--SPONSOR_PAY_ENTRIES_REMOVED--}'; } if (!empty($message)) { // Output message - loadTemplate('admin_settings_saved', false, $message); + displayMessage($message); } // END - if } -if (isPostRequestElementSet('add')) { +if (isFormSent('add')) { // Check if entry with same name does exists $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1", - array(postRequestElement('pay_name')), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) { + array(postRequestParameter('pay_name')), __FILE__, __LINE__); + if (SQL_HASZERONUMS($result)) { // No entry found so add this line - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`,`pay_rate`,`pay_min_count`,`pay_currency`) VALUES ('%s','%s','%s','%s')", array( - postRequestElement('pay_name'), - convertCommaToDot(postRequestElement('pay_rate')), - bigintval(postRequestElement('pay_min_count')), - postRequestElement('pay_currency') + postRequestParameter('pay_name'), + convertCommaToDot(postRequestParameter('pay_rate')), + bigintval(postRequestParameter('pay_min_count')), + postRequestParameter('pay_currency') ), __FILE__, __LINE__); // Payment type added! - $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ADDED'), postRequestElement('pay_name')); + $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ADDED=' . postRequestParameter('pay_name') . '%}'; } else { - // Free memory - SQL_FREERESULT($result); - // Entry does already exists - $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY'), postRequestElement('pay_name')); + $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ALREADY=' . postRequestParameter('pay_name') . '%}'; } + // Free memory + SQL_FREERESULT($result); + // Output message - loadTemplate('admin_settings_saved', false, $message); -} elseif ((isPostRequestElementSet('edit')) || (isPostRequestElementSet('del'))) { + displayMessage($message); +} elseif ((isFormSent('edit')) || (isFormSent('delete'))) { // Load all data - $OUT = ''; $SW = 2; - foreach (postRequestElement('id') as $id => $sel) { + $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) - ); - - if (isPostRequestElementSet('edit')) { + $content = SQL_FETCHARRAY($result); + + if (isFormSent('edit')) { // Edit entry $OUT .= loadTemplate('admin_list_sponsor_pay_edit_row', true, $content); } else { @@ -170,12 +158,12 @@ if (isPostRequestElementSet('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) - if (isPostRequestElementSet('edit')) { + if (isFormSent('edit')) { // Load main edit template loadTemplate('admin_list_sponsor_pay_edit', false, $OUT); } else { @@ -184,43 +172,35 @@ if (isPostRequestElementSet('add')) { } } else { // Load all payment types - $result = SQL_QUERY("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` ORDER BY `pay_name` ASC", - __FILE__, __LINE__); + $result = SQL_QUERY("SELECT + `id`,`pay_name`,`pay_rate`,`pay_min_count`,`pay_currency` +FROM + `{?_MYSQL_PREFIX?}_sponsor_paytypes` +ORDER BY + `pay_name` ASC", + __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 - // Free memory - SQL_FREERESULT($result); - // Load list template $content['list_out'] = loadTemplate('admin_list_sponsor_pay', true, $OUT); } else { // Noting setup so far! - $content['list_out'] = loadTemplate('admin_settings_saved', true, getMessage('ADMIN_SPONSOR_NO_PAYTYPES')); + $content['list_out'] = displayMessage('{--ADMIN_SPONSOR_NO_PAYTYPES--}', true); } + // Free memory + SQL_FREERESULT($result); + // Add new payment types here $content['add_out'] = loadTemplate('admin_add_sponsor_paytype', true);