Beispiel #1
0
 /**
  * This public static function is used by jnews_cb plugin
  */
 public static function updateCBSubscribers($force = false, $install = false)
 {
     $db = JFactory::getDBO();
     $time = isset($GLOBALS[JNEWS . 'last_sub_update']) && $GLOBALS[JNEWS . 'last_sub_update'] > 0 ? $GLOBALS[JNEWS . 'last_sub_update'] : 200000;
     $newTask = mktime(date("H") - 1, date("i"), date("s"), date("m"), date("d"), date("Y"));
     if ($force or $newTask > $GLOBALS[JNEWS . 'last_sub_update']) {
         $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();
         $xf = new jNews_Config();
         $newtime = mktime(date("H", $time), date("i", $time), date("s", $time), date("m", $time), date("d", $time) - 2, date("Y", $time));
         if ($install) {
             $newtime = 0;
         }
         $oneDay = date('Y-m-d H:i:s', $newtime);
         $query = 'SELECT M.* FROM `#__users` AS M ' . ' LEFT JOIN `#__jnews_subscribers` AS N ON M.email = N.email ';
         $query .= ' WHERE M.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND  N.id IS NULL AND M.block=0 ';
         $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);
                 $lists = jNews_Lists::getLists(0, 0, null, '', true, false, false);
                 if (!empty($lists)) {
                     foreach ($lists as $list) {
                         $qid[0] = jNews_Subscribers::getSubscriberId($row->registerDate);
                         $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
                         $subId = array();
                         //if ( isset($subscriber->id) ) {
                         //$subId[0] =  $subscriber->id;
                         // jNews_Queue::insertQueuesForNews($subId, $list->id, 29 );
                         ////$subscriberInfo=jNews_ListsSubs::getListidsSubscribedInfo($subscriber->id);
                         //jNews_Queue::updateQueues($subId, '', $list->id, @$list->acc_id, true);
                         // }
                     }
                 }
             }
         }
         $query = 'SELECT M.* FROM `#__jnews_subscribers` AS M ' . ' LEFT JOIN `#__users` AS N ON N.id = M.user_id ';
         $query .= ' WHERE N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND  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_ListsSubs::removeSubscription($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 ';
         $query .= ' WHERE  N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND 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` ='" . addslashes($row->name) . "' " . ", `email` = '" . addslashes($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 N.registerDate > \'' . $oneDay . '\'';
         $query .= ' AND M.subscribe_date > \'' . $oneDay . '\'';
         $query .= ' AND 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);
             }
         }
         $xf->update('last_sub_update', time());
         return true;
     }
 }
Beispiel #2
0
function installPlugin()
{
    $database = JFactory::getDBO();
    $return = '<b>' . _JNEWS_INSTALL_PLUGIN . '</b> : ';
    $error = '';
    $files = array('jnews_cb.php', 'jnews_cb.xml', 'index.html');
    if (!is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) {
        @mkdir(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
        @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
    }
    foreach ($files as $file) {
        if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) {
            @unlink(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file);
        } else {
            if (!@rename(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file, JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) {
                $error .= '<br /> Error copying plugin file ' . $file . ' to CB plugin directory.';
            }
        }
        //endelseif
    }
    if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) {
        @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
    }
    if (!@rmdir(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/')) {
        $error .= '<br /> Error deleting the temporary cbplugin directory.';
    }
    $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' ";
    $database->setQuery($query);
    $database->query();
    $id = $database->loadResult();
    $mysqlerror = $database->getErrorMsg();
    if (!empty($mysqlerror)) {
        $error .= '<br />Error getting plugin information from cb plugin table. Database error: <br />' . $mysqlerror . '';
    } else {
        if ($id < 1) {
            $row->name = 'jNews CB Plugin';
            $row->element = 'jnews_cb';
            $row->type = 'user';
            $row->folder = 'plug_jnewscbplugin';
            $row->ordering = '99';
            $query = "INSERT INTO `#__comprofiler_plugin` (`name` , `element`, `type`, `ordering`, `folder`) VALUES ( " . "'{$row->name}', " . "'{$row->element}', " . "'{$row->type}', " . "'{$row->ordering}', " . " '{$row->folder}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB plug table.';
            }
            $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' ";
            $database->setQuery($query);
            $database->query();
            $id = $database->loadResult();
            $error .= $database->getErrorMsg();
            $row = '';
            $row->title = 'Mailing Lists';
            $row->description = 'Listing of all the mailing lists for jNews';
            $row->ordering = '99';
            $row->width = '.5';
            $row->enabled = '0';
            $row->pluginclass = 'getjNewsTab';
            $row->pluginid = $id;
            $row->sys = '0';
            $row->params = 'NULL';
            $row->displaytype = 'tab';
            $row->position = 'cb_tabmain';
            $query = "INSERT INTO `#__comprofiler_tabs` (`title` , `description`, `ordering`, `width`, `enabled`, " . " `pluginclass` , `pluginid`, `sys`, `displaytype`, `params` , `position` ) VALUES ( " . "'{$row->title}', " . "'{$row->description}', " . "'{$row->ordering}', " . "'{$row->width}', " . "'{$row->enabled}', " . "'{$row->pluginclass}', " . "'{$row->pluginid}', " . "'{$row->sys}', " . "'{$row->displaytype}', " . "'{$row->params}', " . "'{$row->position}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB tab table.';
            }
        }
    }
    //endelse
    if (empty($error)) {
        $xf = new jNews_Config();
        $xf->update('cb_pluginInstalled', '1');
        //$return .= jnews::M('green' , _JNEWS_INSTALL_SUCCESS,false) .'<br />';
        jnews::displayInfo(_JNEWS_INSTALL_SUCCESS, 'success');
    } else {
        //$return .= $error.jnews::M('red' , _JNEWS_INSTALL_ERROR,false) .'<br />';
        jnews::displayInfo($error, 'error');
    }
    //return $return;
}
Beispiel #3
0
 function updateActiveList()
 {
     $xf = new jNews_Config();
     $j = 0;
     $nb = array();
     for ($i = 1; $i < $GLOBALS[JNEWS . 'nblist']; $i++) {
         if ($GLOBALS[JNEWS . 'listype' . $i] == 1) {
             $j++;
             $nb[$j] = $i;
         }
     }
     $activeList = implode(",", $nb);
     return $xf->update('activelist', $activeList);
 }
Beispiel #4
0
 public static function checkCBPlugin()
 {
     $xf = new jNews_Config();
     if (!file_exists(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php') and !file_exists(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscb' . DS . 'jnews_cb.php')) {
         $xf->update('cb_pluginInstalled', '0');
         return false;
     }
     $xf->update('cb_pluginInstalled', '1');
     $xf->update('cb_integration', '1');
     return true;
 }
Beispiel #5
0
function configuration($action, $task)
{
    $db = JFactory::getDBO();
    $config = array();
    $redirect = true;
    $xf = new jNews_Config();
    $message = JRequest::getVar('message', '');
    $clear_log = JRequest::getVar('clear_log', '0');
    switch ($task) {
        case 'syncUsers':
            echo jnews::printYN(jNews_Subscribers::syncSubscribers(), _JNEWS_SYNC_USERS_SUCCESS, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
        case 'sendtest':
            $my = JFactory::getUser();
            $mailing = new stdClass();
            $status = false;
            $mailing->id = 1;
            $mailing->images = '';
            $mailing->attachments = '';
            $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']);
            $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']);
            if (empty($mailing->fromemail)) {
                $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']);
            }
            ### create the mail
            $mail = jNews_ProcessMail::getMailer($mailing);
            ### create content
            $mail->IsHTML(true);
            $mail->Body = '<p>This message has been sent at ' . date('l, j F Y h:i:s', jnews::getNow(0, true)) . ' from ' . JNEWS_JPATH_LIVE . ' to test your mail configuration.</p><br/><p style="color:green;">' . _JNEWS_SENDTEST_CONFIGSUCC . '</p>';
            $mail->AddAddress($my->email, $my->name);
            $mail->Subject = 'Test Email from ' . JNEWS_JPATH_LIVE;
            $status = $mail->Send();
            $success = 'Email "' . $mail->Subject . '" successfully sent to ' . $my->name . ' (' . $my->email . ')';
            $error = 'Failed sending "' . $mail->Subject . '" to ' . $my->name . ' (' . $my->email . '). <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
            $message = is_bool($status) && $status ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            echo $message;
            break;
        case 'apply':
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            if ($clear_log != 0) {
                @unlink(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file']);
            }
            $config = JRequest::getVar('config');
            $message = jnews::printYN($xf->saveConfig($config), _JNEWS_CONFIG_UPDATED, _JNEWS_ERROR);
            $listCreator = JRequest::getVar('list_creatorfe', '', 'post');
            if (!empty($listCreator)) {
                $xf->update('list_creatorfe', $listCreator);
            }
            //we update the active list
            $xf->updateActiveList();
            if ($GLOBALS[JNEWS . 'level'] > 1) {
                //we require the cron controller
                require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'cron.jnews.php';
                //we update the published/enabld of the jnews cron plugin according to what is selected
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    $db->setQuery("UPDATE `#__plugins` SET `published` = " . $config['jnewscronplugin'] . " WHERE `element`='jnewscron' ");
                } else {
                    //j16
                    $db->setQuery("UPDATE `#__extensions` SET `enabled` = " . $config['jnewscronplugin'] . " WHERE `type` = 'plugin' AND `element`='jnewscron' ");
                }
                $db->query();
                //Joobi Cron System
                $cron = $GLOBALS[JNEWS . 'j_cron'];
                if ($cron == 2) {
                    joobiCron('Yes');
                } else {
                    joobiCron('No');
                }
            }
            if ($task == 'apply') {
                backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
                jNews_ConfigHTML::showConfigEdit();
                echo $message;
            } else {
                backHTML::controlPanel();
            }
            break;
        case 'cancel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'acaupdate':
            // update jnews datas from acajoom
            $msg = jNews_TableUpdate::executeUpdate();
            echo $msg . '<br><br>';
        default:
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
    }
    return true;
}
Beispiel #6
0
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;
}