Rewrote script to use more EL, introduced wrappers for sending pool:
authorRoland Häder <roland@mxchange.org>
Tue, 22 Jan 2013 23:27:13 +0000 (23:27 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 22 Jan 2013 23:27:13 +0000 (23:27 +0000)
- Introduced wrapper function getPaymentTime() and getPaymentPayment() and used
  both in EL code instead of PHP script
- Added new function library "pool-functions.php"
- Rewrote reading emails from "pool" table
- Rewrote updating of "pool data"
- TODOs.txt updated

30 files changed:
.gitattributes
DOCS/TODOs.txt
inc/libs/network_functions.php
inc/libs/surfbar_functions.php
inc/modules/admin/what-del_email.php
inc/modules/admin/what-list_network_array_translation.php
inc/modules/admin/what-list_network_request_params.php
inc/modules/admin/what-list_network_types.php
inc/modules/admin/what-unlock_emails.php
inc/modules/frametester.php
inc/modules/member/what-unconfirmed.php
inc/modules/order.php
inc/mysql-connect.php
inc/mysql-manager.php
inc/pool-functions.php [new file with mode: 0644]
inc/pool/pool-user.php
inc/purge/purge-general.php
mailid.php
templates/de/emails/member/member_order_accepted.tpl
templates/de/emails/member/member_order_deleted.tpl
templates/de/emails/member/member_order_normal.tpl
templates/de/emails/member/member_order_rejected.tpl
templates/de/emails/member/member_user_pool_normal.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/select/select_network_type_box.tpl

index 95c965a..5bfeb97 100644 (file)
@@ -856,6 +856,7 @@ inc/phpmailer/phpdoc/media/stylesheet.css svneol=native#text/css
 inc/phpmailer/test/phpmailer_test.php svneol=native#text/plain
 inc/phpmailer/test/phpunit.php svneol=native#text/plain
 inc/phpmailer/test/test.png -text svneol=unset#image/png
+inc/pool-functions.php svneol=native#text/plain
 inc/pool-update.php svneol=native#text/plain
 inc/pool/.htaccess svneol=native#text/plain
 inc/pool/pool- svneol=native#text/plain
index 2d24e2b..cc00330 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:57:             // @TODO Unused: cat_id
+./inc/modules/admin/what-del_email.php:51:     // @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:93:                                 // @TODO Rewrite these if-blocks to a filter
+./inc/modules/admin/what-unlock_emails.php:78:                                 // @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/frametester.php:91:      // @TODO Rewrite this somehow
 ./inc/modules/guest/what-beg.php:51:// @TODO No more needed? define('__BEG_USERID_TIMEOUT', createFancyTime(getBegUseridTimeout()));
 ./inc/modules/guest/what-mediadata.php:188:// @TODO Rewrite all these if-blocks to filters
 ./inc/modules/guest/what-mediadata.php:67:     // @TODO Find a better formular than this one
 ./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: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: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/modules/member/what-unconfirmed.php:130: // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code
+./inc/modules/member/what-unconfirmed.php:174: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/member/what-unconfirmed.php:241:                 // @TODO cat_id is unused
+./inc/modules/member/what-unconfirmed.php:244:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
+./inc/modules/order.php:71:            // @TODO Unused: timestamp
+./inc/mysql-manager.php:1509:          // @TODO Rewrite these lines to a filter
+./inc/mysql-manager.php:1533:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1849:                  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2017:                          // @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:2140:                  // @TODO Used generic 'userid' here
+./inc/mysql-manager.php:2361:// @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/pool-functions.php:44:// @TODO "Hook" ext-html_mail into this to allow column `html_msg`
 ./inc/revision-functions.php:168:// @TODO This function does also set and get in 'cache_array'
 ./inc/template-functions.php:1048:                             // @TODO <label for="' . $prefix . '_' . $field . '"></<label> not working here
 ./inc/template-functions.php:1103:                     // @TODO Deprecate this thing
index c59214f..405d557 100644 (file)
@@ -226,7 +226,7 @@ function isNetworkArrayTranslationValid ($key, $networkTypeId, $networkId) {
 }
 
 // "Getter" for a network's data by provided id number
-function getNetworkDataById ($networkId, $column = '') {
+function getNetworkDataFromId ($networkId, $column = '') {
        // Ids lower one are not accepted
        if (!isValidId($networkId)) {
                // Not good, should be fixed
@@ -395,7 +395,7 @@ LIMIT 1',
 }
 
 // "Getter" for all network type data by provided id number
-function getNetworkTypeDataById ($networkId) {
+function getNetworkTypeDataFromId ($networkId) {
        // Ids lower one are not accepted
        if (!isValidId($networkId)) {
                // Not good, should be fixed
@@ -441,7 +441,7 @@ ORDER BY
 }
 
 // "Getter" for a network request parameter data by provided id number
-function getNetworkRequestParamsDataById ($networkRequestId) {
+function getNetworkRequestParamsDataFromId ($networkRequestId) {
        // Ids lower one are not accepted
        if (!isValidId($networkRequestId)) {
                // Not good, should be fixed
@@ -480,7 +480,7 @@ LIMIT 1',
 }
 
 // "Getter" for a network array translation data by provided id number
-function getNetworkArrayTranslationsDataById ($networkTranslationId) {
+function getNetworkArrayTranslationsDataFromId ($networkTranslationId) {
        // Ids lower one are not accepted
        if (!isValidId($networkTranslationId)) {
                // Not good, should be fixed
@@ -1293,7 +1293,7 @@ function countNetworkApiRequest ($networkData) {
  */
 function generateMetworkReferralLinkById ($networkId) {
        // Simple output (no need for template!)
-       $output = '<a href="{%network,getNetworkDataById,network_reflink=' . $networkId . '%}" target="_blank" title="{%network,getNetworkDataById,network_title=' . $networkId . '%}">{%network,getNetworkDataById,network_title=' . $networkId . '%}</a>';
+       $output = '<a href="{%network,getNetworkDataFromId,network_reflink=' . $networkId . '%}" target="_blank" title="{%network,getNetworkDataFromId,network_title=' . $networkId . '%}">{%network,getNetworkDataFromId,network_title=' . $networkId . '%}</a>';
 
        // Return it
        return $output;
@@ -1849,7 +1849,7 @@ function doAdminNetworkProcessHandleNetworks () {
                        // Is this selected?
                        if ($sel == 1) {
                                // Load this network's data
-                               $networkData = getNetworkDataById($networkId);
+                               $networkData = getNetworkDataFromId($networkId);
 
                                // Is there found the network?
                                if (count($networkData) > 0) {
@@ -1883,7 +1883,7 @@ function doAdminNetworkProcessHandleNetworkTypes () {
        // Is there selections?
        if (ifPostContainsSelections()) {
                // Load network data
-               $networkData = getNetworkDataById(getRequestElement('network_id'));
+               $networkData = getNetworkDataFromId(getRequestElement('network_id'));
 
                // Something has been selected, so start displaying one by one
                $OUT = '';
@@ -1944,7 +1944,7 @@ function doAdminNetworkProcessHandleRequestParams () {
                $GLOBALS['network_request_params_disabled'] = array();
 
                // Load network data
-               $networkData = getNetworkDataById(getRequestElement('network_id'));
+               $networkData = getNetworkDataFromId(getRequestElement('network_id'));
 
                // Something has been selected, so start displaying one by one
                $OUT = '';
@@ -1952,7 +1952,7 @@ function doAdminNetworkProcessHandleRequestParams () {
                        // Is this selected?
                        if ($sel == 1) {
                                // Load this network's data
-                               $networkRequestData = getNetworkRequestParamsDataById($networkId);
+                               $networkRequestData = getNetworkRequestParamsDataFromId($networkId);
 
                                // Is there found the network?
                                if (count($networkRequestData) > 0) {
@@ -2431,7 +2431,7 @@ function doAdminNetworkProcessHandleArrayTranslations () {
                $GLOBALS['network_array_translation_disabled'] = array();
 
                // Load network data
-               $networkData = getNetworkDataById(getRequestElement('network_id'));
+               $networkData = getNetworkDataFromId(getRequestElement('network_id'));
 
                // Something has been selected, so start displaying one by one
                $OUT = '';
@@ -2439,7 +2439,7 @@ function doAdminNetworkProcessHandleArrayTranslations () {
                        // Is this selected?
                        if ($sel == 1) {
                                // Load this network's data
-                               $networkTranslationsData = getNetworkArrayTranslationsDataById($networkId);
+                               $networkTranslationsData = getNetworkArrayTranslationsDataFromId($networkId);
 
                                // Is there found the network?
                                if (count($networkTranslationsData) > 0) {
@@ -3111,7 +3111,7 @@ function doAjaxAdminNetworkListById () {
        }
 
        // Load all network type handlers by given network id and extract only network_type_id
-       $networkTypes = getArrayFromArrayIndex(getNetworkTypeDataById(postRequestElement('network_id')), 'network_type_id');
+       $networkTypes = getArrayFromArrayIndex(getNetworkTypeDataFromId(postRequestElement('network_id')), 'network_type_id');
 
        // Set generated array
        setAjaxReplyContent(encodeJson($networkTypes));
index bc559ac..b4c4982 100644 (file)
@@ -285,7 +285,7 @@ function doSurfbarMemberByFormData ($formData, $urlArray) {
 }
 
 // Getter for surfbar_actions table by given id number
-function getSurfbarActionsDataById ($columnName, $id) {
+function getSurfbarActionsDataFromId ($columnName, $id) {
        // Is cache set?
        if (!isset($GLOBALS[__FUNCTION__][$id][$columnName])) {
                // Default is not found
index 60705d4..f367fb9 100644 (file)
@@ -48,15 +48,11 @@ $count = '0';
 
 if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
        // Load email data
-       $result = SQL_QUERY_ESC("SELECT `id`, `sender`, `subject`, `url`, `timestamp`, `cat_id`, `payment_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
-               array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
+       // @TODO Unused: cat_id
+       $content getPoolDataFromId(getRequestElement('id'));
 
        // Delete mail only once
-       if (SQL_NUMROWS($result) == 1) {
-               // Load data
-               // @TODO Unused: cat_id
-               $content = SQL_FETCHARRAY($result);
-
+       if (count($content) > 0) {
                // Prepare data for the template
                $content['timestamp'] = generateDateTime($content['timestamp'], 0);
 
@@ -189,9 +185,6 @@ LIMIT 1",
                // Mail already deleted!
                displayMessage('{--ADMIN_BONUS_MAIL_ALREADY_DELETED--}');
        }
-
-       // Free result
-       SQL_FREERESULT($result);
 } elseif ((isGetRequestElementSet('nid')) && (isExtensionInstalledAndNewer('bonus', '0.8.7'))) {
        // Load data from bonus mail
        $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
index 071009f..b53daf2 100644 (file)
@@ -64,7 +64,7 @@ if ($GLOBALS['network_display'] === FALSE) {
 // Is there a network selected?
 if (isGetRequestElementSet('network_id')) {
        // Get its data for template
-       $networkData = getNetworkDataById(getRequestElement('network_id'));
+       $networkData = getNetworkDataFromId(getRequestElement('network_id'));
 
        // Init type
        $networkData['network_type_id'] = 0;
index 2fcadeb..4bcfdca 100644 (file)
@@ -64,7 +64,7 @@ if ($GLOBALS['network_display'] === FALSE) {
 // Is there a network selected?
 if (isGetRequestElementSet('network_id')) {
        // Get its data for template
-       $networkData = getNetworkDataById(getRequestElement('network_id'));
+       $networkData = getNetworkDataFromId(getRequestElement('network_id'));
        $networkData['network_type_id'] = 0;
 
        // Init disabled list
index f59e930..07e6d4a 100644 (file)
@@ -64,7 +64,7 @@ if ($GLOBALS['network_display'] === FALSE) {
 // Is there a network selected?
 if (isGetRequestElementSet('network_id')) {
        // Get its data for template
-       $networkData = getNetworkDataById(getRequestElement('network_id'));
+       $networkData = getNetworkDataFromId(getRequestElement('network_id'));
 
        // Init disabled list
        $GLOBALS['network_types_disabled'] = array();
index 980ee0c..f87c9c9 100644 (file)
@@ -46,12 +46,13 @@ addYouAreHereLink('admin', __FILE__);
 // Check for mails
 $result_main = SQL_QUERY("SELECT
        `id`,
-       `sender`,
+       `url`,
        `subject`,
-       `payment_id`,
+       `text`,
+       `sender`,
        `timestamp`,
-       `url`,
        `target_send`,
+       `payment_id`,
        `cat_id`
 FROM
        `{?_MYSQL_PREFIX?}_pool`
@@ -68,27 +69,11 @@ if ((!SQL_HASZERONUMS($result_main)) || (isFormSent('lock'))) {
                                // Secure id number
                                $id = bigintval($id);
 
-                               // Order placed in queue...
-                               $result = SQL_QUERY_ESC('SELECT
-       `url`,
-       `subject`,
-       `sender`,
-       `payment_id`
-FROM
-       `{?_MYSQL_PREFIX?}_pool`
-WHERE
-       `id`=%s
-LIMIT 1',
-                                       array($id), __FILE__, __LINE__);
-
-                               // Update wents fine?
-                               if (SQL_NUMROWS($result) == 1) {
-                                       // Load data
-                                       $content = SQL_FETCHARRAY($result);
-
-                                       // Get payment from getter to avoid JOIN
-                                       $content['payment'] = getPaymentData($content['payment_id', 'payment');
+                               // Get pool data from given id
+                               $content = getPoolDataFromId($id);
 
+                               // Found some data?
+                               if (count($content) > 0) {
                                        // Is the surfbar installed?
                                        // @TODO Rewrite these if-blocks to a filter
                                        if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
@@ -113,12 +98,8 @@ LIMIT 1',
                                        sendEmail($content['sender'], '{--MEMBER_ORDER_ACCEPTED--}', $message_user);
 
                                        // Unlock selected email
-                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW' WHERE `id`=%s AND `data_type`='ADMIN' LIMIT 1",
-                                               array($id), __FILE__, __LINE__);
+                                       updatePoolDataById($id, 'data_type', 'NEW', NULL, " AND `data_type`='ADMIN'");
                                } // END - if
-
-                               // Free result
-                               SQL_FREERESULT($result);
                        } // END - foreach
 
                        // Set message
@@ -138,15 +119,8 @@ LIMIT 1',
                                // Secure id number
                                $id = bigintval($id);
 
-                               // Load URL and subject from pool
-                               $result = SQL_QUERY_ESC("SELECT `url`, `subject`, `sender` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
-                                       array($id), __FILE__, __LINE__);
-
-                               // Load data
-                               $content = SQL_FETCHARRAY($result);
-
-                               // Free result
-                               SQL_FREERESULT($result);
+                               // Get pool data from given id
+                               $content = getPoolDataFromId($id);
 
                                // Load email template and send it away
                                $message_user = loadEmailTemplate('member_order_rejected', $content, $content['sender']);
@@ -158,8 +132,7 @@ LIMIT 1',
                                } // END - if
 
                                // Redirect URL
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `url`='%s',`data_type`='NEW' WHERE `id`=%s LIMIT 1",
-                                       array(postRequestElement('redirect'), $id),__FILE__, __LINE__);
+                               updatePoolDataById($id, NULL, array('url' => postRequestElement('redirect'), 'data_type' => 'NEW'));
 
                                // Prepare data for the row template
                                $content = array(
index 09898ff..600958c 100644 (file)
@@ -46,11 +46,10 @@ if (isGetRequestElementSet('order')) {
        // Order number placed, is he also logged in?
        if (isMember()) {
                // Ok, test passed... :)
-               $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1",
-                       array(bigintval(getRequestElement('order')), getMemberId()), __FILE__, __LINE__);
+               $content = getPoolDataFromId(getRequestElement('order'));
 
                // Finally is the entry valid?
-               if (SQL_NUMROWS($result) == 1) {
+               if ((count($content) > 0) && ($content['data_type'] == 'TEMP')) {
                        // Load subject and URL (but forwhat do we need the subject line here???
                        list($url) = SQL_FETCHROW($result);
 
@@ -63,9 +62,6 @@ if (isGetRequestElementSet('order')) {
                        // Matching line not found
                        redirectToUrl('modules.php?module=index&amp;what=login');
                }
-
-               // Free memory
-               SQL_FREERESULT($result);
        } else {
                // He is no longer logged in
                redirectToUrl('modules.php?module=index&amp;what=login');
index d2fe6db..3451587 100644 (file)
@@ -125,12 +125,9 @@ LIMIT 1",
        // 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');
+       // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code
        $content['userid'] = getMemberId();
        $content['user_mail_status'] = '{%message,MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN=' . $content['id'] . '%}';
 
index a522254..cc880e6 100644 (file)
@@ -65,29 +65,11 @@ if (empty($url)) {
                $type = 'NEW';
        } // END - if
 
-       // Update sending pool
-       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='%s' WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1",
-               array(
-                       $type,
-                       bigintval(getRequestElement('order')),
-                       getMemberId()
-               ), __FILE__, __LINE__);
-
-       // Finally is the entry valid?
-       if (!SQL_HASZEROAFFECTED()) {
-               // @TODO Unused: 2,4
-               // Load mail again...              0         1          2             3            4         5       6            7
-               $result = SQL_QUERY_ESC("SELECT `subject`, `text`, `receivers`, `payment_id`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s LIMIT 1",
-                       array(
-                               bigintval(getRequestElement('order')),
-                               getMemberId()
-                       ), __FILE__, __LINE__);
-
-               // Merge arrays
-               $content = merge_array($content, SQL_FETCHARRAY($result));
-
-               // Free result
-               SQL_FREERESULT($result);
+       // Update pool data and check if the entry is valid
+       if (!updatePoolDataById(getRequestElement('order'), 'data_type', $type, NULL, sprintf(" AND `sender`=%s AND `data_type`='TEMP'", getMemberId()))) {
+               // Merge array with pool data
+               // @TODO Unused: timestamp
+               $content = merge_array($content, getPoolDataFromId(getRequestElement('order'));
 
                // Fix empty subject line
                if (empty($content['subject'])) {
index fd68e77..edd9c0e 100644 (file)
@@ -53,6 +53,7 @@ foreach ( array(
                'request',
                'session',
                'code',
+               'pool',
                'language',
                'sql',
                'expression',
index 2a36d6d..d42cd4e 100644 (file)
@@ -907,8 +907,20 @@ function getPaymentPrice ($paymentsId) {
        return getPaymentData($paymentsId, 'price');
 }
 
+// Get payment time
+function getPaymentTime ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'time');
+}
+
+// Get payment 'payment'
+function getPaymentPayment ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'payment');
+}
+
 // "Getter" for payment data (cached)
-function getPaymentData ($paymentsId, $lookFor = 'price') {
+function getPaymentData ($paymentsId, $lookFor) {
        // Default value...
        $data[$lookFor] = NULL;
 
@@ -986,8 +998,7 @@ function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isB
                                // Update 'mails_sent' if ext-sql_patches is updated
                                if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
                                        // Update the pool
-                                       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1',
-                                               array(bigintval($poolId)), __FUNCTION__, __LINE__);
+                                       updatePoolDataById($poolId, 'mails_sent', 1, '+');
                                } // END - if
                                $ret = 'done';
                        } else {
diff --git a/inc/pool-functions.php b/inc/pool-functions.php
new file mode 100644 (file)
index 0000000..81a303e
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 01/22/2013 *
+ * ===================                          Last change: 01/22/2013 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : pool-functions.php                               *
+ * -------------------------------------------------------------------- *
+ * Short description : Functions for handling status codes              *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Funktionen zum Umgang mit Status-Funktionen      *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} // END - if
+
+// "Getter" for pool data from given id number
+// @TODO "Hook" ext-html_mail into this to allow column `html_msg`
+function getPoolDataFromId ($poolId) {
+       // Init content array
+       $content = array();
+
+       // Search for pool data
+       $result = SQL_QUERY_ESC('SELECT
+       `id`,
+       `sender`,
+       `subject`,
+       `text`,
+       `receivers`,
+       `payment_id`,
+       `data_type`,
+       `timestamp`,
+       `url`,
+       `target_send`,
+       `cat_id`,
+       `zip`
+FROM
+       `{?_MYSQL_PREFIX?}_pool`
+WHERE
+       `id`=%s
+LIMIT 1',
+               array(bigintval($poolId)), __FUNCTION__, __LINE__);
+
+       // Is there an entry?
+       if (SQL_NUMROWS($result) == 1) {
+               // Load data
+               $content = SQL_FETCHARRAY($result);
+       } // END - if
+
+       // Free result
+       SQL_FREERESULT($result);
+
+       // Return found data
+       return $content;
+}
+
+// Update the pool
+function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $whereSql = '', $moreSql = '') {
+       // Is update mode set?
+       if (!is_null($updateMode)) {
+               // Don't allow array as data here
+               assert(!is_array($data));
+
+               // Then use this on the column with this mode (mostly counters)
+               SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
+                       array(
+                               $columnName,
+                               $columnName,
+                               $updateMode,
+                               $data,
+                               bigintval($poolId)
+                       ), __FUNCTION__, __LINE__);
+       } elseif (is_array($data)) {
+               /*
+                * Update multiple columns, $columnName and $updateMode are being
+                * ignored as last doesn't work and first is given in $data array.
+                */
+               $sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET ';
+               foreach ($data as $key => $value) {
+                       // Add it
+                       $sql .= sprintf("`%s`='%s',", SQL_ESCAPE($key), SQL_ESCAPE($value));
+               } // END - foreach
+
+               // Finish SQL
+               $sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1';
+
+               // And finally run it
+               SQL_QUERY($sql, __FUNCTION__, __LINE__);
+       } else {
+               // Regular update
+               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
+                       array(
+                               $columnName,
+                               $data,
+                               bigintval($poolId)
+                       ), __FUNCTION__, __LINE__);
+       }
+
+       // Return if it has an affected row
+       return (SQL_AFFECTEDROWS() == 1);
+}
+
+// [EOF]
+?>
index 9d8b295..1d074ef 100644 (file)
@@ -70,7 +70,7 @@ $result_main = SQL_QUERY("SELECT
        `url`,
        `target_send`,
        `cat_id`
-       ".$HTML."
+       " . $HTML . "
 FROM
        `{?_MYSQL_PREFIX?}_pool`
 WHERE
@@ -88,12 +88,13 @@ if (!SQL_HASZERONUMS($result_main)) {
        // Parse all mails
        while ($mailData = SQL_FETCHARRAY($result_main)) {
                // Set mail order as 'active'. That means it will be sent out
-               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='ACTIVE' WHERE `id`=%s AND `data_type`='NEW' LIMIT 1",
-                       array($mailData['id']), __FILE__, __LINE__);
+               updatePoolDataById($mailData['id'], 'data_type', 'ACTIVE', NULL, " AND `data_type`='NEW'");
 
                // Check fetched data for HTML
                $isHtml = 'N';
-               if (isset($mailData['html_msg'])) $isHtml = $mailData['html_msg'];
+               if (isset($mailData['html_msg'])) {
+                       $isHtml = $mailData['html_msg'];
+               } // END - if
 
                // Entry updated?
                if (!SQL_HASZEROAFFECTED()) {
@@ -177,10 +178,6 @@ if (!SQL_HASZERONUMS($result_main)) {
                                                                // Prepare the mail
                                                                $mailData['stats_id'] = bigintval($stats_id);
 
-                                                               // Prepare content
-                                                               $mailData['time']   = getPaymentData($mailData['payment_id'], 'time');
-                                                               $mailData['points'] = getPaymentData($mailData['payment_id'], 'payment');
-
                                                                // Load message template
                                                                $mailText = loadEmailTemplate('member_user_pool_normal', $mailData, bigintval($userid));
 
@@ -230,7 +227,7 @@ if (!SQL_HASZERONUMS($result_main)) {
                                                        'cat_id'        => $mailData['cat_id'],
                                                        'text'          => $mailData['text'],
                                                        'url'           => $mailData['url'],
-                                                       'expiration'    => '{%pipe,createFancyTime=' . getPaymentData($mailData['payment_id'], 'time') . '%}'
+                                                       'expiration'    => '{%pipe,getPaymentTime,createFancyTime=' . $mailData['payment_id'] . '%}'
                                                );
 
                                                // Yes we do, so we notify admin and sender about fully sent mail!
@@ -246,8 +243,7 @@ if (!SQL_HASZERONUMS($result_main)) {
                                                } // END - if
 
                                                // Set status to SEND because we completely send it away
-                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='SEND',`target_send`=0,`receivers`='' WHERE `id`=%s LIMIT 1",
-                                                       array(bigintval($mailData['id'])), __FILE__, __LINE__);
+                                               updatePoolDataById($mailData['id'], NULL, array('data_type' => 'SEND', 'target_send' => '0', 'receivers' => '');
 
                                                // Update send-completed-time
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1",
@@ -270,12 +266,8 @@ if (!SQL_HASZERONUMS($result_main)) {
                                        elseif (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || ($count2 >= getConfig('max_send'))) {
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $add = '';
-                                               if ($GLOBALS['pool_cnt'] <= $mailData['target_send']) $add = ", target_send=target_send-".$GLOBALS['pool_cnt'];
-                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW', receivers='%s'" . $add . " WHERE `id`=%s LIMIT 1",
-                                                       array(
-                                                               implode(';', $temporaryReceivers),
-                                                               bigintval($mailData['id'])
-                                                       ), __FILE__, __LINE__);
+                                               if ($GLOBALS['pool_cnt'] <= $mailData['target_send']) $add = ',`target_send`=`target_send`-' . $GLOBALS['pool_cnt'];
+                                               updatePoolDataById($mailData['id'], NULL, array('data_type' => 'NEW', 'receivers' => implode(';', $temporaryReceivers)), NULL, '', $add);
 
                                                //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__.'*');
                                                break;
@@ -287,18 +279,16 @@ if (!SQL_HASZERONUMS($result_main)) {
                                        // User does not exists so we have add the sender's points back to sender's account
                                        if (($receivers['id'] == '0') || (empty($receivers['id']))) {
                                                // List was empty
-                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='SEND' WHERE `id`=%s LIMIT 1",
-                                                       array(bigintval($mailData['id'])), __FILE__, __LINE__);
+                                               updatePoolDataById($mailData['id'], 'data_type', 'SEND');
                                        } else {
                                                // Is the userid set?
                                                if (isValidId($userid)) {
                                                        // User does not exists, pay points back
-                                                       $points = getPaymentPrice($mailData['payment_id']);
                                                        initReferralSystem();
-                                                       addPointsThroughReferralSystem('pool_payback', $mailData['sender_userid'], $points);
+                                                       addPointsThroughReferralSystem('pool_payback', $mailData['sender_userid'], getPaymentPrice($mailData['payment_id']));
 
                                                        // Add points together and remove user
-                                                       $pointsBack[$mailData['sender_userid']] += $points;
+                                                       $pointsBack[$mailData['sender_userid']] += getPaymentPrice($mailData['payment_id']);
                                                } // END - if
 
                                                // Count up
@@ -309,8 +299,7 @@ if (!SQL_HASZERONUMS($result_main)) {
                                        unset($temporaryReceivers[$key]);
 
                                        // Update receivers
-                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `receivers`='%s' WHERE `id`=%s LIMIT 1",
-                                               array(implode(';', $temporaryReceivers), bigintval($mailData['id'])), __FILE__, __LINE__);
+                                       updatePoolData($mailData['id'], 'receivers', implode(';', $temporaryReceivers));
                                }
                        } // END - foreach
                } // END - if
index 9fdacc3..8b3dfb4 100644 (file)
@@ -91,8 +91,7 @@ ORDER BY
                                        array(bigintval($content['id'])), __FILE__, __LINE__, FALSE));
 
                                // Update status of order
-                               addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='DELETED' WHERE `id`=%s LIMIT 1",
-                                       array(bigintval($content['pool_id'])), __FILE__, __LINE__, FALSE));
+                               updatePoolDataById($content['pool_id'], 'data_type', 'DELETED');
                        } // END - if
 
                        // Free memory
index 557231c..2e19762 100644 (file)
@@ -166,8 +166,8 @@ if ((isValidId($data['userid'])) && (isValidId($data['id'])) && (!empty($data['t
                                                        // Entry found?
                                                        if (SQL_NUMROWS($result) == 1) {
                                                                $data = merge_array($data, SQL_FETCHARRAY($result));
-                                                               $data['time']    = getPaymentData($data['payment_id'], 'time');
-                                                               $data['payment'] = getPaymentData($data['payment_id'], 'payment');
+                                                               $data['time']    = getPaymentTime($data['payment_id']);
+                                                               $data['payment'] = getPaymentPayment($data['payment_id']);
                                                                $isValid   = TRUE;
                                                        } // END - if
 
@@ -176,7 +176,7 @@ if ((isValidId($data['userid'])) && (isValidId($data['id'])) && (!empty($data['t
                                                        break;
 
                                                case 'BONUS':
-                                                       $result = SQL_QUERY_ESC("SELECT `time`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+                                                       $result = SQL_QUERY_ESC("SELECT `time`, `points` AS `payment` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                                                                array(bigintval($data['pool_id'])), __FILE__, __LINE__);
 
                                                        // Entry found?
index c1efcb6..72f3746 100644 (file)
@@ -1,12 +1,22 @@
 Hallo {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,family=$userid%},
 
-Einer unserer Administratoren hat soeben Ihre Mailbuchung freigegeben. Sie wird von unserem System automatisch versendet! Bitte beachten Sie, dass dies ggf. zeitversetzt zu dieser Mail versendet wird. Hier sind nochmals URL und Betreff Ihrer Mailbuchung:
+Einer unserer Administratoren hat soeben Ihre Mailbuchung freigegeben. Sie wird von unserem System automatisch versendet! Bitte beachten Sie, dass dies ggf. zeitversetzt zu dieser Mail versendet wird.
 
+Hier sind nochmals alle Daten Ihrer Mailbuchung:
 -----------------------------
 Beworbene URL: $content[url]
 -----------------------------
 Betreffzeile: $content[subject]
 -----------------------------
+Verg&uuml;tung: {%pipe,getPaymentPayment,translateComma=$content[payment_id]%} {?POINTS?}
+-----------------------------
+Wartezeit: {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
+-----------------------------
+Beworbene Kategorie: {%pipe,getCategory=$content[cat_id]%}
+-----------------------------
+Werbetext:
+$content[text]
+-----------------------------
 
 Sie k&ouml;nnen den Versand-Fortschritt im Mitgliedsmen&uuml; unter "Unbest&auml;tigte Mails" verfolgen. Sobald die Mail vollst&auml;ndig versendet wurde, erhalten Sie eine weitere Mail!
 
index 584d52a..801bf11 100644 (file)
@@ -2,11 +2,20 @@ Hallo {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,fa
 
 Einer unserer Administratoren hat soeben Ihre Mailbuchung gel&ouml;scht. Hier sind nochmals Ihre URL und Betreff Ihrer Mailbuchung:
 
----------------
+-----------------------------
 Beworbene URL: $content[url]
----------------
+-----------------------------
 Betreffzeile: $content[subject]
----------------
+-----------------------------
+Verg&uuml;tung: {%pipe,getPaymentPayment,translateComma=$content[payment_id]%} {?POINTS?}
+-----------------------------
+Wartezeit: {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
+-----------------------------
+Beworbene Kategorie: {%pipe,getCategory=$content[cat_id]%}
+-----------------------------
+Werbetext:
+$content[text]
+-----------------------------
 
 Ihre Mailbuchung wurde somit gel&ouml;scht. Sollten Sie Fragen hierzu haben, so wenden Sie sich bitte an unseren Support.
 
index b6eba8f..52fa5bc 100644 (file)
@@ -5,9 +5,13 @@ Ihre Mailbuchung befindet sich derzeit in Warteschleife und wird bald ausgesende
 Hier sind nochmals Ihre Daten aus dem Buchungsformular:
 ------------------------------------------------
 Gebuchte Kategorie: {%pipe,getCategory=$content[cat_id]%}
+------------------------------------------------
 Gebuchter Payment-Typ: {%pipe,getPaymentTitlePrice=$content[payment_id]%}
+------------------------------------------------
 Betreffzeile in den Mails: $content[subject]
+------------------------------------------------
 Gebuchte URL: $content[url]
+------------------------------------------------
 Bezahlte {?POINTS?}: $content[payed_points]
 ------------------------------------------------
 
index 0c96892..4fdb2b0 100644 (file)
@@ -7,6 +7,15 @@ Beworbene URL: $content[url]
 -----------------------------
 Betreffzeile: $content[subject]
 -----------------------------
+Verg&uuml;tung: {%pipe,getPaymentPayment,translateComma=$content[payment_id]%} {?POINTS?}
+-----------------------------
+Wartezeit: {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
+-----------------------------
+Beworbene Kategorie: {%pipe,getCategory=$content[cat_id]%}
+-----------------------------
+Werbetext:
+$content[text]
+-----------------------------
 
 Ihre Mailbuchung wurde somit gel&ouml;scht. Sollten Sie Fragen hierzu haben, so wenden Sie sich bitte an unseren Support.
 
index 54ced09..e61e937 100644 (file)
@@ -9,13 +9,13 @@ $content[text]
 ----------------
 Werber: $content[sender_userid]
 ----------------
-Verg&uuml;tung: {%pipe,translateComma=$content[points]%} {?POINTS?}
+Verg&uuml;tung: {%pipe,getPaymentPayment,translateComma=$content[payment_id]%} {?POINTS?}
 ----------------
 Verfallszeit: $content[expiration]
 ----------------
 Beworbene Kategorie: {%pipe,getCategory=$content[cat_id]%}
 ----------------
-Wartezeit: {%pipe,createFancyTime=$content[time]%}
+Wartezeit: {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
 ----------------
 Beworbene URL: $content[url]
 ----------------
index 3282b21..1f1e50b 100644 (file)
@@ -43,7 +43,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index 5acb059..35bba35 100644 (file)
@@ -42,7 +42,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index e931546..bef3acb 100644 (file)
@@ -42,7 +42,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index 5f63c45..3a20cb0 100644 (file)
@@ -42,7 +42,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index fe50adc..0609c62 100644 (file)
@@ -44,7 +44,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index 9c01502..863cd84 100644 (file)
@@ -42,7 +42,7 @@
 <tr>
        <td align="center" class="switch_sw2 bottom right">{--EMAIL_TIME--}:</td>
        <td align="center" class="switch_sw2 bottom">
-               {%pipe,createFancyTime=$content[time]%}
+               {%pipe,getPaymentTime,createFancyTime=$content[payment_id]%}
        </td>
 </tr>
 <tr>
index 1cc389e..2e0f685 100644 (file)
@@ -2,7 +2,7 @@
 {%form,formMethodGet=modules.php%}
 <input type="hidden" name="module" value="{%pipe,getModule%}" />
 <input type="hidden" name="what" value="{%pipe,getWhat%}" />
-<input type="hidden" name="network_id" value="{%network,getNetworkDataById,network_id=%network_id%%}" />
+<input type="hidden" name="network_id" value="{%network,getNetworkDataFromId,network_id=%network_id%%}" />
 <div class="table dashed">
        <div class="table_header bottom">
                <div>