function updateList($listId, $listUpdated, $status, $new)
 {
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $total = 0;
     @set_time_limit(0);
     if ($listUpdated->list_type != '7' and $listUpdated->delay_min > $listUpdated->delay_max) {
         $listUpdated->delay_min = $listUpdated->delay_max;
     }
     $erro->ck = lists::updateListData($listUpdated);
     if (!$erro->Eck(__LINE__, '8304')) {
         return false;
     } else {
         if ($listUpdated->auto_add == 2) {
             subscribers::updateSubscribers(true);
             $subscribers = subscribers::getSubscribers(-1, -1, '', $total, 0, '', 1, 1, '');
             $subId = acajoom::convertObjectToIdList($subscribers, 'id');
             if (!empty($subId)) {
                 $erro->ck = queue::updateQueues($subId, '', $listId, $listUpdated->acc_id, $new);
                 if (!$erro->Eck(__LINE__, '8305')) {
                     return false;
                 }
             }
         } elseif ($status == '' and $listUpdated->list_type == 2) {
             $queues = queue::getAllOneList($listId);
             $qid = acajoom::convertObjectToIdList($queues, 'qid');
             $erro->ck = queue::updatePublished($qid, $status);
             if (!$erro->Eck(__LINE__, '8306')) {
                 return false;
             }
         } else {
             if (class_exists('auto')) {
                 auto::updateListNb($listUpdated->list_type, $listUpdated->id);
             }
         }
     }
     lisType::updateNewsletters();
     return true;
 }
Exemple #2
0
 function confirmRegistration($d)
 {
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     if (!empty($d['subscriberId']) and !empty($d['cle'])) {
         $qid[0] = $d['subscriberId'];
         $subscriber = subscribers::getSubscribersFromId($qid, false);
         if (md5($subscriber->email) == $d['cle']) {
             $subscriber->confirmed = 1;
             $erro->ck = subscribers::updateSubscriber($subscriber, $notused);
             if ($erro->Eck(__LINE__, '8275', $d)) {
                 $queues = queue::getSubscriberLists($d['subscriberId']);
                 $qids = acajoom::convertObjectToIdList($queues, 'qid');
                 $erro->ck = queue::updateSuspend($qids, 0);
                 return $erro->Eck(__LINE__, '8276');
             }
         }
     }
     return false;
 }
 function saveMailing(&$mailingId, $listId)
 {
     global $database;
     $list = lists::getOneList($listId);
     $allow_html = compa::allow_html();
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $xf = new xonfig();
     $listType = mosGetParam($_REQUEST, 'listype', 0);
     $senddate = mosGetParam($_REQUEST, 'senddate', '0000-00-00 00:00:00');
     if (mosGetParam($_REQUEST, 'task', '') == 'saveSend') {
         $senddate = acajoom::getNow();
     }
     $subject = mosGetParam($_REQUEST, 'subject', '', $allow_html);
     $content = mosGetParam($_REQUEST, 'content', '', $allow_html);
     $alt_content = mosGetParam($_REQUEST, 'alt_content', '', _MOS_ALLOWRAW);
     $published = mosGetParam($_REQUEST, 'published', 0);
     $visible = mosGetParam($_REQUEST, 'visible', 1);
     $html = mosGetParam($_REQUEST, 'html', 1);
     $new_list = mosGetParam($_REQUEST, 'new_list', 0);
     $fromname = mosGetParam($_REQUEST, 'fromname', '');
     $fromemail = mosGetParam($_REQUEST, 'fromemail', '');
     $frombounce = mosGetParam($_REQUEST, 'frombounce', '');
     $userid = mosGetParam($_REQUEST, 'userid', 0);
     $delay = mosGetParam($_REQUEST, 'delay', 1);
     $acc_level = mosGetParam($_REQUEST, 'acc_level', $list->acc_id);
     $issue_nb = mosGetParam($_REQUEST, 'issue_nb', 1);
     $delay = $delay * 24 * 60;
     $attachments = mosGetParam($_REQUEST, 'attachments', '');
     $attach = '';
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             $attach .= $attachment . "\n";
         }
     }
     if (!empty($_FILES['file_0']['name'])) {
         $otherAttachs = xmailing::uploadFiles();
         if (!empty($otherAttachs)) {
             foreach ($otherAttachs as $otherAttach) {
                 $attach .= '/' . $otherAttach . "\n";
             }
         }
     }
     $images = mosGetParam($_REQUEST, 'images', '');
     if ($html == 0) {
         $alt_content = $content;
     }
     if ($senddate != '0000-00-00 00:00:00' and $senddate > acajoom::getNow()) {
         $published = 2;
     }
     if ($new_list != 0) {
         $query = 'INSERT INTO `#__acajoom_mailings` (`list_id`, `list_type`, `send_date`, `subject`, `htmlcontent`, `textonly`, `attachments`, `images`, `published`, `html`, `visible`, `fromname`, `fromemail`, `frombounce`, `author_id`, `delay`, `issue_nb` , `acc_level` , `createdate`) VALUES( \'' . $listId . '\', \'' . $listType . '\', \'' . $senddate . '\', \'' . addslashes($subject) . '\', \'' . addslashes($content) . '\', \'' . addslashes($alt_content) . '\', \'' . $attach . '\', \'' . $images . '\', \'' . $published . '\', \'' . $html . '\', \'' . $visible . '\', \'' . $fromname . '\', \'' . $fromemail . '\', \'' . $frombounce . '\', \'' . $userid . '\', \'' . $delay . '\', \'' . $issue_nb . '\', \'' . $acc_level . '\' , \'' . acajoom::getNow() . '\' ) ';
         $database->setQuery($query);
         $database->query();
         $erro->err = $database->getErrorMsg();
         $query = 'SELECT max(id) FROM `#__acajoom_mailings` WHERE `list_id` = ' . $listId . ' AND `issue_nb` = \'' . $issue_nb . '\'';
         $query .= ' AND `published` != -1 ';
         $database->setQuery($query);
         $mailingId = $database->loadResult();
         $erro->err .= $database->getErrorMsg();
         if ($mailingId == 1) {
             $xf->update('firstmailing', $listType);
         }
         $xf->plus('totalmailing0', 1);
         $xf->plus('act_totalmailing0', 1);
         $xf->plus('totalmailing' . $listType, 1);
         $xf->plus('act_totalmailing' . $listType, 1);
         xmailing::insertStatsGlobal($mailingId);
     } else {
         $query = "UPDATE `#__acajoom_mailings` SET " . "\t`subject` = '" . addslashes($subject) . "', " . "\t`htmlcontent` = '" . addslashes($content) . "', " . "\t`textonly` = '" . addslashes($alt_content) . "', " . "\t`attachments` = '{$attach}', " . "\t`images` = '{$images}', " . "\t`published` = '{$published}', " . "\t`html` = {$html} , " . "\t`visible` = {$visible} , " . "\t`fromname` = '{$fromname}', " . "\t`fromemail` = '{$fromemail}', " . "\t`frombounce` = '{$frombounce}', " . "\t`author_id` =  '{$userid}' , " . "\t`delay` = {$delay} , " . "\t`acc_level` = {$acc_level} , " . "\t`send_date` = '{$senddate}' " . "\tWHERE `id` = {$mailingId} ";
         $database->setQuery($query);
         $database->query();
         $erro->err = $database->getErrorMsg();
     }
     if (!$erro->E(__LINE__, '8414', $database)) {
         return false;
     } else {
         lisType::updateNewsletters();
         if ($listType == 2) {
             if ($new_list) {
                 $subscribers = subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 1, '');
             } else {
                 $subscribers = subscribers::getSubscribers(-1, -1, '', $total, $listId, $mailingId, 1, 1, '');
             }
             $subsId = acajoom::convertObjectToIdList($subscribers, 'id');
             if (!empty($subsId)) {
                 $queues = queue::getAllOneList($listId);
                 if (!empty($queues)) {
                     if ($queues[0]->mailing_id == 0) {
                         $qids = acajoom::convertObjectToIdList($queues, 'qid');
                         $erro->ck = queue::updateQueues('', $qids, $listId, $acc_level, false);
                     } else {
                         $erro->ck = queue::updateQueues($subsId, '', $listId, $acc_level, false);
                     }
                 } else {
                     return true;
                 }
                 if (!$erro->Eck(__LINE__, '8415')) {
                     return false;
                 }
             }
         } elseif ($listType == 1 and $senddate > acajoom::getNow()) {
             $subscribers = subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 1, '');
             $subsId = acajoom::convertObjectToIdList($subscribers, 'id');
             if (!empty($subsId)) {
                 if ($new_list == 1) {
                     if (class_exists('auto')) {
                         $erro->ck = auto::insertQueuesForScheduledNews($subsId, $listId, $acc_level, $mailingId, $senddate);
                     }
                 } else {
                     $queues = queue::getQueueFromMailingId($mailingId);
                     if (!empty($queues)) {
                         $erro->ck = queue::updateQueueData('', $subsId, 1, $listId, $mailingId, $issue_nb, $senddate, 0, $acc_level, 2);
                         return $erro->Eck(__LINE__, '8417', 'put here 1 $d');
                     } else {
                         if (class_exists('auto')) {
                             $erro->ck = auto::insertQueuesForScheduledNews($subsId, $listId, $acc_level, $mailingId, $senddate);
                         }
                     }
                 }
                 return $erro->Eck(__LINE__, '8416', 'put here 2 $d');
             }
         }
         return true;
     }
 }
Exemple #4
0
 function updateQueues($subId, $qids, $listId, $acc_level, $new)
 {
     if (ACA_CMSTYPE) {
         $database =& JFactory::getDBO();
     } else {
         global $database;
     }
     //endif
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $list = lists::getOneList($listId);
     if ($list->list_type == 1) {
         if ($new) {
             if (!empty($subId)) {
                 $erro->ck = queue::insertQueuesForNews($subId, $listId, $acc_level);
                 $erro->Eck(__LINE__, '8504');
             } else {
                 if (!empty($qids)) {
                     $qid = implode(',', $qids);
                     $query = 'SELECT `subscriber_id` FROM `#__acajoom_queue` WHERE `qid` IN ( ' . $qid . ' ) ';
                     $database->setQuery($query);
                     $subIds = $database->loadObjectList();
                     $erro->err = $database->getErrorMsg();
                 }
                 foreach ($subIds as $v) {
                     $subId[] = $v->subscriber_id;
                 }
                 $erro->ck = queue::insertQueuesForNews($subId, $listId, $acc_level);
                 $erro->E(__LINE__, '8505');
             }
         } else {
             if (!empty($subId)) {
                 $erro->ck = queue::updateQueueData('', $subId, 0, $listId, 0, 0, 0, 0, $acc_level, 0);
                 $erro->Eck(__LINE__, '8506');
             } elseif (!empty($qids)) {
                 $erro->ck = queue::updateQueueData($qids, '', 0, $listId, 0, 0, 0, 0, $acc_level, 0);
                 $erro->Eck(__LINE__, '8507');
             }
         }
     } elseif ($list->list_type == 7) {
         $newQueue->list_id = $list->id;
         $newQueue->mailing_id = 0;
         $newQueue->issue_nb = 0;
         $newQueue->send_date = 0;
         $newQueue->delay = 0;
         $newQueue->acc_level = $acc_level;
         $newQueue->published = $list->published;
         $erro->ck = autonews::insertQueuesForAutoNews($subId, $newQueue);
         $erro->Eck(__LINE__, '8508');
     } else {
         if ($new) {
             if (!empty($subId)) {
                 $mailingId = 0;
                 $mailing = queue::getValidMailing($list, $mailingId);
                 if (!empty($mailing)) {
                     if (class_exists('auto')) {
                         if ($mailing->list_type == 2) {
                             $newQueue->list_id = $mailing->list_id;
                             $newQueue->mailing_id = $mailing->id;
                             $newQueue->issue_nb = $mailing->issue_nb;
                             $newQueue->send_date = acajoom::getNow($mailing->delay);
                             $newQueue->delay = $mailing->delay;
                             $newQueue->acc_level = $acc_level;
                             $newQueue->published = $list->published;
                             $erro->ck = auto::insertQueuesForAuto($subId, $newQueue);
                             $erro->Eck(__LINE__, '8508');
                         } else {
                             $erro->ck = queue::insertQueuesForNews($subId, $mailing->list_id, $acc_level);
                             $erro->Eck(__LINE__, '8509');
                         }
                     }
                 } else {
                     if (class_exists('auto')) {
                         $newQueue->list_id = $list->id;
                         $newQueue->mailing_id = 0;
                         $newQueue->issue_nb = 0;
                         $newQueue->send_date = 0;
                         $newQueue->delay = 0;
                         $newQueue->acc_level = $acc_level;
                         $newQueue->published = $list->published;
                         $erro->ck = auto::insertQueuesForAuto($subId, $newQueue);
                         $erro->Eck(__LINE__, '8510');
                     }
                 }
             } elseif (!empty($qids)) {
                 //On r�cup�re le premier mail du follow up
                 $mailingId = xmailing::getFirstMailingId($listId);
                 if (!empty($mailingId)) {
                     $mailing = queue::getValidMailing($list, $mailingId);
                     if (!empty($mailing)) {
                         if ($mailing->list_type == 2) {
                             //$subscribers = subscribers::getSubscribers( -1 , -1 , '' , $total , $listId, '', 1, 1,'' );
                             //$subId = acajoom::convertObjectToIdList($subscribers , 'id');
                             if (!empty($subId)) {
                                 $erro->ck = queue::updateQueueData('', $subId, $mailing->list_type, $listId, $mailing->id, $mailing->issue_nb, 0, $mailing->delay, 0, 1);
                                 $erro->Eck(__LINE__, '8511');
                             } else {
                                 $erro->ck = queue::updateQueueData($qids, '', $mailing->list_type, $listId, $mailing->id, $mailing->issue_nb, 0, $mailing->delay, 0, 1);
                                 $erro->Eck(__LINE__, '8511');
                             }
                         } else {
                             $subscribers = subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 1, '');
                             $subId = acajoom::convertObjectToIdList($subscribers, 'id');
                             $erro->ck = queue::insertQueuesForNews($subId, $mailing->list_id, $acc_level);
                             $erro->Eck(__LINE__, '8512');
                         }
                     }
                 }
             }
         } else {
             if (!empty($subId)) {
                 $mailing = queue::getValidMailing($list, 0);
                 if (!empty($mailing)) {
                     $erro->ck = queue::updateQueueData('', $subId, $list->list_type, $listId, '', '', 0, '', 0, $list->published);
                 } else {
                     $erro->ck = queue::updateQueueData('', $subId, $mailing->list_type, $mailing->list_id, $mailing->id, $mailing->issue_nb, acajoom::getNow(), $mailing->delay, $acc_level, $mailing->published);
                 }
                 $erro->E(__LINE__, '8513');
             } elseif (!empty($qids)) {
                 $mailing = queue::getValidMailing($list, 0);
                 if (!empty($mailing)) {
                     if ($mailing->list_type == 2) {
                         $erro->ck = queue::updateQueueData($qids, '', $list->list_type, $listId, $mailing->id, $mailing->issue_nb, acajoom::getNow(), $mailing->delay, 0, 1);
                         $erro->E(__LINE__, '8514');
                     } else {
                         $subId = acajoom::convertObjectToIdList($qids, 'subscriber_id');
                         $erro->ck = queue::deleteQueues($qids);
                         $erro->Eck(__LINE__, '8515');
                         $erro->ck = queue::insertQueuesForNews($subId, $mailing->list_id, $acc_level);
                         $erro->Eck(__LINE__, '8516');
                     }
                 }
             }
         }
     }
     return $erro->R();
 }