Rewrote a lot parts to extract 'payments' table (+ handling) into own extension:
authorRoland Häder <roland@mxchange.org>
Tue, 22 Jan 2013 22:12:18 +0000 (22:12 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 22 Jan 2013 22:12:18 +0000 (22:12 +0000)
- Tried to avoid JOINs where possible to instead load data with getters from
  cache
- Renamed many array elements for payment data to match with database columns
- Used more EL code for payment data
- TODOs.txt updated

28 files changed:
DOCS/TODOs.txt
inc/libs/rallye_functions.php
inc/loader/load-
inc/loader/load-imprint.php
inc/loader/load-payments.php
inc/modules/admin/what-del_email.php
inc/modules/admin/what-list_unconfirmed.php
inc/modules/admin/what-payments.php
inc/modules/admin/what-unlock_emails.php
inc/modules/member/what-order.php
inc/modules/member/what-unconfirmed.php
inc/modules/order.php
inc/mysql-manager.php
inc/pool/pool-user.php
inc/purge/purge-general.php
templates/de/html/member/member_list_unconfirmed_nopoints_row.tpl
templates/de/html/member/member_list_unconfirmed_row.tpl
templates/de/html/member/member_mail_bonus_deleted.tpl
templates/de/html/member/member_mail_bonus_new.tpl
templates/de/html/member/member_mail_bonus_queue.tpl
templates/de/html/member/member_mail_bonus_send.tpl
templates/de/html/member/member_mail_normal_active.tpl
templates/de/html/member/member_mail_normal_admin.tpl
templates/de/html/member/member_mail_normal_deleted.tpl
templates/de/html/member/member_mail_normal_new.tpl
templates/de/html/member/member_mail_normal_send.tpl
templates/de/html/member/member_mail_normal_temp.tpl
templates/de/html/member/member_order_page2.tpl

index 821c7cc..2d24e2b 100644 (file)
 ./inc/modules/admin/what-bonus.php:46:// @TODO Unused at the moment
 ./inc/modules/admin/what-config_points.php:90:                         // @TODO Rewrite these two lines for new user_points columns (e.g. locked_order_points) with a filter
 ./inc/modules/admin/what-config_register.php:79:       // @TODO Move this HTML code into a template
-./inc/modules/admin/what-del_email.php:61:             // @TODO Unused: cat_id, payment_id
+./inc/modules/admin/what-del_email.php:57:             // @TODO Unused: cat_id
 ./inc/modules/admin/what-edit_user.php:18: * @TODO Add support for ext-country                                    *
 ./inc/modules/admin/what-email_stats.php:46:// @TODO Unused at the moment
 ./inc/modules/admin/what-extensions.php:366:                                           // @TODO Rewrite this to a filter
 ./inc/modules/admin/what-mem_add.php:124:                              // @TODO This can be somehow rewritten to a function
 ./inc/modules/admin/what-mem_add.php:63:               // @TODO Cant this be rewritten?
 ./inc/modules/admin/what-mem_add.php:79:               // @TODO This can be somehow rewritten to a function
-./inc/modules/admin/what-unlock_emails.php:95:                                 // @TODO Rewrite these if-blocks to a filter
+./inc/modules/admin/what-unlock_emails.php:93:                                 // @TODO Rewrite these if-blocks to a filter
 ./inc/modules/admin/what-usage.php:89: // @TODO This code is double, see loadTemplate() and loadEmailTemplate() in functions.php
 ./inc/modules/admin/what-usr_online.php:49:    // @TODO Add a filter for sponsor
 ./inc/modules/frametester.php:95:      // @TODO Rewrite this somehow
 ./inc/modules/member/what-rallyes.php:99:      // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;id=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
 ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter
 ./inc/modules/member/what-transfer.php:128:                            // @TODO Rewrite this to a filter
-./inc/modules/member/what-unconfirmed.php:178: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/member/what-unconfirmed.php:177: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/member/what-unconfirmed.php:244:                 // @TODO cat_id is unused
 ./inc/modules/member/what-unconfirmed.php:247:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
 ./inc/modules/order.php:78:            // @TODO Unused: 2,4
-./inc/mysql-manager.php:1492:          // @TODO Rewrite these lines to a filter
-./inc/mysql-manager.php:1516:  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1832:                  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:2000:                          // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
-./inc/mysql-manager.php:2123:                  // @TODO Used generic 'userid' here
-./inc/mysql-manager.php:2344:// @TODO cacheFiles is not yet supported
+./inc/mysql-manager.php:1498:          // @TODO Rewrite these lines to a filter
+./inc/mysql-manager.php:1522:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1838:                  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2006:                          // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
+./inc/mysql-manager.php:2129:                  // @TODO Used generic 'userid' here
+./inc/mysql-manager.php:2350:// @TODO cacheFiles is not yet supported
 ./inc/mysql-manager.php:408:   // @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/revision-functions.php:168:// @TODO This function does also set and get in 'cache_array'
index 1d69791..b599a0f 100644 (file)
@@ -972,10 +972,10 @@ FROM
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_refdepths` AS `d`
 ON
-       s.`level`=`d`.`level`
+       `s`.`level`=`d`.`level`
 WHERE
-       s.`userid`=%s AND
-       s.`level`=1",
+       `s`.`userid`=%s AND
+       `s`.`level`=1",
                        array(
                                bigintval($userid)
                        ), __FUNCTION__, __LINE__);
index aeedfc5..7be34fe 100644 (file)
@@ -51,9 +51,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('foo')) && ($GLOBALS['cache_insta
        // Create cache file
        $GLOBALS['cache_instance']->init();
 
-       // Load every data from DB to cache file
-       //$add = runFilterChain('sql_admin_extra_data');
-
        // Query the database about this
        $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_foos` ORDER BY `some_bar` ASC', __FILE__, __LINE__);
        while ($dummy = SQL_FETCHARRAY($result)) {
index eb1d818..05031b4 100644 (file)
@@ -54,9 +54,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('imprint')) && ($GLOBALS['cache_i
        // Create cache file
        $GLOBALS['cache_instance']->init();
 
-       // Load every data from DB to cache file
-       $add = runFilterChain('sql_admin_extra_data');
-
        // Query the database about this
        $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_imprint_data` ORDER BY `imprint_id` ASC', __FILE__, __LINE__);
        while ($row = SQL_FETCHARRAY($result)) {
index 6a6ce9d..c861e22 100644 (file)
@@ -70,9 +70,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('payments')) && ($GLOBALS['cache_
        // Create cache file
        $GLOBALS['cache_instance']->init();
 
-       // Load every data from DB to cache file
-       //$add = runFilterChain('sql_admin_extra_data');
-
        // Query the database about this
        $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `id` ASC', __FILE__, __LINE__);
        while ($dummy = SQL_FETCHARRAY($result)) {
index 1ffcee8..60705d4 100644 (file)
@@ -54,12 +54,9 @@ if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (post
        // Delete mail only once
        if (SQL_NUMROWS($result) == 1) {
                // Load data
+               // @TODO Unused: cat_id
                $content = SQL_FETCHARRAY($result);
 
-               // Get points we shall pay back per mail
-               $content['price'] = getPaymentData($content['payment_id'], 'price');
-               // @TODO Unused: cat_id, payment_id
-
                // Prepare data for the template
                $content['timestamp'] = generateDateTime($content['timestamp'], 0);
 
@@ -72,15 +69,15 @@ if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (post
 
                // Fetch right stats_id from pool
                $result_pool = SQL_QUERY_ESC("SELECT
-       s.`id`
+       `s`.`id`
 FROM
        `{?_MYSQL_PREFIX?}_user_stats` AS `s`
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_pool` AS `p`
 ON
-       s.`pool_id`=`p`.`id`
+       `s`.`pool_id`=`p`.`id`
 WHERE
-       s.`pool_id`=%s
+       `s`.`pool_id`=%s
 LIMIT 1",
                        array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
                if (SQL_NUMROWS($result_pool) == 1) {
index 4a87666..aec2a69 100644 (file)
@@ -58,19 +58,19 @@ $sql = '';
 if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
        // SQL query for mail data
        $sql = sprintf("SELECT
-       s.`id`,
+       `s`.`id`,
        `p`.`sender`,
        `p`.`subject`,
        `p`.`text`,
        `p`.`url`,
        `p`.`timestamp`,
-       s.`max_rec`
+       `s`.`max_rec`
 FROM
        `{?_MYSQL_PREFIX?}_pool` AS `p`
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_user_stats` AS `s`
 ON
-       `p`.`id`=s.`pool_id`
+       `p`.`id`=`s`.`pool_id`
 WHERE
        `p`.`id`=%s
 LIMIT 1",
index 0f11f5f..7a1def3 100644 (file)
@@ -47,25 +47,55 @@ if (((!isPostRequestElementSet('t_wait')) || (!isPostRequestElementSet('payment'
        unsetPostRequestElement('ok');
 } // END - if
 
+// Init SQL array
+nitSqls();
+
 if (isFormSent()) {
        switch (getRequestElement('do')) {
                case 'add':
-                       addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestElement('t_wait')."','".postRequestElement('payment')."','".postRequestElement('title')."','".postRequestElement('price')."')");
-                       if (countSumTotalData(postRequestElement('t_wait'), 'payments', 'id', 'time', TRUE) == 1) {
-                               // Re-init the array here
-                               initSqls();
+                       if (countSumTotalData(postRequestElement('t_wait'), 'payments', 'id', 'time', TRUE) == 0) {
+                               addSql("INSERT INTO
+       `{?_MYSQL_PREFIX?}_payments`
+(
+       `time`,
+       `payment`,
+       `mail_title`,
+       `price`
+) VALUES (
+       '" . postRequestElement('t_wait') . "',
+       '" . postRequestElement('payment') . "',
+       '" . postRequestElement('title') . "',
+       '" . postRequestElement('price') . "'
+)");
                        } // END - if
                        break;
 
                case 'edit':
                        foreach (postRequestElement('time') as $id => $value) {
-                               addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "',`payment`='".postRequestElement('payment', $id)."', price='".postRequestElement('price', $id)."', mail_title='".postRequestElement('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1");
+                               // Secure id
+                               $id = bigintval($id);
+
+                               // Add UPDATE
+                               addSql("UPDATE
+       `{?_MYSQL_PREFIX?}_payments`
+SET
+       `time`='" . $value . "',
+       `payment`='" . postRequestElement('payment', $id) . "',
+       `price`='" . postRequestElement('price', $id) . "',
+       `mail_title`='" . postRequestElement('mail_title', $id) . "'
+WHERE
+       `id`='" . $id . "'
+LIMIT 1");
                        } // END - foreach
                        break;
 
                case 'delete':
                        foreach (postRequestElement('id') as $id => $value) {
-                               addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
+                               // Secure id
+                               $id = bigintval($id);
+
+                               // Add DELETE
+                               addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . $id . " LIMIT 1");
                        } // END - foreach
                        break;
        } // END - switch
@@ -91,7 +121,17 @@ if (isFormSent()) {
        // Delete entries here
        $OUT = '';
        foreach (postRequestElement('sel') as $id => $value) {
-               $result = SQL_QUERY_ESC("SELECT `id`, `time`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT
+       `id`,
+       `time`,
+       `payment`,
+       `mail_title`,
+       `price`
+FROM
+       `{?_MYSQL_PREFIX?}_payments`
+WHERE
+       `id`=%s
+LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
                $content = SQL_FETCHARRAY($result);
 
@@ -108,7 +148,17 @@ if (isFormSent()) {
        // Edit entries
        $OUT = '';
        foreach (postRequestElement('sel') as $id => $value) {
-               $result = SQL_QUERY_ESC("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT
+       `id`,
+       `time`,
+       `payment`,
+       `mail_title`,
+       `price`
+FROM
+       `{?_MYSQL_PREFIX?}_payments`
+WHERE
+       `id`=%s
+LIMIT 1",
                        array(bigintval($id)), __FILE__, __LINE__);
                $content = SQL_FETCHARRAY($result);
 
@@ -123,7 +173,16 @@ if (isFormSent()) {
        loadTemplate('admin_edit_payments', FALSE, $OUT);
 } else {
        // Referral levels
-       $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
+       $result = SQL_QUERY("SELECT
+       `id`,
+       `time`,
+       `payment`,
+       `mail_title`,
+       `price`
+FROM
+       `{?_MYSQL_PREFIX?}_payments`
+ORDER BY
+       `time` ASC", __FILE__, __LINE__);
        if (!SQL_HASZERONUMS($result)) {
                // Make referral levels editable and deletable
                $OUT = '';
index f23946d..980ee0c 100644 (file)
@@ -70,19 +70,14 @@ if ((!SQL_HASZERONUMS($result_main)) || (isFormSent('lock'))) {
 
                                // Order placed in queue...
                                $result = SQL_QUERY_ESC('SELECT
-       po.`url`,
-       po.`subject`,
-       po.`sender`,
-       pay.`payment`,
-       po.`payment_id`
+       `url`,
+       `subject`,
+       `sender`,
+       `payment_id`
 FROM
-       `{?_MYSQL_PREFIX?}_pool` AS `po`
-INNER JOIN
-       `{?_MYSQL_PREFIX?}_payments` AS `pay`
-ON
-       po.`payment_id`=pay.`id`
+       `{?_MYSQL_PREFIX?}_pool`
 WHERE
-       po.`id`=%s
+       `id`=%s
 LIMIT 1',
                                        array($id), __FILE__, __LINE__);
 
@@ -91,6 +86,9 @@ LIMIT 1',
                                        // Load data
                                        $content = SQL_FETCHARRAY($result);
 
+                                       // Get payment from getter to avoid JOIN
+                                       $content['payment'] = getPaymentData($content['payment_id', 'payment');
+
                                        // Is the surfbar installed?
                                        // @TODO Rewrite these if-blocks to a filter
                                        if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
index a1f7a2a..0cc9a78 100644 (file)
@@ -245,7 +245,7 @@ LIMIT 1",
                        } // END - if
 
                        // Calculate used points
-                       $usedPoints = $content['target_send'] * getPaymentData(bigintval(postRequestElement('mail_type')));
+                       $usedPoints = $content['target_send'] * getPaymentPrice(bigintval(postRequestElement('mail_type')));
 
                        // Fix empty zip code
                        if (!isPostRequestElementSet('zip')) {
@@ -636,13 +636,13 @@ LIMIT 1",
                                        $content['category_selection'] = generateCategoryOptionsList(((isExtensionActive('html_mail')) && (isPostRequestElementSet('html'))) ? postRequestElement('html') : 'N', getMemberId());
 
                                        // Mail type
-                                       $content['type_selection'] = '';
+                                       $content['payment_selection'] = '';
                                        foreach ($payments as $key => $value) {
                                                if (is_array($value)) {
                                                        // Output option line
-                                                       $content['type_selection'] .= '      <option value="' . $payments[$key]['id'] . '"';
-                                                       if (($OLD_ORDER) && ($content['payment_id'] == $payments[$key]['id'])) $content['type_selection'] .= ' selected="selected"';
-                                                       $content['type_selection'] .= '>{%pipe,translateComma=' . $payments[$key]['price'] . '%} {--PER_MAIL--} - ' . $payments[$key]['mail_title'] . ' - ' . round($payments[$key]['payment']) . ' {--PAYMENT--}</option>';
+                                                       $content['payment_selection'] .= '      <option value="' . $payments[$key]['id'] . '"';
+                                                       if (($OLD_ORDER) && ($content['payment_id'] == $payments[$key]['id'])) $content['payment_selection'] .= ' selected="selected"';
+                                                       $content['payment_selection'] .= '>{%pipe,translateComma=' . $payments[$key]['price'] . '%} {--PER_MAIL--} - ' . $payments[$key]['mail_title'] . ' - ' . round($payments[$key]['payment']) . ' {--PAYMENT--}</option>';
                                                } // END - if
                                        } // END - foreach
 
index f64ae4c..d2fe6db 100644 (file)
@@ -103,14 +103,13 @@ LIMIT 1',
 } elseif (isGetRequestElementSet('mailid')) {
        // Display regular member mail by loading its full data
        $result_data = SQL_QUERY_ESC("SELECT
-       s.`id`,
-       s.`subject`,
+       `s`.`id`,
+       `s`.`subject`,
        `p`.`text`,
-       s.`timestamp_ordered` AS `timestamp`,
-       s.`cat_id`,
-       pay.`price` AS `points`,
+       `s`.`timestamp_ordered` AS `timestamp`,
+       `s`.`cat_id`,
+       `p`.`payment_id`,
        `p`.`sender`,
-       pay.`time`,
        `p`.`data_type`
 FROM
        `{?_MYSQL_PREFIX?}_user_stats` AS `s`
@@ -118,18 +117,18 @@ LEFT JOIN
        `{?_MYSQL_PREFIX?}_pool` AS `p`
 ON
        s.pool_id=p.id
-LEFT JOIN
-       `{?_MYSQL_PREFIX?}_payments` AS `pay`
-ON
-       `p`.`payment_id`=pay.`id`
 WHERE
-       s.`id`=%s
+       `s`.`id`=%s
 LIMIT 1",
                array(bigintval(getRequestElement('mailid'))), __FILE__, __LINE__);
 
        // Load data
        $content = SQL_FETCHARRAY($result_data);
 
+       // Get price/time to avoid one JOIN
+       $content['price'] = getPaymentPrice($content['payment_id']);
+       $content['time']  = getPaymentData($content['payment_id'], 'time');
+
        // Translate some data
        $content['timestamp'] = generateDateTime($content['timestamp'], '2');
        $content['userid'] = getMemberId();
@@ -185,19 +184,19 @@ if (!SQL_HASZERONUMS($result)) {
                switch ($row['link_type']) {
                        case 'NORMAL':
                                $result_data = SQL_QUERY_ESC("SELECT
-       s.`subject`,
-       s.`timestamp_ordered` AS `timestamp`,
-       s.`cat_id`,
-       s.`payment_id`,
+       `s`.`subject`,
+       `s`.`timestamp_ordered` AS `timestamp`,
+       `s`.`cat_id`,
+       `s`.`payment_id`,
        `p`.`sender`
 FROM
        `{?_MYSQL_PREFIX?}_user_stats` AS `s`
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_pool` AS `p`
 ON
-       s.`pool_id`=`p`.`id`
+       `s`.`pool_id`=`p`.`id`
 WHERE
-       s.`id`=%s
+       `s`.`id`=%s
 LIMIT 1",
                                        array(bigintval($row['stats_id'])), __FILE__, __LINE__);
                                $row['link_type'] = 'mailid';
@@ -221,59 +220,60 @@ LIMIT 1",
                // Data found to this mail?
                if ((SQL_NUMROWS($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
                        // Mail was found
-                       list($subject, $timestamp, $cat, $pay, $sender) = SQL_FETCHROW($result_data);
+                       $rowData = SQL_FETCHARRAY($result_data);
 
                        // Subject line found?
-                       if (empty($subject)) {
+                       if (empty($rowData['subject'])) {
                                // No subject line!
-                               $subject = '{--DEFAULT_SUBJECT--}';
+                               $rowData['subject'] = '{--DEFAULT_SUBJECT--}';
                        } // END - if
 
                        // Prepare sender id
-                       if ((isValidId($sender)) && ($row['link_type'] == 'mailid')) {
+                       if ((isValidId($rowData['sender'])) && ($row['link_type'] == 'mailid')) {
                                // Sender id
-                               $sender = bigintval($sender);
+                               $rowData['sender'] = bigintval($rowData['sender']);
                        } elseif ($row['link_type'] == 'bonusid') {
                                // Is admin
-                               $sender = '{--USERNAME_ADMIN_SHORT--}';
+                               $rowData['sender'] = '{--USERNAME_ADMIN_SHORT--}';
                        } else {
                                // Deleted
-                               $sender = '{--EMAIL_STATUS_DELETED--}';
+                               $rowData['sender'] = '{--EMAIL_STATUS_DELETED--}';
                        }
 
                        // Prepare data for template
-                       $content = array(
-                               'data'      => bigintval($data),
+                       // @TODO cat_id is unused
+                       $rowData = array(
+                               'data'              => bigintval($data),
                                // @TODO This 'userid' cannot be saved because of encapsulated EL code
-                               'userid'    => getMemberId(),
-                               'link_type' => $row['link_type'],
-                               'subject'   => $subject,
-                               'sender'    => $sender,
-                               'timestamp' => generateDateTime($timestamp, 2),
-                               'points'    => $pay,
+                               'userid'            => getMemberId(),
+                               'link_type'         => $row['link_type'],
+                               'subject'           => $rowData['subject'],
+                               'sender'            => $rowData['sender'],
+                               'timestamp_ordered' => generateDateTime($rowData['timestamp_ordered'], 2),
+                               'payment_id'        => $rowData['payment_id'],
                        );
 
                        // Load row template
                        if (isShowPointsUnconfirmedEnabled()) {
-                               $OUT .= loadTemplate('member_list_unconfirmed_row', TRUE, $content);
+                               $OUT .= loadTemplate('member_list_unconfirmed_row', TRUE, $rowData);
                        } else {
-                               $OUT .= loadTemplate('member_list_unconfirmed_nopoints_row', TRUE, $content);
+                               $OUT .= loadTemplate('member_list_unconfirmed_nopoints_row', TRUE, $rowData);
                        }
 
-                       // Count points
-                       $sum += $pay;
+                       // Count points (price)
+                       $sum += getPaymentPrice($rowData['payment_id']);
                } else {
                        // Prepare data for template
-                       $content = array(
+                       $rowData = array(
                                'data'    => $data,
                                'message' => $message,
                        );
 
                        // Display points or not?
                        if (isShowPointsUnconfirmedEnabled()) {
-                               $OUT .= loadTemplate('member_list_unconfirmed_404_row', TRUE, $content);
+                               $OUT .= loadTemplate('member_list_unconfirmed_404_row', TRUE, $rowData);
                        } else {
-                               $OUT .= loadTemplate('member_list_unconfirmed_nopoints_404_row', TRUE, $content);
+                               $OUT .= loadTemplate('member_list_unconfirmed_nopoints_404_row', TRUE, $rowData);
                        }
                }
 
index 6850993..a522254 100644 (file)
@@ -95,7 +95,7 @@ if (empty($url)) {
                } // END - if
 
                // Calculate used points
-               $content['payed_points'] = $content['target_send'] * getPaymentData($content['payment_id']);
+               $content['payed_points'] = $content['target_send'] * getPaymentPrice($content['payment_id']);
 
                // Subtract them from the user's account and ignore return status
                subtractPoints('order', getMemberId(), $content['payed_points']);
index fd5fa60..2a36d6d 100644 (file)
@@ -901,6 +901,12 @@ function getPaymentTitlePrice ($paymentsId, $full = FALSE) {
        return $ret;
 }
 
+// Get payment price
+function getPaymentPrice ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'price');
+}
+
 // "Getter" for payment data (cached)
 function getPaymentData ($paymentsId, $lookFor = 'price') {
        // Default value...
index ee0bb3f..9d8b295 100644 (file)
@@ -293,7 +293,7 @@ if (!SQL_HASZERONUMS($result_main)) {
                                                // Is the userid set?
                                                if (isValidId($userid)) {
                                                        // User does not exists, pay points back
-                                                       $points = getPaymentData($mailData['payment_id']);
+                                                       $points = getPaymentPrice($mailData['payment_id']);
                                                        initReferralSystem();
                                                        addPointsThroughReferralSystem('pool_payback', $mailData['sender_userid'], $points);
 
index 3694ae7..9fdacc3 100644 (file)
@@ -53,20 +53,16 @@ if (getAutoPurge() > 0) {
 
        // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
        $result = SQL_QUERY('SELECT
-       `s`.`id`,
-       `s`.`userid`,
-       `s`.`pool_id`,
-       `t`.`price`
+       `id`,
+       `userid`,
+       `pool_id`,
+       `payment_id`
 FROM
-       `{?_MYSQL_PREFIX?}_user_stats` AS `s`
-LEFT JOIN
-       `{?_MYSQL_PREFIX?}_payments` AS `t`
-ON
-       `s`.`payment_id`=`t`.`id`
+       `{?_MYSQL_PREFIX?}_user_stats`
 WHERE
-       (UNIX_TIMESTAMP() - `s`.`timestamp_ordered`) >= {?auto_purge?}
+       (UNIX_TIMESTAMP() - `timestamp_ordered`) >= {?auto_purge?}
 ORDER BY
-       `s`.`userid` ASC', __FILE__, __LINE__);
+       `userid` ASC', __FILE__, __LINE__);
        if (!SQL_HASZERONUMS($result)) {
                // Start deleting procedure
                $userid = NULL;
@@ -87,7 +83,7 @@ ORDER BY
 
                                // Add points
                                $userid = $content['userid'];
-                               $points += $content['price'];
+                               $points += getPaymentPrice($content['payment_id']);
                                $admin_points += $content['price'];
 
                                // Remove confirmation links from queue
index 24ef8c0..1d60147 100644 (file)
@@ -9,5 +9,7 @@
        <td align="center" class="{%template,ColorSwitch%} bottom right">
                [<a href="{%url=modules.php?module=login&amp;what=unconfirmed&amp;$content[link_type]=$content[data]%}">{--EMAIL_DETAILS_LINK--}</a>]
        </td>
-       <td align="center" class="{%template,ColorSwitch%} bottom">$content[timestamp]</td>
+       <td align="center" class="{%template,ColorSwitch%} bottom">
+               $content[timestamp_ordered]
+       </td>
 </tr>
index 6766718..d562201 100644 (file)
@@ -8,8 +8,10 @@
        <td align="center" class="{%template,ColorSwitch%} bottom right">
                [<a href="{%url=modules.php?module=login&amp;what=unconfirmed&amp;$content[link_type]=$content[data]%}">{--EMAIL_DETAILS_LINK--}</a>]
        </td>
-       <td align="center" class="{%template,ColorSwitch%} bottom right">$content[timestamp]</td>
+       <td align="center" class="{%template,ColorSwitch%} bottom right">
+               $content[timestamp_ordered]
+       </td>
        <td align="right" class="{%template,ColorSwitch%} bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
index e99a729..5479fe5 100644 (file)
@@ -54,7 +54,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw2 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 8723b53..5c94cc9 100644 (file)
@@ -54,7 +54,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw2 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index a2f186c..7fde5b7 100644 (file)
@@ -54,7 +54,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw2 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index fa741c2..c4ecdec 100644 (file)
@@ -56,7 +56,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw2 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 84f424d..3282b21 100644 (file)
@@ -49,7 +49,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 5b915d2..5acb059 100644 (file)
@@ -48,7 +48,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 9509cc3..e931546 100644 (file)
@@ -48,7 +48,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index d456c40..5f63c45 100644 (file)
@@ -48,7 +48,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 997351c..fe50adc 100644 (file)
@@ -50,7 +50,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index 51d3ba8..9c01502 100644 (file)
@@ -48,7 +48,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_POINTS--}:</td>
        <td align="center" class="switch_sw1 bottom" style="padding-right:5px">
-               {%pipe,translateComma=$content[points]%} {?POINTS?}
+               {%pipe,getPaymentPrice,translateComma=$content[payment_id]%} {?POINTS?}
        </td>
 </tr>
 <tr>
index f19f12c..0ab8310 100644 (file)
@@ -12,7 +12,7 @@
                <div>
                <select name="mail_type" size="1" class="form_select">
                        <option value="X" disabled="disabled">{--PLEASE_SELECT--}</option>
-                       $content[type_selection]
+                       $content[payment_selection]
                </select>
                </div>
        </div>