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; }
public static function showMailingQueue($mailingq = null, $lists = null, $form, $start, $limit, $mailingsearch, $setLimit = null, $setSort = null) { $listId = null; ?> <script language="javascript" type="text/javascript"> <!-- function jnewsselectall(){ var i = 0; allcheck = document.getElementById("selectallcheck"); if(allcheck.checked) checkedvalue = 1; else checkedvalue = 0; while(myelement = document.getElementById("cid["+i+"]")){ myelement.checked = checkedvalue; i++; } if(checkedvalue){ document.getElementById("boxcount").value = i; }else{ document.getElementById("boxcount").value = 0; } } //--> </script> <?php if (empty($mailingq)) { echo '<center>' . jnews::printYN(true, _JNEWS_Q_M1, _JNEWS_ERROR) . '</center>'; } if ($listId == 0) { $message = _JNEWS_MESSAGE_QUEUE; } else { $lt_name = jNews_Lists::getLists($listId, 0, null, '', false, false, true, false, false, ''); $message = _JNEWS_SUSCRIB_LIST_UNIQUE . "<span style='color: rgb(51, 51, 51);'>" . @$lt_name[0]->list_name . "</span>"; } if (!isset($action)) { $action = JRequest::getVar('act', '', '', 'WORD'); } $mySepList = array(); $mySepList[0] = new stdClass(); $mySepList[0]->subject = 'All Mailings'; $mySepList[0]->id = 0; $myMailingQueA = jNews_Mailing::getMailingsForQueue(); if (empty($myMailingQueA) || !is_array($myMailingQueA)) { $myMailingQueA = array(); } $lt = array_merge($mySepList, $myMailingQueA); $mailingId = JREquest::getVar('mailingid', ''); $dropDown = jnews::HTML_GenericList($lt, 'mailingid', '' . 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'subject', $mailingId); $filter = _JNEWS_FILTER_MAILING . $dropDown; $hidden = '<input type="hidden" name="option" value="' . JNEWS_OPTION . '" />'; $hidden .= '<input type="hidden" name="act" value="' . $action . '" />'; $hidden .= '<input type="hidden" name="limit" value="' . $limit . '" />'; ?> <?php echo $form['main']; if ($form['main'] !== "") { $form['select'] = ""; } // top portion before the table list // for search $toSearch = new stdClass(); $toSearch->forms = $form['select']; $toSearch->hidden = $hidden; $toSearch->listsearch = $mailingsearch; $toSearch->id = 'mailingsearch'; echo jnews::setTop($toSearch, $message, $setLimit, $filter); ?> <table class="<?php echo jnews::myTheme(); ?> "> <thead><tr> <th width="2%" class="title">#</th> <th width="2%" class="title"><input type="checkbox" id="selectallcheck" name="allchecked" onclick="jnewsselectall();"></th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_SUBJECT, 'm.subject', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_EMAIL, 's.email', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="22%" class="title"><?php echo jnews::HTML_GridSort(_JNEWS_SENDDATE, 'q.send_date', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_PRIOR, 'q.priority', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th width="2%" class="title"><center><?php echo jnews::HTML_GridSort(_JNEWS_QUEUE_ATT, 'q.attempt', $setSort->orderDir, $setSort->orderValue); ?> </center></th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('Suspend', 'q.suspend', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('Blocked', 'q.block', $setSort->orderDir, $setSort->orderValue); ?> </th> <th width="3%" class="title"><?php echo jnews::HTML_GridSort('ID', 'q.qid', $setSort->orderDir, $setSort->orderValue); ?> </th> </thead></tr> <?php $i = $start; jNews_QueueHTML::_displayQueue($mailingq, $i); ?> </table> <?php echo '<br />'; echo jnews::setLegend(); }