Huge script change, see http://forum.mxchange.org/topic-458.html for details:
[mailer.git] / inc / modules / admin / what-list_sponsor_pay.php
index 476b21863cbaaeafbbfe0435749ad8a5a7844bf1..ad8ff06b09af15e50387dbf9c7245cf2aaf0f47d 100644 (file)
@@ -17,7 +17,7 @@
  * Needs to be in all Files and every File needs "svn propset           *
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  ************************************************************************/
 
 // Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
-       require($INC);
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
 } // END - if
 
 // Add description as navigation point
-ADD_DESCR('admin', __FILE__);
+addMenuDescription('admin', __FILE__);
 
 $message = '';
 
-if (REQUEST_ISSET_POST('add')) {
+if (isPostRequestElementSet('add')) {
        // Check input variables
-       if (!REQUEST_ISSET_POST('pay_name')) REQUEST_UNSET_POST('add');
-       if ((round(REQUEST_POST('pay_rate')) == 0) || (!REQUEST_ISSET_POST('pay_rate'))) REQUEST_UNSET_POST('add');
+       if (!isPostRequestElementSet('pay_name')) unsetPostRequestElement('add');
+       if ((round(postRequestElement('pay_rate')) == 0) || (!isPostRequestElementSet('pay_rate'))) unsetPostRequestElement('add');
 
-       REQUEST_SET_POST('pay_min_count', bigintval(REQUEST_POST('pay_min_count')));
+       setRequestPostElement('pay_min_count', bigintval(postRequestElement('pay_min_count')));
 
-       if ((REQUEST_POST('pay_min_count') == 0) || (!REQUEST_ISSET_POST('pay_min_count'))) REQUEST_UNSET_POST('add');
-       if (!REQUEST_ISSET_POST('pay_currency')) REQUEST_UNSET_POST('add');
+       if ((postRequestElement('pay_min_count') == 0) || (!isPostRequestElementSet('pay_min_count'))) unsetPostRequestElement('add');
+       if (!isPostRequestElementSet('pay_currency')) unsetPostRequestElement('add');
 
-} elseif ((REQUEST_ISSET_POST('edit')) || (REQUEST_ISSET_POST('del')) || (REQUEST_ISSET_POST('change')) || (REQUEST_ISSET_POST('remove'))) {
+} elseif ((isPostRequestElementSet('edit')) || (isPostRequestElementSet('del')) || (isPostRequestElementSet('change')) || (isPostRequestElementSet('remove'))) {
        // Check if at least one entry was selected
-       if (!REQUEST_ISSET_POST('id')) {
+       if (!isPostRequestElementSet('id')) {
                // Nothing selected for editing / deleting???
-               REQUEST_UNSET_POST('edit');
-               REQUEST_UNSET_POST('del');
-               REQUEST_UNSET_POST('change');
-               REQUEST_UNSET_POST('remove');
-       } elseif (REQUEST_ISSET_POST('change')) {
+               unsetPostRequestElement('edit');
+               unsetPostRequestElement('del');
+               unsetPostRequestElement('change');
+               unsetPostRequestElement('remove');
+       } elseif (isPostRequestElementSet('change')) {
                // Change entries here...
-               foreach (REQUEST_POST('id') as $id => $sel) {
+               foreach (postRequestElement('id') as $id => $sel) {
                        // Secure ID
                        $id = bigintval($id);
 
                        // Save entry
                        SQL_QUERY_ESC("UPDATE
-       `{!_MYSQL_PREFIX!}_sponsor_paytypes`
+       `{?_MYSQL_PREFIX?}_sponsor_paytypes`
 SET
        `pay_name`='%s',
        `pay_rate`='%s',
@@ -83,21 +82,21 @@ WHERE
        `id`='%s'
 LIMIT 1",
                        array(
-                               REQUEST_POST('name', $id),
-                               REQUEST_POST('rate', $id),
-                               bigintval(REQUEST_POST('min', $id)),
-                               REQUEST_POST('curr', $id),
+                               postRequestElement('name', $id),
+                               postRequestElement('rate', $id),
+                               bigintval(postRequestElement('min', $id)),
+                               postRequestElement('curr', $id),
                                $id
                        ), __FILE__, __LINE__);
                }
 
                // Generate message
                $message = getMessage('SPONSOR_PAY_ENTRIES_CHANGED');
-       } elseif (REQUEST_ISSET_POST('remove')) {
+       } elseif (isPostRequestElementSet('remove')) {
                // Remove entries here...
-               foreach (REQUEST_POST('id') as $id => $sel) {
+               foreach (postRequestElement('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__);
                }
 
@@ -107,42 +106,42 @@ LIMIT 1",
 
        if (!empty($message)) {
                // Output message
-               LOAD_TEMPLATE('admin_settings_saved', false, $message);
+               loadTemplate('admin_settings_saved', false, $message);
        } // END - if
 }
 
-if (REQUEST_ISSET_POST('add')) {
+if (isPostRequestElementSet('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__);
+       $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) {
                // 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(
-                               REQUEST_POST('pay_name'),
-                               convertCommaToDot(REQUEST_POST('pay_rate')),
-                               bigintval(REQUEST_POST('pay_min_count')),
-                               REQUEST_POST('pay_currency')
+                               postRequestElement('pay_name'),
+                               convertCommaToDot(postRequestElement('pay_rate')),
+                               bigintval(postRequestElement('pay_min_count')),
+                               postRequestElement('pay_currency')
                        ), __FILE__, __LINE__);
 
                // Payment type added!
-               $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ADDED'), REQUEST_POST('pay_name'));
+               $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ADDED'), postRequestElement('pay_name'));
        } else {
                // Free memory
                SQL_FREERESULT($result);
 
                // Entry does already exists
-               $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY'), REQUEST_POST('pay_name'));
+               $message = sprintf(getMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY'), postRequestElement('pay_name'));
        }
 
        // Output message
-       LOAD_TEMPLATE('admin_settings_saved', false, $message);
-} elseif ((REQUEST_ISSET_POST('edit')) || (REQUEST_ISSET_POST('del'))) {
+       loadTemplate('admin_settings_saved', false, $message);
+} elseif ((isPostRequestElementSet('edit')) || (isPostRequestElementSet('del'))) {
        // Load all data
        $OUT = ''; $SW = 2;
-       foreach (REQUEST_POST('id') as $id => $sel) {
+       foreach (postRequestElement('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 `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
@@ -159,36 +158,33 @@ if (REQUEST_ISSET_POST('add')) {
                                'curr' => htmlspecialchars($curr)
                        );
 
-                       if (REQUEST_ISSET_POST('edit')) {
+                       if (isPostRequestElementSet('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;
        } // END - foreach
 
-       // Remember content in constant
-       define('__SPONSOR_ROWS', $OUT);
-
        // Load main template depending on mode (edit/delete)
-       if (REQUEST_ISSET_POST('edit')) {
+       if (isPostRequestElementSet('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` ASC",
+       $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?
@@ -209,7 +205,7 @@ if (REQUEST_ISSET_POST('add')) {
                        );
 
                        // Add row
-                       $OUT .= LOAD_TEMPLATE('admin_list_sponsor_pay_row', true, $content);
+                       $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
 
                        // Switch colors
                        $SW = 3 - $SW;
@@ -218,22 +214,19 @@ if (REQUEST_ISSET_POST('add')) {
                // 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'] = loadTemplate('admin_settings_saved', true, getMessage('ADMIN_SPONSOR_NO_PAYTYPES'));
        }
 
        // 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]
 ?>