- // Mark this user as "spammed" ;-) And place a line for him...
- if (removeReceiver($dummy, $key, $userid, $DATA['id'], $DATA['id'], true) == 'done') {
- // Replace text variables
- foreach ($GLOBALS['replacer'] as $key => $value) {
- if (isset($DATA[$key])) $DATA['text'] = str_replace($value, $DATA[$key], $DATA['text']);
- } // END - foreach
-
- // Prepare the mail
- $mailText = loadEmailTemplate('bonus-mail', $DATA, $userid);
-
- // Send mail away
- if (isset($DATA['html_msg'])) {
- // Send HTML?
- sendEmail(getUserData('email'), $DATA['subject'], $mailText, $DATA['html_msg']);
- } else {
- // No HTML mail!
- sendEmail(getUserData('email'), $DATA['subject'], $mailText);
- }
-
- // Count one up and remove entry from dummy array
- $GLOBALS['pool_cnt']++; unset($dummy[$key]);
-
- if (isExtensionInstalledAndNewer('user', '0.1.4')) {
- // Update mails received for receiver
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
- array(bigintval($userid)), __FILE__, __LINE__);
- } // END - if
-
- // Do we have send maximum mails?
- if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (countSelection($dummy) == 0)) {
- // Yes, we have
- //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__);
+ // Remove receiver from list
+ $status = removeReceiver($dummy, $key, $userid, $mailData['id'], $mailData['id'], true);
+
+ // Did it work?
+ switch ($status) {
+ case 'done': // Done!
+ // Prepare the mail
+ $mailText = loadEmailTemplate('member_bonus_pool_normal', $mailData, $userid);
+
+ // Send mail away
+ if (isset($mailData['html_msg'])) {
+ // Send HTML?
+ sendEmail(getUserData('userid'), $mailData['subject'], $mailText, $mailData['html_msg']);
+ } else {
+ // No HTML mail!
+ sendEmail(getUserData('userid'), $mailData['subject'], $mailText);
+ }
+
+ // Count one up and remove entry from dummy array
+ $GLOBALS['pool_cnt']++; unset($dummy[$key]);
+
+ if (isExtensionInstalledAndNewer('user', '0.1.4')) {
+ // Update mails received for receiver
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
+ array(bigintval($userid)), __FILE__, __LINE__);
+ } // END - if
+
+ // Do we have send maximum mails?
+ if (($GLOBALS['pool_cnt'] >= getMaxSend()) || (countSelection($dummy) == 0)) {
+ // Yes, we have
+ //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__);
+ break;
+ } // END - if
+ break;
+
+ default: // Unknown return type
+ logDebugMessage(__FILE__, __LINE__, 'Unknown status ' . $status . ' detected. pool_id=' . $mailData['id'] . ',userid=' . $mailData['userid'] . ',stats_id=' . $stats_id);