public static function syncSubscribers($onlyAdd = false) { $db = JFactory::getDBO(); $xf = new jNews_Config(); $query = 'UPDATE IGNORE `#__jnews_subscribers` as S LEFT JOIN `#__users` AS U ON U.`id` = S.`user_id` SET S.`name` = U.`name`, S.`email` = U.`email`, S.`confirmed` = 1 - U.`block` WHERE U.`id` > 0 AND S.`user_id` > 0'; $db->setQuery($query); $db->query(); $query = 'SELECT M.* FROM `#__users` AS M ' . ' LEFT JOIN `#__jnews_subscribers` AS N ON M.email = N.email ' . ' WHERE N.id IS NULL AND M.block=0 AND M.registerDate<>\'0000-00-00 00:00:00\' '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = "INSERT INTO `#__jnews_subscribers` (`user_id`,`subscribe_date`, `name`,`email`,`confirmed`)"; $query .= " VALUES ( {$row->id} , '{$row->registerDate}', '" . addslashes($row->name) . "', '" . addslashes($row->email) . "' , 1 ) "; $db->setQuery($query); $db->query(); $xf->plus('totalsubcribers0', 1); $xf->plus('act_totalsubcribers0', 1); } } if ($onlyAdd) { return true; } $query = 'SELECT M.* FROM `#__jnews_subscribers` AS M ' . ' LEFT JOIN `#__users` AS N ON N.id = M.user_id ' . ' WHERE N.id IS NULL AND M.user_id>0 '; // ORDER BY N.id $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = 'DELETE FROM `#__jnews_subscribers` WHERE `id` = ' . $row->id; $db->setQuery($query); $db->query(); $xf->plus('act_totalsubcribers0', -1); jNews_Queue::deleteSubsQueue($row->id, ''); } } $query = 'SELECT N.id, N.name , N.email , N.block FROM `#__users` AS N ' . ' LEFT JOIN `#__jnews_subscribers` AS M ON N.id = M.user_id ' . ' WHERE M.name != N.name OR M.email != N.email OR N.block = M.confirmed'; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { if ($row->block == 1) { $status = 0; } else { $status = 1; } $query = "UPDATE IGNORE `#__jnews_subscribers` SET `name` ='" . $row->name . "' " . ", `email` = '" . $row->email . "' " . ", `confirmed` ='" . $status . "' WHERE `user_id` = " . $row->id; $db->setQuery($query); $db->query(); } } $query = 'SELECT N.id , N.email FROM `#__users` AS N '; $query .= 'LEFT JOIN `#__jnews_subscribers` AS M ON N.email = M.email '; $query .= ' WHERE M.user_id = 0 AND N.block = 0 '; $db->setQuery($query); $rows = $db->loadObjectList(); if (!empty($rows)) { foreach ($rows as $row) { $query = "UPDATE `#__jnews_subscribers` AS S SET `user_id` = " . $row->id; $query .= " WHERE S.email = '{$row->email}'"; $db->setQuery($query); $db->query(); } } return true; }
public static function confirmRegistration($d) { if (!empty($d['subscriberId']) and !empty($d['cle'])) { $qid[0] = $d['subscriberId']; $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false); if (md5($subscriber->email) == $d['cle']) { $subscriber->confirmed = 1; $subscriber->name = addslashes($subscriber->name); jNews_Subscribers::saveSubscriber($subscriber, $subscriber->id, false); //&$subscriberId } if (!(require_once JNEWSPATH_CLASS . 'class.queue.php')) { return false; } jNews_Queue::updateSuspendedQueue($subscriber->id); } return true; }
/** * This public static function is used for the view of sendReady for manual sending */ public static function sendReady($mailingId, $listId, $listType) { ?> <div id="manualsend"></div> <?php JHTML::_('behavior.modal'); $formLink3 = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=send', true, false, true); ?> <form class="modal" action="<?php echo $formLink3; ?> " method="post" name="adminForm" autocomplete="off" id="adminForm"> <div> <fieldset class="adminform"> <legend> <?php echo 'Sending Status'; ?> </legend> <?php $doc = JFactory::getDocument(); $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css'); if (empty($mailingId) || $mailingId == 0) { $warning = 'Please select a newsletter to be sent.'; jnews::displayInfo($warning, 'warning'); return; } $queueCount = jNews_Queue::getQueueCount($mailingId); $new = false; $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); if (empty($queueCount)) { if (empty($listId)) { $listIds = jNews_Mailing::getMailingList($mailingId); } if (!empty($listIds)) { ?> <br/> <fieldset class="adminform"> <legend> <?php echo $mailing->subject . ' will be sent to '; ?> </legend> <br/> <table class="adminlist" cellspacing="1" align="center"> <tbody> <?php $listNames = jNews_Mailing::getMailingListName($listIds); foreach ($listNames as $key => $listName) { if (isset($listIds[$key])) { ?> <tr><td><?php echo $listName . ' ( ' . jNews_Subscribers::getSubscribersCount($listIds[$key], true, true, true) . ' subscribers ) '; ?> </td></tr> <?php } } ?> </tbody> </table> <br/> </fieldset> <?php } else { $warning = $mailing->subject . ' will be sent to none of the created Lists.'; jnews::displayInfo($warning, 'warning'); } } else { $info = 'There are ' . $queueCount . ' in the queue for the Newsletter ' . $mailing->subject . ' <br/>Do you want to continue sending this newsletter?'; jnews::displayInfo($info, 'info'); ?> <input type="hidden" name="totalsend" value="<?php echo $queueCount; ?> " /> <?php } ?> <br/> <input type="submit" value="<?php echo empty($queueCount) ? _JNEWS_MENU_SEND : _JNEWS_MENU_CONTINUE; ?> "> <input type="hidden" name="mailingid" value="<?php echo $mailingId; ?> " /> <input type="hidden" name="option" value="<?php echo JNEWS_OPTION; ?> " /> <input type="hidden" name="task" value="<?php echo empty($queueCount) ? 'send' : 'continuesend'; ?> " /> <input type="hidden" name="act" value="mailing" /> <?php if (version_compare(JVERSION, '3.0.0', '<')) { echo JHTML::_('form.token'); } else { echo JHtml::_('form.token'); } ?> </div> </form> <?php }
public static function upgrade_News3() { $my = JFactory::getUser(); $db = JFactory::getDBO(); $xf = new jNews_Config(); $newLists = array(); $idImportedList = array(); $i = 0; $db->setQuery("SELECT * FROM #__yanc_letters"); $newsletters = $db->loadObjectList(); $error = $db->getErrorMsg(); $newSubscriber = null; $list = null; $mailings = null; $subscriberId = 0; $total = 0; if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($newsletters as $newsletter) { $list->list_name = $newsletter->list_name; $list->list_desc = $newsletter->list_desc; $list->sendername = $newsletter->sendername; $list->senderemail = $newsletter->senderemail; $list->bounceadres = $newsletter->bounceadres; $list->layout = $newsletter->layout; $list->template = 0; $list->subscribemessage = $newsletter->subscribemessage; $list->unsubscribemessage = $newsletter->unsubscribemessage; $list->notifyadminmsg = $newsletter->notifyadminmsg; $list->html = $newsletter->html; $list->hidden = !$newsletter->hidden; $list->unsubscribesend = 1; $list->unsubscribenotifyadmin = 1; $list->list_type = '1'; $list->auto_add = 0; $list->user_choose = 0; $list->cat_id = '0:0'; $list->delay_min = 0; $list->delay_max = 0; $list->follow_up = 0; $list->owner = $my->id; $list->acc_level = $newsletter->aid; $list->acc_id = 29; $list->published = 1; $list->createdate = time(); $list->footer = 1; $list->notify_id = 0; $list->notification = 0; $query = 'INSERT INTO `#__jnews_lists` (`list_name`) VALUES (\'' . $list->list_name . '\' )'; $db->setQuery($query); $db->query(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use? The list name has to be different for each list! <br /><br />'; } else { $query = 'SELECT * FROM `#__jnews_lists` WHERE `list_name`= \'' . $list->list_name . '\''; $db->setQuery($query); $mynewlist = $db->loadObject(); $error = $db->getErrorMsg(); $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist1', 1); $xf->plus('act_totallist1', 1); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>'; return false; } else { $idImportedList[$newsletter->id] = $mynewlist->list_id; $newLists[$i] = $mynewlist->list_id; $i++; $list->id = $mynewlist->list_id; $error = jNews_Lists::updateListData($list); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . @constant($GLOBALS[JNEWS . 'listnames1']) . ': </b>' . $list->list_name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); $db->setQuery("SELECT * FROM #__yanc_letters WHERE `list_id`=" . $newsletter->id); $mailingsImports = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>'; return false; } else { $issue_nb = 1; foreach ($mailingsImports as $mailingsImport) { $mailings->list_id = $mynewlist->list_id; $mailings->list_type = '1'; $mailings->send_date = $mailingsImport->send_date; $mailings->subject = $mailingsImport->subject; $mailings->htmlcontent = $mailingsImport->htmlcontent; $mailings->textonly = $mailingsImport->textonly; $mailings->attachments = $mailingsImport->attachments; $mailings->images = $mailingsImport->images; $mailings->published = $mailingsImport->published; $mailings->visible = $mailingsImport->visible; $mailings->html = $mynewlist->html; $mailings->fromname = $list->sendername; $mailings->fromemail = $list->senderemail; $mailings->frombounce = $list->bounceadres; $mailings->author_id = $my->id; $mailings->delay = 0; $mailings->issue_nb = $issue_nb; $mailings->acc_level = 25; $mailings->createdate = $list->createdate; $issue_nb++; $error = jNews_Mailing::insertMailingData($mailings); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . _JNEWS_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); } } } } } } } $db->setQuery("SELECT * FROM #__yanc_subscribers"); $subscribers = $db->loadObjectList(); $error = $db->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($subscribers as $subscriber) { $newSubs = true; $jnewssubscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', '', ''); //added one parameter for mailid foreach ($jnewssubscribers as $jnewssubscriber) { if ($subscriber->subscriber_email == $jnewssubscriber->email) { $newSubs = false; $subId[0] = $jnewssubscriber->id; } } if ($newSubs) { $newSubscriber->user_id = $subscriber->userid; $newSubscriber->name = $subscriber->subscriber_name; $newSubscriber->email = $subscriber->subscriber_email; $newSubscriber->ip = $subscriber->ip; $newSubscriber->receive_html = $subscriber->receive_html; $newSubscriber->confirmed = $subscriber->confirmed; $newSubscriber->subscribe_date = $subscriber->subscribe_date; $newSubscriber->blacklist = 0; $newSubscriber->timezone = '00:00:00'; $newSubscriber->language_iso = 'eng'; $newSubscriber->params = ''; if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro $newSubscriber->column1 = $newSubscriber->column1; $newSubscriber->column2 = $newSubscriber->column2; $newSubscriber->column3 = $newSubscriber->column3; $newSubscriber->column4 = $newSubscriber->column4; $newSubscriber->column5 = $newSubscriber->column5; } //end if for check version pro $error = jNews_Subscribers::saveSubscriber($newSubscriber, $subscriberId, true); if (!empty($error)) { if ($subscriberId < 1) { echo ' Error inserting subscriber:' . $newSubscriber->name; } $error = ''; $subId[0] = $subscriberId; } else { echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS); $d['email'] = $subscriber->email; jNews_Subscribers::getSubscriberIdFromEmail($d); $subId[0] = $d['subscriberId']; } } else { echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . jnews::printM('red', _JNEWS_IMPORT_EXIST); } $j = 0; $queue = jNews_ListsSubs::getListSubscriberInfo($subId[0], $idImportedList[$subscriber->list_id]); if (empty($queue)) { $error = jNews_Queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>'; } } } } } return true; }
function mailing($action, $task, $listId, $listType, $mailingId, $message) { $showMailings = false; $db = JFactory::getDBO(); switch ($task) { case 'edit': $issue_nb = JRequest::getInt('issue_nb', 1); $mailingType = JRequest::getVar('listype'); $isEdit = JRequest::getVar('isEdit', true); $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); if (!empty($listId)) { $list = jNews_Lists::getOneList($listId); } else { $list = jNews_Lists::getListFirstEntry(); } $new = empty($mailingId) || $mailingId == 0 ? true : false; $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new, false, true); $mailing->mailing_type = $mailingType; // if(empty($isEdit)) $isEdit = true; // set default mailing parameters $my = JFactory::getUser(); $subscribers = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); if (!isset($subscribers)) { $subscribers = new stdClass(); } $subscribers->name = isset($subscribers->name) ? $subscribers->name : ''; $subscribers->email = isset($subscribers->email) ? $subscribers->email : ''; // $mailing->fromname = ( !isset( $mailing->fromname ) || empty( $mailing->fromname ) ) ? $subscribers->name : $mailing->fromname; // $mailing->fromemail = ( !isset( $mailing->fromemail ) || empty( $mailing->fromemail ) ) ? $subscribers->email : $mailing->fromemail; // $mailing->frombounce = ( !isset( $mailing->frombounce ) || empty( $mailing->frombounce ) ) ? $GLOBALS[JNEWS.'sendmail_from'] : $mailing->frombounce; $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing'); if ($mailing->published != 1 or $mailing->mailing_type != 1 or isset($show['admin']) and $show['admin']) { $forms['main'] = " <form action='index.php' method='post' enctype='multipart/form-data' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message, 'edit'); jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $isEdit); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); } else { $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message); //backHTML::formStart(); jNews_MailingsHTML::viewMailing($mailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('mailingid', $mailing->id); backHTML::formEnd($go); } break; case 'new': case 'add': // check if atleast one list exist and published // if false then restrict entry $mailingType = JRequest::getVar('listype'); $type = $mailingType == 2 ? 2 : 1; $result = jNews_Lists::checkListNotEmpty($type); if (!$result) { if ($type == 2) { $disp = addslashes(_JNEWS_CHECKCAMPAIGNFOUND); } else { $disp = addslashes(_JNEWS_CHECKLISTFOUND); } echo "<script> alert('" . $disp . "'); window.history.go(-1);</script>\n"; break; } $mailingType = JRequest::getVar('listype'); if (empty($listId)) { $listId = JRequest::getVar('listid'); } if (!empty($listId)) { $mailingType = jNews_Lists::getListType($listId) == 2 ? 2 : 1; } JRequest::setVar('listype', $mailingType); $total = jNews_Mailing::countMailings($listId, $mailingType); $total++; jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listype=' . $mailingType . '&listid=' . $listId . '&isEdit=0'); //mariap break; case 'saveSend': JRequest::checkToken() or die('Invalid Token'); $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); $status = checkMailingSave($mailingType); if (!$status) { return false; } jNews_Mailing::saveMailing($mailingId, $listId); case 'sendready': //we update the senddate of the newsletter jNews_Mailing::updatesenddate($mailingId); jNews_MailingsHTML::sendReady($mailingId, $listId, $listType); break; case 'generate': if (class_exists('jNews_Auto')) { $still = false; $message = jnews::printYN(jNews_Auto::processQueue(true, true, $still, true), 'Queue processed', _JNEWS_ERROR); jNews_Auto::displayStatus(); } return; break; case 'send': $queueC = new jNews_Queue(); $queueC->checkForNewsletters($mailingId); $queueCount = jNews_Queue::getQueueCount($mailingId); $totalSub = JRequest::setVar('totalsend', $queueCount); $linkURL = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true); jNews_Tools::redirect($linkURL); break; case 'continuesend': $queueC = new jNews_Queue(); //we update the senddate of the mailing to be now to be able to continue the sending and send it after we click continue // $queueC->updateSenddateToNow($mailingId); $totalSend = JRequest::getVar('totalsend', 0, '', 'int'); $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int'); $queueC->start = $alreadySent; $queueC->total = $totalSend; $queueC->pause = $GLOBALS[JNEWS . 'pause_time']; $queueC->sendQueue(false, $mailingId, false, true); ob_start(); exit; break; case 'testspam': if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; $my = JFactory::getUser(); if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $mailing = new stdClass(); $receivers = new stdClass(); $receivers->email = '*****@*****.**'; $receivers->name = $archivemailing->fromname; $receivers->receive_html = 1; $receivers->id = jNews_Subscribers::getSubscriberIdFromUserId($my->id); //if email are different we dont replace because we want to make sure the spam cehck count the fact that //sender and bounce back are different if ($archivemailing->fromemail == $archivemailing->frombounce) { $archivemailing->frombounce = $my->email; } $archivemailing->fromemail = $my->email; $mailerC = new jNews_ProcessMail(); $status = $mailerC->send($archivemailing, $receivers); $message = jnews::printYN($status, _JNEWS_SPAMTEXT_MESSAGE_SENT_SUCCESSFULLY, $message); $link = 'http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=SpamCheck&alt=jnewsdoc_glossary'; $iFrame = '<iframe src="' . $link . '" width="100%" height="680px" scrolling="auto"></iframe>'; echo $iFrame; break; case 'savePreview': JRequest::checkToken() or die('Invalid Token'); $status = checkMailingSave($mailingType); if (!$status) { return false; } if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } jNews_Mailing::saveMailing($mailingId, $listId); case 'preview': $emailaddress = JRequest::getVar('emailaddress', ''); $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; if (!empty($emailaddress)) { $status = jNews_Mailing::sendTestEmail($mailingId, $listId); if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $message = jnews::printYN($status, _JNEWS_MESSAGE_SENT_SUCCESSFULLY, $message); } if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $doc = JFactory::getDocument(); $css = '.icon-48-preview{ background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/preview.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); $title = _JNEWS_PREVIEW_TITLE . ': ' . $archivemailing->subject; backHTML::_header(_JNEWS_PREVIEW_TITLE, 'preview.png', $message, $task, $action); //new view for the preview mailing echo '<table cellpadding="0" cellspacing="2" border="0" width="100%"><tr><td width="40%">'; jNews_MailingsHTML::previewMailingHTML($mailingId, $listId, $listType, $archivemailing->html); echo '</td><td width="60%">'; $forms['main'] = ''; $list = jNews_Lists::getOneList($archivemailing->list_id); $textonly = ''; $mailerC = new jNews_ProcessMail(); $queueInfo = new stdClass(); $queueInfo->mailingid = $mailingId; $queueInfo->listid = @$listId; $mailerC->getContent($archivemailing->images, $archivemailing->html, $archivemailing->textonly, $archivemailing->subject, false, true, $queueInfo); //new $archivemailing->subject if ($archivemailing->html == 1) { if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } } else { $archivemailing->textonly = jNews_ProcessMail::htmlToText($archivemailing->textonly); } //new view for the preview mailing jNews_MailingsHTML::viewHeading($archivemailing); echo '</td></tr><tr><td colspan="2">'; jNews_MailingsHTML::viewMailing($archivemailing, $forms); echo '</td></tr></tbody></table>'; if ($mailingId == 0) { JRequest::setVar('mailingid', $mailingId); } break; case 'view': $mailingType = JRequest::getVar('listype'); if (!empty($mailingType)) { $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); } if ($mailingId != 0) { if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } $forms['main'] = "<form action='index.php?option=" . JNEWS_OPTION . "&act=mailing&listype=" . $listType . "&listid=" . $listId . "' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $listType, $message); backHTML::formStart('show_mailing', 0, ''); jNews_MailingsHTML::viewMailing($archivemailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('listId', $archivemailing->list_id); //listid to listId--original backHTML::formEnd($go); } break; case 'deletequeue': //implement here what are we going to do with the delete queueu column on the mailing $mailingID = JRequest::getVar('mailingid'); $mailingType = JRequest::getVar('listype'); if (!empty($mailingID)) { $db = JFactory::getDBO(); $db->setQuery('DELETE FROM `#__jnews_queue` WHERE `mailing_id` = ' . $mailingID); $db->query(); $message = jnews::printYN(true, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } else { $message = jnews::printYN(false, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType, $message); break; case 'deleteMailing': JRequest::checkToken() or die('Invalid Token'); $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . '"' . $d['mailing']->subject . '"' . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); $showMailings = true; break; case 'cancel': $url = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&mailingid=' . $mailingId; $url .= (!empty($listId) ? '&listid=' . $listId : '') . '&listype=' . $mailingType; jNews_Tools::redirect($url); break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR); $showMailings = true; break; case 'cancelMailing': $showMailings = true; break; case 'publishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::publishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_PUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType); break; case 'unpublishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::unpublishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_UNPUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); break; case 'cpanel': backHTML::controlPanel(); break; case 'save': JRequest::checkToken() or die('Invalid Token'); $subject = JRequest::getVar('subject', ''); if (empty($subject)) { echo "<script> alert('subject needs to be not empty'); window.history.go(-1);</script>\n"; return false; } if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'apply': JRequest::checkToken() or die('Invalid Token'); $mailingid = JRequest::getVar('mailingid', '0'); if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); $mailingid = $mailingid == 0 ? jNews_Mailing::getLastMailingId() : $mailingid; if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'show': $id = JRequest::getVar('mailingid'); $mySess = JFactory::getSession(); $mailingType = JRequest::getVar('listype', 0); $listId = JRequest::getVar('listid', 0); $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId; jNews_Tools::redirect($link); $showMailings = true; break; case 'toggle': $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); $mailingid = JRequest::getVar('mailingid'); if (!empty($mailingid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_mailings'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $mailingid; jnews::toggle($passObj); } if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=1'); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=2'); } break; default: $showMailings = true; break; } if ($showMailings) { if (empty($listType)) { $listType = JRequest::getVar('listype', 0); } if (empty($listId)) { $listId = JRequest::getVar('listid', 0); } $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Mailing::countMailings(0, $listType); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } jNews_Mailing::showMailings($task, $action, $listId, $listType, $message, true, _JNEWS_MENU_MAILING, $setLimit); } return true; }
public static function updateList($listId, $listUpdated, $status, $new) { $total = 0; @set_time_limit(0); //If memory_limit less than 128M $limit = jnews::convertToBytes(@ini_get('memory_limit')); if ($limit < jnews::convertToBytes('128M')) { @ini_set('memory_limit', '128M'); } if ($listUpdated->list_type != '7' and $listUpdated->delay_min > $listUpdated->delay_max) { $listUpdated->delay_min = $listUpdated->delay_max; } if (!jNews_Lists::updateListData($listUpdated)) { return false; } else { if ($listUpdated->auto_add == 2) { $subscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', 1, 1, '', ''); //added one parameter for mailid $subId = jnews::convertObjectToIdList($subscribers, 'id'); if (!empty($subId)) { jNews_Queue::insertQueuesForNews($subId, $listId, $listUpdated->acc_id); } } elseif ($status == '' and $listUpdated->list_type == 2) { $queues = jNews_Queue::getAllOneList($listId); $qid = jnews::convertObjectToIdList($queues, 'qid'); if (!jNews_Queue::updatePublished($qid, $status)) { return false; } } else { if (class_exists('jNews_Auto')) { jNews_Auto::updateListNb($listUpdated->list_type, $listUpdated->id); } } } if ($listUpdated->published == 0) { jnews::printM('blue', _JNEWS_LIST_UNPUBMSG); } if ($listUpdated->hidden == 0) { jnews::printM('blue', _JNEWS_LIST_INVIMSG); } return true; }
/** public static function that will save mailing * @param int $mailingId - mailing id * @param int $listId - list id */ public static function saveMailing(&$mailingId, $listId) { $total = 0; $list = jNews_Lists::getOneList($listId); // $allow_html = jNews_Tools::allow_html(); $xf = new jNews_Config(); $db = JFactory::getDBO(); // check list type $mailingtype = JRequest::getVar('listype', 0); if (empty($mailingtype)) { $mySess = JFactory::getSession(); $listType = $mySess->set('listype', '', 'LType'); } else { $listType = $mailingtype; } $senddate = JRequest::getVar('senddate', 0); $task = JRequest::getVar('task', ''); if ($task == 'saveSend') { $senddate = time(); } $subject = JRequest::getVar('subject', '', 'request', 'string'); // $content = JRequest::getVar('content', '', 'request','string', JREQUEST_ALLOWRAW); $content = JRequest::getVar('jnewsContent', '', 'request', 'string', JREQUEST_ALLOWRAW); $alt_content = JRequest::getVar('altbody', '', JREQUEST_ALLOWRAW); $published = JRequest::getVar('published', 0); $visible = JRequest::getVar('visible', 1); $html = JRequest::getVar('html_mailings', 1); $new_list = JRequest::getVar('new_list', 0); $fromname = JRequest::getVar('fromname', ''); $fromemail = JRequest::getVar('fromemail', ''); $frombounce = JRequest::getVar('frombounce', ''); $userid = JRequest::getVar('userid', 0); $delay = JRequest::getVar('delay', 0); $acc_level = JRequest::getVar('acc_level', $list->acc_id); $issue_nb = JRequest::getVar('issue_nb', 1); if ($mailingtype == 7) { $issue_nb = 1; } $attachments = JRequest::getVar('attachments', ''); $follow_up = JRequest::getVar('follow_up', 0); $cat_id = JRequest::getVar('cat_id', ''); $delay_max = JRequest::getVar('delay_max', 7); $delay_min = JRequest::getVar('delay_min', 0); $notify_id = JRequest::getVar('notify_id', 0); $next_date = JRequest::getVar('next_date', 0); $start_date = JRequest::getVar('start_date', 0); $smart_date = JRequest::getVar('smart_date', 0); $listIdA = JRequest::getVar('aca_mailing_addto', array()); //clean up $cat_id if (!empty($cat_id)) { $cat_idA = explode(',', $cat_id); if (count($cat_idA) > 1) { //remove the all category $newcat_idA = array(); foreach ($cat_idA as $oneCat_id) { if ($oneCat_id != '0:0') { $newcat_idA[] = $oneCat_id; } } $cat_id = trim(implode(',', $newcat_idA), ','); } } $createdate = time(); //get the default template $template = jNews_Templates::loadOneTemplate('*', '', 'template_id', 'DESC', true); $template_id = JRequest::getVar('template_id', $template->template_id); // change start_date type from string to int if (!empty($senddate) and $task != 'saveSend') { $senddate = strtotime($senddate); $senddate = $senddate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); if ($senddate <= time()) { $senddate = 0; } } elseif (!empty($senddate) && $task == 'saveSend') { //not used any more $senddate = $senddate; } else { $senddate = 0; } if (!empty($start_date)) { $start_date = strtotime($start_date); $start_date = $start_date - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); } if (!empty($next_date)) { $next_date = strtotime($next_date); $next_date = $next_date - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); } if (!empty($create_date)) { $create_date = strtotime($create_date); $create_date = $create_date - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z'); } $delay = $delay * 24 * 60; $attach = ''; if (!empty($attachments)) { foreach ($attachments as $attachment) { $attach .= $attachment . "\n"; } } if (!empty($_FILES['file_0']['name'])) { $otherAttachs = jNews_Mailing::uploadFiles(); if (!empty($otherAttachs)) { foreach ($otherAttachs as $otherAttach) { $attach .= '/' . $otherAttach . "\n"; } } } $images = JRequest::getVar('images', ''); if (empty($alt_content)) { $alt_content = jNews_ProcessMail::htmlToText($content); } else { $alt_content = "<pre>" . $alt_content . "</pre>"; } if ($listType == 2) { // auto-repsonders $senddate = time() + $delay * 60; } else { if ($senddate > time()) { $published = 2; } } if ($GLOBALS[JNEWS . 'show_subscriptionlink']) { if (substr_count($content, '{tag:subscriptions}') < 1) { $content .= "<br/> {tag:subscriptions} <br/>"; } if (strlen($alt_content) > 10 and substr_count($alt_content, '{tag:subscriptions}') < 1) { $alt_content .= "\r\n {tag:subscriptions} \r\n"; } } if ($GLOBALS[JNEWS . 'show_unsubscribelink']) { if (substr_count($content, '{tag:unsubscribe}') < 1) { $content .= "<br/> {tag:unsubscribe} <br/>"; } if (strlen($alt_content) > 10 and substr_count($alt_content, '{tag:unsubscribe}') < 1) { $alt_content .= "\r\n {tag:unsubscribe}\r\n"; } } // save to cross table if (!empty($listIdA) && !empty($listIdA)) { $myLIst2Add = array(); foreach ($listIdA as $listid => $values) { if ($values == 1) { $myLIst2Add[$listid] = true; } } } else { // we dont have any list selected return false; } //in saving in case there are still old tag format we will replace with new //we replce the oldtags to new tags $mailing = new stdClass(); $mailing->htmlcontent = jNews_Mailing::replaceOldTagsToNew($content); $mailing->textonly = jNews_Mailing::replaceOldTagsToNew($alt_content); if ($new_list != 0) { //NEW MAILING //information to be inserted $mailing->list_id = $listId; $mailing->mailing_type = $mailingtype; $mailing->senddate = $senddate; $mailing->subject = $subject; $mailing->htmlcontent = $content; $mailing->textonly = $alt_content; $mailing->attachments = $attach; $mailing->images = $images; $mailing->published = $published; $mailing->visible = $visible; $mailing->fromname = $fromname; $mailing->fromemail = $fromemail; $mailing->frombounce = $frombounce; $mailing->html = $html; $mailing->delay = $delay; $mailing->issue_nb = $issue_nb; $mailing->acc_level = $acc_level; $mailing->createdate = $createdate; $mailing->follow_up = $follow_up; if (empty($mailing->follow_up)) { $mailing->follow_up = 0; } $mailing->cat_id = $cat_id; $mailing->delay_max = $delay_max; $mailing->delay_min = $delay_min; $mailing->notify_id = $notify_id; $mailing->next_date = $next_date; $mailing->start_date = $start_date; $mailing->smart_date = $smart_date; $mailing->mailing_type = $mailingtype; $mailing->list_id = $listId; $mailing->author_id = $userid; $mailing->template_id = $template_id; //insert the mailing data $mailingId = jNews_Mailing::insertMailingData($mailing); $db->setQuery('SELECT LAST_INSERT_ID()'); $mailingId = $db->loadResult(); $xf->plus('totalmailing0', 1); $xf->plus('act_totalmailing0', 1); $xf->plus('totalmailing' . $listType, 1); $xf->plus('act_totalmailing' . $listType, 1); if ($listType == 7) { jNews_Queue::addSNinQueue($mailingId, $delay_min, $start_date, $mailing->next_date); } //modified for smartnewsletter added next_date jNews_Mailing::saveMailingList($mailingId, array_keys($myLIst2Add), $senddate, $listType, $published, (bool) $new_list); //if we have an auto-responder we need to make sure the new auto-responders get added to all current subscribed users if ($published && $mailingtype == 2) { //add the this auto-responders to all users //select all user subscribe to this autoresponder $query = "SELECT L.`subscriber_id`, L.`subdate`+" . $delay . ", " . $mailingId . ", 2, 1 FROM `#__jnews_listssubscribers` AS L "; $query .= " WHERE L.`list_id` =" . $listId; $query2 = "INSERT IGNORE `#__jnews_queue` ( `subscriber_id`, `send_date`, `mailing_id`, `type`, `priority` ) " . $query; $db->setQuery($query2); $db->query(); } } else { //update mailing $query = 'SELECT `send_date`,`published`,`delay` FROM `#__jnews_mailings` WHERE `id` =' . $mailingId; $db->setQuery($query); $mailingInfoO = $db->loadObject(); $queueSendDateUpdate = $mailingInfoO->send_date != $senddate ? true : false; $queuePublishUpdate = $mailingInfoO->published != $published ? true : false; $queueDelayUpdate = $mailingInfoO->delay != $delay ? $delay - $mailingInfoO->delay : 0; $query = "UPDATE `#__jnews_mailings` SET " . " `subject` = '" . addslashes($subject) . "', " . " `htmlcontent` = '" . addslashes($content) . "', " . " `textonly` = '" . addslashes($alt_content) . "', " . " `attachments` = '" . $attach . "', " . " `images` = '" . $images . "', " . " `published` = '" . $published . "', " . " `html` = " . $html . " , " . " `visible` = " . $visible . " , " . " `fromname` = '" . $fromname . "', " . " `fromemail` = '" . $fromemail . "', " . " `frombounce` = '" . $frombounce . "', " . " `author_id` = '" . $userid . "' , " . " `delay` = " . $delay . ", " . " `acc_level` = '" . $acc_level . "', " . " `send_date` = '" . $senddate . "', " . " `follow_up` = " . $follow_up . ", " . " `cat_id` = '" . $cat_id . "', " . " `delay_max` = " . (int) $delay_max . ", " . " `delay_min` = " . (int) $delay_min . ", " . " `notify_id` = " . (int) $notify_id . ", " . " `next_date` = " . (int) $next_date . ", " . " `template_id` = " . (int) $template_id . ", " . " `start_date` = " . (int) $start_date . ", " . " `smart_date` = " . (int) $smart_date . " " . " WHERE `id` =" . $mailingId; $db->setQuery($query); $db->query(); jNews_Mailing::saveMailingList($mailingId, array_keys($myLIst2Add), $senddate, $listType, $published, (bool) $new_list, $queueSendDateUpdate, $queuePublishUpdate, $queueDelayUpdate); if ($published && $mailingtype == 2) { $query_check = "SELECT `qid` FROM `#__jnews_queue` WHERE `type` = '8' AND `mailing_id` = '{$mailingId}'"; $db->setQuery($query_check); $additionInfo = $db->loadObjectList(); if (is_array($additionInfo) && !empty($additionInfo)) { $query_update = "UPDATE `#__jnews_queue` SET `type` = '2' WHERE mailing_id = {$mailingId}"; $db->setQuery($query_update); $db->query(); } } } return true; }
static function deleteSubsQueue($subscriber_id, $listId = 0) { $db = JFactory::getDBO(); if ($listId == 0) { $query = 'DELETE FROM `#__jnews_queue` WHERE `subscriber_id` = ' . $subscriber_id . ""; $db->setQuery($query); $db->query(); return true; } else { //get mailing id fron the list (listmailing table) $mailing_ids = jNews_Mailing::getListMailingToDelete($listId); //if not empty $mailing_ids if (!empty($mailing_ids)) { foreach ($mailing_ids as $mailing_id) { jNews_Queue::_deleteSubsQueuePriv($subscriber_id, $mailing_id, $listId); } } } }
public static function processTypeEightfromQueue() { $ARtoUnsubA = array(); $followupToSubscribeA = array(); //get entries in the queue where type =8 $typeEightinQueue = jNews_Queue::typeEight(); if (empty($typeEightinQueue)) { return false; } foreach ($typeEightinQueue as $oneTypeEight) { $subscriberId = $oneTypeEight->subscriber_id; $ARtoUnsubA[0] = $oneTypeEight->delay; //we use the delay column of the queue saving the AR id being subscribed of the subscriber $mailId = $oneTypeEight->mailing_id; //we get the followup of the listid saved in the delay column $followupid = jNews_Lists::getFollowup($ARtoUnsubA[0]); $followupToSubscribeA[0] = $followupid; //$subs=jNews_ListsSubs::getSubs($subscriberId); //we unsubscribe the user from the list using the data saved in the delay column in the queue jNews_ListsSubs::_applyChangedSubscription($subscriberId, '', $ARtoUnsubA); //we delete this type 8 entry in the queue $db = JFactory::getDBO(); $query = 'DELETE FROM `#__jnews_queue` WHERE `type`=8 AND `subscriber_id`=' . $subscriberId . ' AND `mailing_id`=' . $mailId; $db->setQuery($query); $db->query(); //we subscribe the user to the followup if ($followupToSubscribeA[0] != 0 && !empty($followupToSubscribeA[0])) { jNews_ListsSubs::_applyChangedSubscription($subscriberId, $followupToSubscribeA, ''); $followupType = jNews_Lists::getListType($followupid); if ($followupType == 2) { //we add entries in the queue if the type is equal 2 jNews_ListsSubs::subscribeARtoQueue($subscriberId, $followupToSubscribeA); } } //$subs=jNews_ListsSubs::getSubs($subscriberId); } return true; }
function queue($action, $task, $listid, $mailingid, $lists, $cid) { $db = JFactory::getDBO(); $my = JFactory::getUser(); $start = JRequest::getInt('start'); $css = '.icon-48-queue { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/queue.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'queue.png'; $message = ''; $xf = new jNews_Config(); $conf = JFactory::getConfig(); $mail = new stdClass(); $mail->Mailer = $conf->get('config.mailer'); $mailingsearch = JRequest::getVar('mailingsearch', ''); $start = JRequest::getInt('start'); $limit = JRequest::getInt('limit', $conf->get('config.list_limit')); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cpanel') { form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=cpanel'; }else if (pressbutton == 'pqueue') { var $ok = confirm('Are you sure you want to process queue?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=pqueue'; }else{ return; } }else if (pressbutton == 'stopqueue') { var $ok = confirm('Are you sure you want to stop the queue?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=stopqueue'; }else{ return; } }else if (pressbutton == 'startqueue') { var $ok = confirm('Are you sure you want to start the queue?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=startqueue'; }else{ return; } }else if (pressbutton == 'delq') { var $ok = confirm('Are you sure you want to delete?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=delq'; }else{ return; } }else if (pressbutton == 'cleanq') { var $ok = confirm('Are you sure you want to clear the queue?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=cleanq'; }else{ return; } }else if (pressbutton == 'block') { var $ok = confirm('Are you sure you want to block selected entries?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=block'; }else{ return; } }else if (pressbutton == 'unblock') { var $ok = confirm('Are you sure you want to unblock selected entries?'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=queue&task=unblock'; }else{ return; } } submitform( pressbutton ); } </script> <?php $message = JRequest::getVar('message', ''); $showqueue = true; switch ($task) { case 'pqueue': if (!$GLOBALS[JNEWS . 'queue_status']) { //we start the processing of queue $xf->update('queue_status', 1); $GLOBALS[JNEWS . 'queue_status'] = 1; } //create smart-newsletter if necessary if (class_exists('jNews_Autonews')) { $SmartNewsMessageHTML = jNews_Autonews::createSmartNewsletters(); } else { $SmartNewsMessageHTML = ''; } $queueC = new jNews_Queue(); $queuedMails = $queueC->queueStatus($mailingid); $nextQueuedMails = $queueC->queueStatus($mailingid); // , true if ($GLOBALS[JNEWS . 'level'] > 1) { $scheduledMails = $queueC->getScheduled(); } else { $scheduledMails = null; } jNews_QueueHTML::processQueueHTML($queuedMails, $nextQueuedMails, $scheduledMails, $mailingid, false, $SmartNewsMessageHTML); return; break; case 'stopqueue': //we need to implement here how we can stop the queue $xf->update('queue_status', 0); //we start the processing of queue $GLOBALS[JNEWS . 'queue_status'] = 0; //we turn off the queue_process to make sure we only have one process going on //$xf->update('queue_process', 0); //$GLOBALS[JNEWS.'queue_process']=0; JToolBarHelper::custom('startqueue', 'start-queue.png', 'start-queue.png', _JNEWS_MENU_STARTQ, false); JToolBarHelper::spacer(); $message = jnews::printYN(true, _JNEWS_MENU_STOPQ_MSG, $message); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=queue' . $message); break; case 'startqueue': //we need to implement here how we can start back the queue $xf->update('queue_status', 1); //we stop the processing of queue $GLOBALS[JNEWS . 'queue_status'] = 1; //we turn off the queue_process to make sure we only have one process going on //$xf->update('queue_process', 0); //$GLOBALS[JNEWS.'queue_process']=0; JToolBarHelper::custom('stopqueue', 'stop-queue.png', 'stop-queue.png', _JNEWS_MENU_STOPQ, false); JToolBarHelper::spacer(); $message = jnews::printYN(true, _JNEWS_MENU_STARTQ_MSG, $message); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=queue' . $message); break; case 'cpanel': jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); break; case 'delq': JRequest::checkToken() or die('Invalid Token'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; return false; } else { $status = true; if (!empty($cid)) { $db = JFactory::getDBO(); $query = 'DELETE from `#__jnews_queue` where `qid` IN (' . implode(',', $cid) . ')'; $db->setQuery($query); $db->query(); } $message = jnews::printYN(true, 'Successfully deleted the mailing(s) in the queue.', _JNEWS_ERROR); } break; case 'block': JRequest::checkToken() or die('Invalid Token'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to block'); window.history.go(-1);</script>\n"; return false; } else { $status = true; if (!empty($cid)) { $message = jnews::printYN(jNews_Queue::updateQueueBlock($cid, 1), 'Successfully blocked the mailing(s) in the queue.', _JNEWS_ERROR); } } break; case 'unblock': JRequest::checkToken() or die('Invalid Token'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to unblock'); window.history.go(-1);</script>\n"; return false; } else { $status = true; if (!empty($cid)) { $message = jnews::printYN(jNews_Queue::updateQueueBlock($cid, 0), 'Successfully blocked the mailing(s) in the queue.', _JNEWS_ERROR); } } break; case 'cleanq': JRequest::checkToken() or die('Invalid Token'); $db = JFactory::getDBO(); $query = 'DELETE from `#__jnews_queue` WHERE `type` < 7'; //do not delete the smartnewsletter type 7 and type 8 $db->setQuery($query); $db->query(); $message = jnews::printYN(true, ' Successfully cleared the mailings in the queue! ', _JNEWS_ERROR); break; default: if ($GLOBALS[JNEWS . 'queue_status'] == 1) { JToolBarHelper::custom('stopqueue', 'stop-queue.png', 'stop-queue.png', _JNEWS_MENU_STOPQ, false); } else { JToolBarHelper::custom('startqueue', 'start-queue.png', 'start-queue.png', _JNEWS_MENU_STARTQ, false); } JToolBarHelper::spacer(); } if ($showqueue) { $paginationStart = JRequest::getVar('pg'); $app = JFactory::getApplication(); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Queue::getQueueCount($mailingid); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; $setSort = new stdClass(); $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.queue.filter_order', 'filter_order', 'q.send_date', 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.queue.filter_order_Dir', 'filter_order_Dir', 'asc', 'word'); //count only the search result if (!empty($mailingsearch)) { $mailingq = jNews_Queue::getMailingqueue($mailingsearch, $mailingid, 0, 0, $setSort); $setLimit->total = count($mailingq); } // recheck start if ($setLimit->total <= $setLimit->start) { $setLimit->start = 0; } //perform query for all or specific search $mailingq = jNews_Queue::getMailingqueue($mailingsearch, $mailingid, $setLimit->start, $setLimit->end, $setSort); $form['main'] = " <form name='adminForm' method='POST' action='index.php' id=\"adminForm\">"; $form['select'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n"; backHTML::_header('Mailing Queue', $img, $message, $task, $action); jNews_QueueHTML::showMailingQueue($mailingq, $lists, $form, $setLimit->start, $setLimit->end, $mailingsearch, $setLimit, $setSort); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); } return true; }