Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / pool / pool-bonus.php
index 58ea34151ca1904b52faf657acef63f454805ba8..eb263b9905241feda5c5aa0995d6539756be13b6 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -44,8 +44,8 @@ if (!defined('__SECURITY')) {
 if ((isResetModeEnabled()) || (!isHtmlOutputMode())) {
        // Skip here
        return FALSE;
-} elseif (!isExtensionActive('bonus')) {
-       // Abort if extension bonus is not active
+} elseif ((!isExtensionActive('bonus')) || (!isExtensionActive('other'))) {
+       // Abort if extension bonus/other are not active
        return FALSE;
 }
 
@@ -61,7 +61,7 @@ if ($GLOBALS['pool_cnt'] < getMaxSend()) {
        } // END - if
 
        // Run query
-       $result_main = SQL_QUERY("SELECT
+       $result_main = sqlQuery("SELECT
        `id`,
        `subject`,
        `text`,
@@ -82,15 +82,15 @@ ORDER BY
        `timestamp` DESC", __FILE__, __LINE__);
 
        // Some mails left?
-       if (!SQL_HASZERONUMS($result_main)) {
+       if (!ifSqlHasZeroNumRows($result_main)) {
                // Init SQLs here
                initSqls();
 
                // Send these mails away...
                $count2 = '';
-               while ($mailData = SQL_FETCHARRAY($result_main)) {
+               while ($mailData = sqlFetchArray($result_main)) {
                        // Message is active in queue
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
+                       sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
                                array(bigintval($mailData['id'])), __FILE__, __LINE__);
 
                        // Default is no users left
@@ -175,7 +175,7 @@ ORDER BY
                        //* DEBUG: */ debugOutput('-L:'.__LINE__.'/'.countSelection($temporaryReceivers).'-');
                        if (countSelection($temporaryReceivers) == 0) {
                                // Queue reached!
-                               SQL_QUERY_ESC("UPDATE
+                               sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_bonus`
 SET
        `data_type`='SEND',
@@ -195,7 +195,7 @@ LIMIT 1",
                                } // END - if
                        } elseif ($GLOBALS['pool_cnt'] >= getMaxSend()) {
                                // Update bonus pool
-                               SQL_QUERY_ESC("UPDATE
+                               sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_bonus`
 SET
        `data_type`='NEW',
@@ -219,7 +219,7 @@ LIMIT 1",
        } // END - if
 
        // Free memory
-       SQL_FREERESULT($result_main);
+       sqlFreeResult($result_main);
 
        // Remove variable
        unset($mailText);