function insertIntoQueue($queue) { static $alradyProceesed = array(); $db = JFactory::getDBO(); if ($queue->subscriber_id < 0) { return false; } //Added by Grace for the pending of queue $queue->published = $queue->send_date > time() ? 2 : 0; //Note: know what's the use of this line if (empty($queue->list_id)) { //this is for the smartnewsletter $queue->published = 2; } $confirmed = jNews_Subscribers::isConfirmed($queue->subscriber_id); $queue->suspend = $confirmed; $key = serialize($queue); if (isset($alradyProceesed[$key])) { return true; } $alradyProceesed[$key] = true; //if (!$exist){ $query = 'INSERT IGNORE INTO `#__jnews_queue` (`type` , `subscriber_id` , `mailing_id`, `issue_nb`,' . ' `send_date`, `suspend` , `delay`, `acc_level`, `published`, `priority`, `attempt`) VALUES (' . intval($queue->type) . ', ' . intval($queue->subscriber_id) . ' , ' . intval($queue->mailing_id) . ', ' . intval($queue->issue_nb) . ', \'' . $queue->send_date . '\', ' . $queue->suspend . ' , ' . $queue->delay . ' , ' . $queue->acc_level . ' , ' . $queue->published . ' , ' . $queue->priority . ' , ' . $queue->attempt . ')'; $db->setQuery($query); $db->query(); // ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- ONLY FOR AUTO-RESPONDERS --- if (!empty($queue->list_id)) { $type = jNews_Lists::getListType($queue->list_id); if ($type == 2) { $delays = jNews_Mailing::getMailingInfoz($queue->mailing_id, 'delay'); $newQueue->delay = $delays; $newQueue->send_date = time() + $delays * 60; // jnews::getNow( $delays ); $newQueue->published = 2; $arPRiority = empty($GLOBALS[JNEWS . 'ar_prior']) ? 1 : $GLOBALS[JNEWS . 'ar_prior']; $newQueue->priority = $arPRiority; $query = 'UPDATE `#__jnews_queue` SET `send_date`=' . $newQueue->send_date; $query .= ' , `delay`=' . $newQueue->delay; $query .= ' , `published`=' . $newQueue->published; $query .= ' , `priority`=' . $newQueue->priority; $query .= ' , `suspend`=' . $confirmed; $query .= ' WHERE `subscriber_id` = ' . $queue->subscriber_id; $query .= ' and `mailing_id` = ' . $queue->mailing_id; $db->setQuery($query); $db->query(); } return true; } //end if return true; //} }
public static function subscribeARtoQueue($subscriberID, $subscribeARA) { $db = JFactory::getDBO(); $confirmed = jNews_Subscribers::isConfirmed($subscriberID); // $time = jnews::getNow(); $time = time(); //we check to make sure we are not wrong with the values passed if (is_array($subscribeARA)) { $list2Subscribe = count($subscribeARA > 1) ? implode(',', $subscribeARA) : $subscribeARA[0]; } else { $list2Subscribe = $subscribeARA; } $selectQuery = 'SELECT ' . $subscriberID . ',A.`mailing_id`,' . $time . ' + B.`delay`*60,1,' . $confirmed . ',2'; $selectQuery .= ' FROM `#__jnews_listmailings` as A LEFT JOIN `#__jnews_mailings` as B on A.`mailing_id` = B.`id`'; $selectQuery .= ' WHERE A.`list_id` IN (' . $list2Subscribe . ') AND B.`published` = 1'; $query = 'INSERT IGNORE INTO `#__jnews_queue` (`subscriber_id`,`mailing_id`,`send_date`,`priority`,`suspend`,`type`) ' . $selectQuery; $db->setQuery($query); $db->query(); /**we call this public static function to add a flag in the queue that the subscriber had already received all of the mailings in the queue *from the subscribed AR */ jNews_ListsSubs::flagAR($subscriberID, $subscribeARA); }