]> git.mxchange.org Git - mailer.git/commitdiff
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 821c7cc5fa704c1704bf25ce27465fd0236672b1..2d24e2bd777d37ebce50dd8113b5c1ae165abd15 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 1d697914c02f337f39427ce47a03050de68ecc5e..b599a0f1cdd5f05e494eb56bf39946a0e14d4726 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 aeedfc5dbe349059dce4a84b1759ff7fb2fc9604..7be34fe1e702af4a7b8f35c583fb29d75975d0d8 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 eb1d818d81a58189caca0f8382d0c7823615fdf9..05031b4e3b31e95c2cb821ae1eedf5e136667b01 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 6a6ce9d68c4134ab718591fce2640b92a0293a24..c861e22df22827ba073ac09bfbf12a0834c8fbf9 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 1ffcee889cc0b3fc3cc9c9c002487c0481c507a5..60705d4ea662fe530f06f2ae96ac71c599faecc2 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 4a87666826a430d99a2ddff5ef2f26486f9a8397..aec2a6935d7099b7b088dde969a9fa9b177ec6bc 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 0f11f5fed2984351a16089fedc30a4388e14b462..7a1def3cf1d16870eb0baf1f25e3a810d5f6cd28 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 f23946d3ba9bbe86d83f29359d03378b159251f0..980ee0cae4ac08f87aeae9661145c31441f1c75f 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 a1f7a2a08f284aa3a8a87311af2bbb1a6c940f4c..0cc9a78a8c293836a71eee34f7189fd54bc65dcd 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 f64ae4ce2fe8c0fe80dd6bdfc2bb952b0cdd0127..d2fe6db28ba3467557ed849761b221e96b704b05 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 68509930dbf9633d25a8fa1653d185468dc545da..a5222540c6cb9101d0aa6e19480e02544699e0ee 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 fd5fa60bc9b39444df044191925e97d07a10e5b4..2a36d6db07ef1d7d42b773638daffeba2e530199 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 ee0bb3f0b874f9a669076e269456c8a86d482c26..9d8b295dd67c06ba164926f23c3c233dae2a347b 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 3694ae702759ce609755bcecf9a5ed6fb3a1f333..9fdacc38096419ab11e3f25efa544156cb61e0f0 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 24ef8c00ad322c4967f98cfca4065dbf2f9b53f9..1d60147d9f3f173b8de8b4160d799a1fa5e384cf 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 6766718276d674d349a71ecbad81c9b4b254f81b..d5622015bd7639dfdb0a182d86828322c146d355 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 e99a729135ffe1fd497f4838fdccee9b19587575..5479fe5770c6b03a65505450b9b44ec99f08f73e 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 8723b5316f6a1dad8e4f615c23fd1269c4ebe66e..5c94cc9c694b3a12bbbb55ca1aabf943fb83d200 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 a2f186caf251788b3f1c86caa1101f65b4c79d7b..7fde5b7059150740e71af8a5b717e0f2a81f66a1 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 fa741c2c7241398e29928dce0f85614af4a5896e..c4ecdece215d490bfbee2626a4e8fa4dad29fb3e 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 84f424d73b31b56f08afa2093a52d8152a53dee1..3282b21fea6a80ff9107eac8093dd5c312691307 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 5b915d2cbb74fee792ab8cf4e470b745496078c7..5acb059187e316483d2a8e6494a3365f30923393 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 9509cc38df55e310f4388832bb624f14e886ab59..e931546af7807c49c12863319e07b8c0f04c8358 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 d456c406a2287283b08bb6aef314cf6697fc6672..5f63c45effc9333b2878edac2373d0caa38f87df 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 997351c8384d58bdff8d05bb8d7b7f3d64914ee2..fe50adc3cfb2991ac3bcebaa305da8cf4dd9c787 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 51d3ba83c62b01d2a9eb5cbb65ef20d0355c02db..9c01502985022f49fd21e82d8e981baf45b19b74 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 f19f12c51d70341c46ad668aeb3fb485d63b1061..0ab83103d7969c49fd3912519b247475e43d342a 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>