$userid) { // Load personal data if (fetchUserData($userid)) { // The final receiver does exists so we can continue... //* DEBUG: */ debugOutput('OK!/L:'.__LINE__); // Remove receiver from list $status = removeReceiver($temporaryReceivers, $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($temporaryReceivers[$key]); // Is ext-user installed? if (isExtensionInstalledAndNewer('user', '0.1.4')) { // Debug message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',mailData[id]=' . $mailData['id']); // Update mails received for receiver addSql(sprintf("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1", bigintval($userid))); } // END - if // Is the size of pool reached or nothing to sent left? if (($GLOBALS['pool_cnt'] >= getMaxSend()) || (countSelection($temporaryReceivers) == 0)) { // Yes, it is. So abort here 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); break; } // END - switch } // END - if } // END - foreach // Run all SQLs runFilterChain('run_sqls'); // Update mediadata if version is 0.0.4 or higher if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { // Update entry (or add missing $P = $GLOBALS['pool_cnt']; if (!empty($count2) && empty($GLOBALS['pool_cnt'])) $P = $count2; //* DEBUG: */ debugOutput('+MEDIA/L:'.__LINE__.'/'.$P.'+'); updateMediadataEntry(array('total_send', 'bonus_send'), 'add', $P); } // END - if // Close sending system //* DEBUG: */ debugOutput('-L:'.__LINE__.'/'.countSelection($temporaryReceivers).'-'); if (countSelection($temporaryReceivers) == 0) { // Queue reached! sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1", array(bigintval($mailData['id'])), __FILE__, __LINE__); //* DEBUG: */ debugOutput('*L:'.__LINE__.'*'); // Update mediadata if version is 0.0.4 or higher if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { // Update entry (or add missing) //* DEBUG: */ debugOutput('*MEDIA/L:'.__LINE__.'*'); updateMediadataEntry(array('total_orders', 'bonus_orders'), 'add', 1); } // END - if } elseif ($GLOBALS['pool_cnt'] >= getMaxSend()) { // Update bonus pool sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='NEW', `target_send`=%s, `receivers`='%s' WHERE `id`=%s LIMIT 1", array( countSelection($temporaryReceivers), implode(';', $temporaryReceivers), bigintval($mailData['id']) ), __FILE__, __LINE__); //* DEBUG: */ debugOutput('*L:'.__LINE__.'
'.print_r($temporaryReceivers, TRUE).'
!!!'); // Run any SQLs runFilterChain('run_sqls'); break; } } // END - while } // END - if // Free memory sqlFreeResult($result_main); // Remove variable unset($mailText); } // END - if // [EOF] ?>