Exemplo n.º 1
0
 static function insertQueuesForNews($subId, $listId, $acc_level)
 {
     $mailing_ids = array();
     $mailing_ids = jNews_Mailing::getListMailing($listId);
     $status = true;
     if (is_array($subId)) {
         for ($k = 0; $k < count($subId); $k++) {
             if (is_array($mailing_ids)) {
                 for ($i = 0; $i < sizeOf($mailing_ids); $i++) {
                     // check subscribers confirmed status
                     $result = jNews_Subscribers::isSubConfirmed($subId[$k]);
                     $queue = new stdClass();
                     $queue->id = 0;
                     $queue->subscriber_id = $subId[$k];
                     $queue->list_id = $listId;
                     $queue->type = 1;
                     $queue->mailing_id = $mailing_ids[$i];
                     $queue->send_date = jNews_Mailing::getSendDate($mailing_ids[$i]);
                     $queue->suspend = !empty($result) ? 1 : 0;
                     $queue->delay = 0;
                     $queue->acc_level = $acc_level;
                     $queue->issue_nb = 0;
                     $queue->published = 0;
                     $queue->priority = 0;
                     $queue->attempt = 0;
                     jNews_Queue::insertIntoQueue($queue);
                 }
                 $subscriber = new stdClass();
                 $subscriber->list_id = $listId;
                 $subscriber->id = $subId[$k];
                 jNews_ListsSubs::saveToListSubscribers($subscriber);
             } else {
                 // check subscribers confirmed status
                 $result = jNews_Subscribers::isSubConfirmed($subId[$k]);
                 $queue = new stdClass();
                 $queue->id = 0;
                 $queue->subscriber_id = $subId[$k];
                 $queue->list_id = $listId;
                 $queue->type = 1;
                 $queue->mailing_id = $mailing_ids;
                 $queue->send_date = jNews_Mailing::getSendDate($mailing_ids);
                 $queue->suspend = !empty($result) ? 1 : 0;
                 $queue->delay = 0;
                 $queue->acc_level = $acc_level;
                 $queue->issue_nb = 0;
                 $queue->published = 0;
                 $queue->priority = 0;
                 $queue->attempt = 0;
                 $subscriber = new stdClass();
                 $subscriber->list_id = $listId;
                 $subscriber->id = $subId[$k];
                 jNews_ListsSubs::saveToListSubscribers($subscriber);
                 jNews_Queue::insertIntoQueue($queue);
             }
         }
     } else {
         if (is_array($mailing_ids)) {
             // check subscribers confirmed status
             $result = jNews_Subscribers::isSubConfirmed($subId);
             for ($i = 0; $i < sizeOf($mailing_ids); $i++) {
                 $queue = new stdClass();
                 $queue->id = 0;
                 $queue->subscriber_id = $subId;
                 $queue->list_id = $listId;
                 $queue->type = 1;
                 $queue->mailing_id = $mailing_ids[$i];
                 $queue->send_date = jNews_Mailing::getSendDate($mailing_ids[$i]);
                 $queue->suspend = !empty($result) ? 1 : 0;
                 if ($GLOBALS[JNEWS . 'require_confirmation']) {
                     $queue->suspend = 1;
                 } else {
                     $queue->suspend = 0;
                 }
                 $queue->delay = 0;
                 $queue->acc_level = $acc_level;
                 $queue->issue_nb = 0;
                 $queue->published = 0;
                 $queue->priority = 0;
                 $queue->attempt = 0;
                 jNews_Queue::insertIntoQueue($queue);
             }
             $subscriber = new stdClass();
             $subscriber->list_id = $listId;
             $subscriber->id = $subId;
             jNews_ListsSubs::saveToListSubscribers($subscriber);
         } else {
             // check subscribers confirmed status
             $result = jNews_Subscribers::isSubConfirmed($subId);
             $queue = new stdClass();
             $queue->id = 0;
             $queue->subscriber_id = $subId;
             $queue->list_id = $listId;
             $queue->type = 1;
             $queue->mailing_id = $mailing_ids;
             $queue->send_date = jNews_Mailing::getSendDate($mailing_ids);
             $queue->suspend = !empty($result) ? 1 : 0;
             $queue->delay = 0;
             $queue->acc_level = $acc_level;
             $queue->issue_nb = 0;
             $queue->published = 0;
             $queue->priority = 0;
             $queue->attempt = 0;
             $subscriber = new stdClass();
             $subscriber->list_id = $listId;
             $subscriber->id = $subId;
             jNews_ListsSubs::saveToListSubscribers($subscriber);
             jNews_Queue::insertIntoQueue($queue);
         }
     }
     return $status;
 }