]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-unlock_emails.php
Rewrote script to use more EL, introduced wrappers for sending pool:
[mailer.git] / inc / modules / admin / what-unlock_emails.php
index 980ee0cae4ac08f87aeae9661145c31441f1c75f..f87c9c9f58c722d6a0cb6c8bff88c3bfa2f8d693 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(