Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / modules / admin / what-list_payouts.php
index 63ca2e4..00a5e0b 100644 (file)
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * 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')) || (!isAdmin())) {
        die();
-}
+} // END - if
 
 // Add description as navigation point
 addMenuDescription('admin', __FILE__);
 
-if (isGetRequestElementSet(('pid'))) {
+if (isGetRequestParameterSet(('pid'))) {
        // First let's get the member's id
        $result = SQL_QUERY_ESC("SELECT userid, target_account, payout_total, payout_timestamp, password FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
-       array(getRequestElement('pid')), __FILE__, __LINE__);
+               array(getRequestParameter('pid')), __FILE__, __LINE__);
        list($userid, $tuserid, $points, $tstamp, $tpass) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
 
        // Obtain some data
-       if (!isGetRequestElementSet(('task')) && (!empty($userid)) && ($userid > 0)) {
+       if (!isGetRequestParameterSet(('task')) && (!empty($userid)) && ($userid > 0)) {
                // Get task id from database
-               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND task_created='".$tstamp."' LIMIT 1",
-               array(bigintval($userid)), __FILE__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND `task_created`=%s LIMIT 1",
+                       array(bigintval($userid), bigintval($tstamp)), __FILE__, __LINE__);
                list($task) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
                if (empty($task)) $task = '0';
@@ -64,7 +65,7 @@ if (isGetRequestElementSet(('pid'))) {
                loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_FAILED_OBTAIN_USERID'));
        } else {
                // Get task id from URL
-               $task = getRequestElement('task');
+               $task = getRequestParameter('task');
        }
 
        if ((!empty($task)) && (!empty($userid)) && ($userid > 0)) {
@@ -74,12 +75,12 @@ if (isGetRequestElementSet(('pid'))) {
                        debug_report_bug('No user account ' . $userid . ' found.');
                } // END - if
 
-               if ((getRequestElement('do') == 'accept') && (!empty(getUserData('email')))) {
+               if ((getRequestParameter('do') == 'accept') && (!empty(getUserData('email')))) {
                        // Ok, now we can output the form or execute accepting
                        if (isFormSent()) {
                                // Obtain payout type and other data
                                $result = SQL_QUERY_ESC("SELECT `payout_id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
-                                       array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
+                                       array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__);
                                list($ptype) = SQL_FETCHROW($result);
                                SQL_FREERESULT($result);
 
@@ -110,7 +111,7 @@ LIMIT 1",
                                                }
 
                                                // Transfer variables...
-                                               $eval = "\$URL = \"".$eurl."\";";
+                                               $eval = '$url = "' . $eurl . '";';
                                                $reason = encodeString(getMessage('PAYOUT_REASON_PAYOUT'), false);
 
                                                // Run code...
@@ -118,7 +119,7 @@ LIMIT 1",
                                                eval($eval);
 
                                                // Execute transfer
-                                               $ret = sendGetRequest($URL);
+                                               $ret = sendGetRequest($url);
                                        } else {
                                                // No URL to run
                                                $ret[0] = $eok;
@@ -132,10 +133,10 @@ LIMIT 1",
 
                                                // Clear payout request
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='ACCEPTED' WHERE `id`=%s LIMIT 1",
-                                                       array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
+                                                       array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__);
 
                                                // Send out mail
-                                               $message = loadEmailTemplate('member_payout_accepted', postRequestElement('text'), $userid);
+                                               $message = loadEmailTemplate('member_payout_accepted', postRequestParameter('text'), $userid);
 
                                                // Output message
                                                if ($allow == 'Y') {
@@ -155,20 +156,20 @@ LIMIT 1",
                                        }
                                } else {
                                        // Cannot load payout id
-                                       loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">{--PAYOUT_FAILED_OBTAIN_PAYOUT_ID--}</div>");
+                                       loadTemplate('admin_settings_saved', false, '<div class="admin_failed">{--PAYOUT_FAILED_OBTAIN_PAYOUT_ID--}</div>');
                                }
                        } else {
                                // Prepare content
                                $content = array(
                                        'task' => $task,
-                                       'pid'  => bigintval(getRequestElement('pid')),
-                                       'user' => "<a href=\"".generateEmailLink(getUserData('email'), 'user_data')."\">".translateGender(getUserData('gender'))." ".getUserData('surname')." ".getUserData('family')."</a>",
+                                       'pid'  => bigintval(getRequestParameter('pid')),
+                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
                                );
 
                                // Load template
                                loadTemplate('admin_payout_accept_form', false, $content);
                        }
-               } elseif ((getRequestElement('do') == 'reject') && (!empty(getUserData('email')))) {
+               } elseif ((getRequestParameter('do') == 'reject') && (!empty(getUserData('email')))) {
                        // Ok, now we can output the form or execute rejecting
                        if (isFormSent()) {
                                if ($task > 0) {
@@ -178,10 +179,10 @@ LIMIT 1",
 
                                // Clear payout request
                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='REJECTED' WHERE `id`=%s LIMIT 1",
-                                       array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
+                                       array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__);
 
                                // Send out mail
-                               $message = loadEmailTemplate('member_payout_rejected', postRequestElement('text'), $userid);
+                               $message = loadEmailTemplate('member_payout_rejected', postRequestParameter('text'), $userid);
 
                                // Output message
                                loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_REJECTED_NOTIFIED'));
@@ -192,8 +193,8 @@ LIMIT 1",
                                // Prepare content
                                $content = array(
                                        'task' => $task,
-                                       'pid'  => bigintval(getRequestElement('pid')),
-                                       'user' => "<a href=\"".generateEmailLink(getUserData('email'), 'user_data')."\">".translateGender(getUserData('gender'))." ".getUserData('surname')." ".getUserData('family')."</a>",
+                                       'pid'  => bigintval(getRequestParameter('pid')),
+                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
                                );
 
                                // Load template
@@ -208,9 +209,7 @@ LIMIT 1",
                loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_FAILED_OBTAIN_TASK_ID'));
        }
 } else {
-       if (!isGetRequestElementSet('do')) setRequestGetElement('do', '');
-
-       if (getRequestElement('do') == 'delete') {
+       if (getRequestParameter('do') == 'delete') {
                // Delete all requests
                $result = SQL_QUERY("TRUNCATE `{?_MYSQL_PREFIX?}_user_payouts`", __FILE__, __LINE__);
        } // END - if
@@ -236,11 +235,11 @@ ORDER BY
                while ($content = SQL_FETCHARRAY($result)) {
                        if ($content['status'] == 'NEW') {
                                // Generate links for direct accepting and rejecting
-                               $content['status'] = "<a href=\"{?URL?}/modules.php?module=admin&amp;what=list_payouts&amp;do=accept&amp;pid=".$content['id']."\">".PAYOUT_ACCEPT_PAYOUT."</a>&nbsp;|&nbsp;<a href=\"{?URL?}/modules.php?module=admin&amp;what=list_payouts&amp;do=reject&amp;pid=".$content['id']."\">".PAYOUT_REJECT_PAYOUT."</a>";
+                               $content['status'] = '<a href="{%url=modules.php?module=admin&amp;what=list_payouts&amp;do=accept&amp;pid=' . $content['id'] . '%}">{--PAYOUT_ACCEPT_PAYOUT--}</a>&nbsp;|&nbsp;<a href="{%url=modules.php?module=admin&amp;what=list_payouts&amp;do=reject&amp;pid=' . $content['id'] . '%}">{--PAYOUT_REJECT_PAYOUT--}</a>';
                        } else {
                                // Translate status
                                $content['status'] = getMessage('PAYOUT_STATUS_'.strtoupper($content['status']).'');
-                               $content['status'] = "<div class=\"admin_failed\">".$content['status']."</div>";
+                               $content['status'] = '<div class="admin_failed">' . $content['status'] . '</div>';
                        }
 
                        // Nothing entered must be secured in member/what-payputs.php !
@@ -255,7 +254,7 @@ ORDER BY
                                }
 
                                // Admins can addionally test the URL for framekillers
-                               $content['target_bank'] = "<a href=\"".generateFrametesterUrl($content['url'])."\" target=\"_blank\">{--CLICK_HERE--}</a>";
+                               $content['target_bank'] = '<a href="' . generateFrametesterUrl($content['url']) . '" target="_blank">{--CLICK_HERE--}</a>';
                        } else {
                                // e-currency payout request
                                if (empty($content['target_account'])) $content['target_account'] = '---';
@@ -276,7 +275,7 @@ ORDER BY
                        // Add row and switch color
                        $OUT .= loadTemplate('admin_list_payouts_row', true, $content);
                        $SW = 3 - $SW;
-               }
+               } // END - while
 
                // Free memory
                SQL_FREERESULT($result);