New function fetchUserData() introduced to API, total rewrite (not all)
[mailer.git] / inc / pool / pool-bonus.php
index 630562a0894dd27ae72cc7fea80fbfdaf0b6e893..66c350fdf146f561849b0d10a445da6b50d3522f 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
@@ -143,10 +137,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                                                } // 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') {