Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 function updateListFromEdit($listId, $status, $new)
 {
     global $my;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $listUpdated = '';
     $total = 0;
     $allow_html = compa::allow_html();
     $listUpdated->id = $listId;
     $listUpdated->list_name = mosGetParam($_REQUEST, 'list_name', '', $allow_html);
     $listUpdated->list_desc = mosGetParam($_REQUEST, 'list_desc', '', $allow_html);
     //$listUpdated->list_desc = str_replace('"', '"' , $listUpdated->list_desc);
     //$listUpdated->list_name = str_replace('"', '"' , $listUpdated->list_name);
     $listUpdated->sendername = mosGetParam($_REQUEST, 'sendername', '');
     $listUpdated->senderemail = mosGetParam($_REQUEST, 'senderemail', '');
     $listUpdated->bounceadres = mosGetParam($_REQUEST, 'bounceadres', '');
     $listUpdated->layout = mosGetParam($_REQUEST, 'layout', '', $allow_html);
     $listUpdated->template = mosGetParam($_REQUEST, 'template', 0);
     $listUpdated->subscribemessage = mosGetParam($_REQUEST, 'subscribemessage', '', $allow_html);
     $listUpdated->unsubscribemessage = mosGetParam($_REQUEST, 'unsubscribemessage', '', $allow_html);
     $listUpdated->unsubscribesend = mosGetParam($_REQUEST, 'unsubscribesend', 1);
     $listUpdated->html = mosGetParam($_REQUEST, 'html', 1);
     $listUpdated->hidden = mosGetParam($_REQUEST, 'hidden', 0);
     $listUpdated->list_type = mosGetParam($_REQUEST, 'list_type', 1);
     $listUpdated->auto_add = mosGetParam($_REQUEST, 'auto_add', 0);
     $listUpdated->user_choose = mosGetParam($_REQUEST, 'user_choose', 0);
     $listUpdated->cat_id = mosGetParam($_REQUEST, 'cat_id', 0);
     $listUpdated->delay_min = mosGetParam($_REQUEST, 'delay_min', 0);
     $listUpdated->delay_max = mosGetParam($_REQUEST, 'delay_max', 0);
     $listUpdated->follow_up = mosGetParam($_REQUEST, 'follow_up', 0);
     $listUpdated->notify_id = $listUpdated->list_type == '7' ? mosGetParam($_REQUEST, 'notify_id', 0) : 0;
     $listUpdated->owner = $my->id;
     $listUpdated->auto_add = mosGetParam($_REQUEST, 'auto_add', 0);
     $listUpdated->acc_level = mosGetParam($_REQUEST, 'acc_level', 25);
     $listUpdated->acc_id = mosGetParam($_REQUEST, 'acc_id', 29);
     $listUpdated->footer = mosGetParam($_REQUEST, 'footer', 1);
     $listUpdated->start_date = mosGetParam($_REQUEST, 'start_date', 0);
     $listUpdated->next_date = mosGetParam($_REQUEST, 'next_date', 0);
     $listUpdated->notification = 0;
     if ($status == '') {
         $listUpdated->published = mosGetParam($_REQUEST, 'published', 0);
     } else {
         $listUpdated->published = $status;
     }
     if ($listUpdated->published == 0 and ($listUpdated->list_type == 2 or $listUpdated->list_type == 3)) {
         $published = 0;
     } else {
         $published = $listUpdated->published;
     }
     if (!empty($listUpdated->hidden)) {
         $visible = $listUpdated->hidden;
     } else {
         $visible = 0;
     }
     if ($new) {
         $published = $listUpdated->published;
     }
     if (!lists::updateList($listId, $listUpdated, $status, $new)) {
         return false;
     }
     if ($listUpdated->list_type != 11) {
         return xmailing::updateMailingFromList($listId, $published, $listUpdated->html, $visible);
     } else {
         return true;
     }
 }
Ejemplo n.º 3
0
 function updateListFromEdit($listId, $status, $new)
 {
     if (ACA_CMSTYPE) {
         // joomla 15
         $my =& JFactory::getUser();
     } else {
         //joomla 1x
         global $my;
     }
     //endif
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $listUpdated = '';
     $total = 0;
     $allow_html = compa::allow_html();
     $listUpdated->id = $listId;
     if (ACA_CMSTYPE) {
         // joomla 15
         $issue_nb = JRequest::getVar('issue_nb', '0');
         $listUpdated->list_name = JRequest::getVar('list_name', '', 'request', 'string', $allow_html);
         $listUpdated->list_desc = JRequest::getVar('list_desc', '', 'request', 'string', $allow_html);
         $listUpdated->sendername = JRequest::getVar('sendername', '');
         $listUpdated->senderemail = JRequest::getVar('senderemail', '');
         $listUpdated->bounceadres = JRequest::getVar('bounceadres', '');
         $listUpdated->layout = JRequest::getVar('layout', '', 'request', 'string', $allow_html);
         $listUpdated->template = JRequest::getVar('template', 0);
         $listUpdated->subscribemessage = JRequest::getVar('subscribemessage', '', 'request', 'string', $allow_html);
         $listUpdated->unsubscribemessage = JRequest::getVar('unsubscribemessage', '', 'request', 'string', $allow_html);
         $listUpdated->unsubscribesend = JRequest::getVar('unsubscribesend', 1);
         $listUpdated->html = JRequest::getVar('html', 1);
         $listUpdated->hidden = JRequest::getVar('hidden', 0);
         $listUpdated->list_type = JRequest::getVar('list_type', 1);
         $listUpdated->auto_add = JRequest::getVar('auto_add', 0);
         $listUpdated->user_choose = JRequest::getVar('user_choose', 0);
         $listUpdated->cat_id = implode(',', JRequest::getVar('cat_id', array()));
         $listUpdated->delay_min = JRequest::getVar('delay_min', 0);
         $listUpdated->delay_max = JRequest::getVar('delay_max', 0);
         $listUpdated->follow_up = JRequest::getVar('follow_up', 0);
         $listUpdated->notify_id = $listUpdated->list_type == '7' ? JRequest::getVar('notify_id', 0) : 0;
         $listUpdated->auto_add = JRequest::getVar('auto_add', 0);
         $listUpdated->acc_level = JRequest::getVar('acc_level', 25);
         $listUpdated->acc_id = JRequest::getVar('acc_id', 29);
         $listUpdated->footer = JRequest::getVar('footer', 1);
         $listUpdated->start_date = JRequest::getVar('start_date', '');
         $listUpdated->next_date = JRequest::getVar('next_date', 0);
     } else {
         //joomla 1x
         $listUpdated->list_name = mosGetParam($_REQUEST, 'list_name', '', $allow_html);
         $listUpdated->list_desc = mosGetParam($_REQUEST, 'list_desc', '', $allow_html);
         $listUpdated->sendername = mosGetParam($_REQUEST, 'sendername', '');
         $listUpdated->senderemail = mosGetParam($_REQUEST, 'senderemail', '');
         $listUpdated->bounceadres = mosGetParam($_REQUEST, 'bounceadres', '');
         $listUpdated->layout = mosGetParam($_REQUEST, 'layout', '', $allow_html);
         $listUpdated->template = mosGetParam($_REQUEST, 'template', 0);
         $listUpdated->subscribemessage = mosGetParam($_REQUEST, 'subscribemessage', '', $allow_html);
         $listUpdated->unsubscribemessage = mosGetParam($_REQUEST, 'unsubscribemessage', '', $allow_html);
         $listUpdated->unsubscribesend = mosGetParam($_REQUEST, 'unsubscribesend', 1);
         $listUpdated->html = mosGetParam($_REQUEST, 'html', 1);
         $listUpdated->hidden = mosGetParam($_REQUEST, 'hidden', 0);
         $listUpdated->list_type = mosGetParam($_REQUEST, 'list_type', 1);
         $listUpdated->auto_add = mosGetParam($_REQUEST, 'auto_add', 0);
         $listUpdated->user_choose = mosGetParam($_REQUEST, 'user_choose', 0);
         $listUpdated->cat_id = implode(',', mosGetParam($_REQUEST, 'cat_id', array()));
         $listUpdated->delay_min = mosGetParam($_REQUEST, 'delay_min', 0);
         $listUpdated->delay_max = mosGetParam($_REQUEST, 'delay_max', 0);
         $listUpdated->follow_up = mosGetParam($_REQUEST, 'follow_up', 0);
         $listUpdated->notify_id = $listUpdated->list_type == '7' ? mosGetParam($_REQUEST, 'notify_id', 0) : 0;
         $listUpdated->auto_add = mosGetParam($_REQUEST, 'auto_add', 0);
         $listUpdated->acc_level = mosGetParam($_REQUEST, 'acc_level', 25);
         $listUpdated->acc_id = mosGetParam($_REQUEST, 'acc_id', 29);
         $listUpdated->footer = mosGetParam($_REQUEST, 'footer', 1);
         $listUpdated->start_date = mosGetParam($_REQUEST, 'start_date', '');
         $listUpdated->next_date = mosGetParam($_REQUEST, 'next_date', 0);
     }
     //endif
     $listUpdated->owner = $my->id;
     $listUpdated->notification = 0;
     if ($status == '') {
         if (ACA_CMSTYPE) {
             // joomla 15
             $listUpdated->published = JRequest::getVar('published', 0);
         } else {
             $listUpdated->published = intval(mosGetParam($_REQUEST, 'published', 0));
         }
         //endif
     } else {
         $listUpdated->published = $status;
     }
     if ($listUpdated->published == 0 and ($listUpdated->list_type == 2 or $listUpdated->list_type == 3)) {
         $published = 0;
     } else {
         $published = $listUpdated->published;
     }
     if (!empty($listUpdated->hidden)) {
         $visible = $listUpdated->hidden;
     } else {
         $visible = 0;
     }
     if ($new) {
         $published = $listUpdated->published;
     }
     if (!lists::updateList($listId, $listUpdated, $listUpdated->published, $new)) {
         return false;
     }
     if ($listUpdated->list_type != 11) {
         return xmailing::updateMailingFromList($listId, $published, $listUpdated->html, $visible);
     } else {
         return true;
     }
 }