X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_sponsor_pay.php;h=7da0139c83cf770d3c34677c75241b71f071ad58;hb=b68d7d9622a02f3ea9d44ae3c5dee672b097f956;hp=758b749703ba9f97bfd673b271b9f0a8f52c9849;hpb=357b2ca133fc1f89db74097955c366cb4bee6996;p=mailer.git
diff --git a/inc/modules/admin/what-list_sponsor_pay.php b/inc/modules/admin/what-list_sponsor_pay.php
index 758b749703..7da0139c83 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
- $result = 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($_POST['name'][$id], $_POST['rate'][$id], bigintval($_POST['min'][$id]), $_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 = SPONSOR_PAY_ENTRIES_CHANGED;
- } elseif (isset($_POST['remove'])) {
+ $message = '{--SPONSOR_PAY_ENTRIES_CHANGED--}';
+ } elseif (isFormSent('remove')) {
// Remove entries here...
- foreach ($_POST['id'] as $id => $sel) {
+ foreach (postRequestParameter('id') as $id => $sel) {
// Remove entry
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_sponsor_paytypes WHERE id='%s' LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
}
// Generate message
- $MSG = SPONSOR_PAY_ENTRIES_REMOVED;
+ $message = '{--SPONSOR_PAY_ENTRIES_REMOVED--}';
}
- if (!empty($MSG)) {
+ if (!empty($message)) {
// Output message
- LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
- OUTPUT_HTML("
");
- }
+ displayMessage($message);
+ } // END - if
}
-if (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($_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
- $result = 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($_POST['pay_name']), REVERT_COMMA($_POST['pay_rate']), bigintval($_POST['pay_min_count']), htmlspecialchars($_POST['pay_currency'])),
- __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')",
+ array(
+ postRequestParameter('pay_name'),
+ convertCommaToDot(postRequestParameter('pay_rate')),
+ bigintval(postRequestParameter('pay_min_count')),
+ postRequestParameter('pay_currency')
+ ), __FILE__, __LINE__);
// Payment type added!
- $MSG = SPONSOR_ADMIN_PAYTYPE_ADDED_1.$_POST['pay_name'].SPONSOR_ADMIN_PAYTYPE_ADDED_2;
+ $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ADDED', postRequestParameter('pay_name'));
} else {
- // Free memory
- SQL_FREERESULT($result);
-
// Entry does already exists
- $MSG = SPONSOR_ADMIN_PAYTYPE_ALREADY_1.$_POST['pay_name'].SPONSOR_ADMIN_PAYTYPE_ALREADY_2;
+ $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY', postRequestParameter('pay_name'));
}
+ // Free memory
+ SQL_FREERESULT($result);
+
// Output message
- LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
- OUTPUT_HTML("
");
-} elseif ((isset($_POST['edit'])) || (isset($_POST['del']))) {
+ displayMessage($message);
+} elseif ((isFormSent('edit')) || (isFormSent('delete'))) {
// Load all data
- $OUT = ""; $SW = 2;
- foreach ($_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 (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;
- }
-
- // Remember content in constant
- define('__SPONSOR_ROWS', $OUT);
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - foreach
// Load main template depending on mode (edit/delete)
- if (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
- $SW = 2; $OUT = "";
+ $OUT = '';
// List alle found payment types
- while(list($id, $name, $rate, $min, $currency) = SQL_FETCHROW($result)) {
- // Remember data in array
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'name' => $name,
- 'rate' => TRANSLATE_COMMA($rate),
- 'min' => $min,
- 'currency' => $currency
- );
-
+ while ($content = SQL_FETCHARRAY($result)) {
// Add row
- $OUT .= LOAD_TEMPLATE("admin_list_sponsor_pay_row", true, $content);
-
- // Switch colors
- $SW = 3 - $SW;
- }
-
- // Free memory
- SQL_FREERESULT($result);
-
- // Remember rows in constant for the template
- define('__LIST_ROWS', $OUT);
+ $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
+ } // END - while
// 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, SPONSOR_ADMIN_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]
?>