Huge rewrite of default parameters, ext-network continued:
[mailer.git] / inc / pool / pool-bonus.php
index 630562a0894dd27ae72cc7fea80fbfdaf0b6e893..602820c88c6109769a1043b948ede3ed7bf77626 100644 (file)
@@ -87,14 +87,8 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                        // We can now send mails to them...
                        foreach ($RECEIVERS as $key => $userid) {
                                // Load personal data
-                               //* DEBUG: */ print("*L:".__LINE__.'/'.$userid."*<br />");
-                               $result_user = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
-                                       array(bigintval($userid)), __FILE__, __LINE__);
-
-                               // Is his data available?
-                               if (SQL_NUMROWS($result_user) == 1) {
+                               if (fetchUserData($userid)) {
                                        // The final receiver does exists so we can continue...
-                                       list($surname, $family, $email) = SQL_FETCHROW($result_user);
                                        //* DEBUG: */ print("OK!/L:".__LINE__."<br />");
 
                                        // Mark this user as "spammed" ;-) And place a line for him...
@@ -120,10 +114,10 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                                                // Send mail away
                                                if (isset($DATA['html_msg'])) {
                                                        // Send HTML?
-                                                       sendEmail($email, $DATA['subject'], $mailText, $DATA['html_msg']);
+                                                       sendEmail(getUserData('email'), $DATA['subject'], $mailText, $DATA['html_msg']);
                                                } else {
                                                        // No HTML mail!
-                                                       sendEmail($email, $DATA['subject'], $mailText);
+                                                       sendEmail(getUserData('email'), $DATA['subject'], $mailText);
                                                }
 
                                                // Count one up and remove entry from dummy array
@@ -136,17 +130,14 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                                                } // END - if
 
                                                // Do we have send maximum mails?
-                                               if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (countSelection($dummy) == 0)) {
+                                               if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (countSelection($dummy) == '0')) {
                                                        // Yes, we have
                                                        //* DEBUG: */ print("*EXIT/L:".__LINE__."<br />");
                                                        break;
                                                } // END - if
                                        } // END - if
                                } // END - if
-
-                               // Free some memory
-                               SQL_FREERESULT($result_user);
-                       }
+                       } // END - foreach
 
                        // Update mediadata if version is 0.0.4 or higher
                        if (getExtensionVersion('mediadata') >= '0.0.4') {
@@ -159,7 +150,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
 
                        // Close sending system
                        //* DEBUG: */ print("-L:".__LINE__.'/'.countSelection($dummy)."-<br />");
-                       if (countSelection($dummy) == 0) {
+                       if (countSelection($dummy) == '0') {
                                // Queue reached!
                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1",
                                array(bigintval($DATA['id'])), __FILE__, __LINE__);