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=12098ede2f5f57a6fdc8fe15deef15af763709a4;hb=0f3a135204757cc8750262871c8e62c42300acb4;hpb=4001187f22197f55e5a1f211fc8defcc180f7c32 diff --git a/inc/modules/admin/what-list_sponsor_pay.php b/inc/modules/admin/what-list_sponsor_pay.php index 12098ede2f..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 - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_sponsor_paytypes` -SET pay_name='%s', pay_rate='%s', pay_min_count='%s', pay_currency='%s' WHERE id='%s' LIMIT 1", - array( - REQUEST_POST('name', $id), - REQUEST_POST('rate', $id), - bigintval(REQUEST_POST('min', $id)), - REQUEST_POST('curr', $id), - $id - ), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_sponsor_paytypes` +SET + `pay_name`='%s', + `pay_rate`='%s', + `pay_min_count`='%s', + `pay_currency`='%s' +WHERE + `id`=%s +LIMIT 1", + array( + postRequestParameter('name', $id), + postRequestParameter('rate', $id), + bigintval(postRequestParameter('min', $id)), + postRequestParameter('curr', $id), + $id + ), __FILE__, __LINE__); } // Generate message - $MSG = getMessage('SPONSOR_PAY_ENTRIES_CHANGED'); - } elseif (REQUEST_ISSET_POST(('remove'))) { + $message = '{--SPONSOR_PAY_ENTRIES_CHANGED--}'; + } elseif (isFormSent('do_delete')) { // Remove entries here... - foreach (REQUEST_POST('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 - $MSG = getMessage('SPONSOR_PAY_ENTRIES_REMOVED'); + $message = '{--SPONSOR_PAY_ENTRIES_REMOVED--}'; } - if (!empty($MSG)) { + if (!empty($message)) { // Output message - LOAD_TEMPLATE("admin_settings_saved", false, $MSG); - } + displayMessage($message); + } // END - if } -if (REQUEST_ISSET_POST(('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(REQUEST_POST('pay_name')), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) { + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1", + 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( - htmlspecialchars(REQUEST_POST('pay_name')), - REVERT_COMMA(REQUEST_POST('pay_rate')), - bigintval(REQUEST_POST('pay_min_count')), - htmlspecialchars(REQUEST_POST('pay_currency')) + postRequestParameter('pay_name'), + convertCommaToDot(postRequestParameter('pay_rate')), + bigintval(postRequestParameter('pay_min_count')), + postRequestParameter('pay_currency') ), __FILE__, __LINE__); // Payment type added! - $MSG = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ADDED'), REQUEST_POST('pay_name')); + $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ADDED=' . postRequestParameter('pay_name') . '%}'; } else { - // Free memory - SQL_FREERESULT($result); - // Entry does already exists - $MSG = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY'), REQUEST_POST('pay_name')); + $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ALREADY=' . postRequestParameter('pay_name') . '%}'; } + // Free memory + SQL_FREERESULT($result); + // Output message - LOAD_TEMPLATE("admin_settings_saved", false, $MSG); -} elseif ((REQUEST_ISSET_POST('edit')) || (REQUEST_ISSET_POST('del'))) { + displayMessage($message); +} elseif ((isFormSent('edit')) || (isFormSent('delete'))) { // Load all data - $OUT = ""; $SW = 2; - foreach (REQUEST_POST('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", - array(bigintval($id)), __FILE__, __LINE__); + $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' => TRANSLATE_COMMA($rate), - 'min' => bigintval($min), - 'curr' => htmlspecialchars($curr) - ); - - if (REQUEST_ISSET_POST('edit')) { + $content = SQL_FETCHARRAY($result); + + if (isFormSent('edit')) { // Edit entry - $OUT .= LOAD_TEMPLATE("admin_list_sponsor_pay_edit_row", true, $content); + $OUT .= loadTemplate('admin_list_sponsor_pay_edit_row', true, $content); } else { // Delete entry - $OUT .= LOAD_TEMPLATE("admin_list_sponsor_pay_del_row", true, $content); + $OUT .= loadTemplate('admin_list_sponsor_pay_del_row', true, $content); } } else { // Entry invalid - $OUT .= LOAD_TEMPLATE("admin_list_sponsor_pay_404", true, $id); + $OUT .= loadTemplate('admin_list_sponsor_pay_404', true, $id); } - // Switch colors - $SW = 3 - $SW; + // Free result + SQL_FREERESULT($result); } // END - foreach - // Remember content in constant - define('__SPONSOR_ROWS', $OUT); - // Load main template depending on mode (edit/delete) - if (REQUEST_ISSET_POST('edit')) { + if (isFormSent('edit')) { // Load main edit template - LOAD_TEMPLATE("admin_list_sponsor_pay_edit"); + loadTemplate('admin_list_sponsor_pay_edit', false, $OUT); } else { // Load main delete template - LOAD_TEMPLATE("admin_list_sponsor_pay_del"); + loadTemplate('admin_list_sponsor_pay_del', false, $OUT); } } 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", - __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' => TRANSLATE_COMMA($content['pay_rate']), - 'min' => $content['pay_min_count'], - 'currency' => $content['pay_currency'] - ); - // Add row - $OUT .= LOAD_TEMPLATE("admin_list_sponsor_pay_row", true, $content); - - // Switch colors - $SW = 3 - $SW; + $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content); } // END - while - // Free memory - SQL_FREERESULT($result); - - // Remember rows in constant for the template - define('__LIST_ROWS', $OUT); - // Load list template - define('__LIST_CONTENT', LOAD_TEMPLATE("admin_list_sponsor_pay", true)); + $content['list_out'] = loadTemplate('admin_list_sponsor_pay', true, $OUT); } else { // Noting setup so far! - define('__LIST_CONTENT', LOAD_TEMPLATE("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 - define('__ADD_CONTENT', LOAD_TEMPLATE("admin_add_sponsor_paytype", true)); + $content['add_out'] = loadTemplate('admin_add_sponsor_paytype', true); // Load final template - LOAD_TEMPLATE("admin_sponsor_paytypes"); + loadTemplate('admin_sponsor_paytypes', false, $content); } -// +// [EOF] ?>