public function Process() { // Newsletter component disabled or not found. Aborting. if (!$this->enabled) { return true; } $config = new jNews_Config(); // Build subscriber object $subscriber = new stdClass(); // Lists $cumulative = $this->JInput->post->get("jnews_subscribe_cumulative", NULL, "int"); $checkboxes = $this->JInput->post->get("jnews_subscribe", array(), "array"); $subscriber->list_id = $cumulative ? $checkboxes : array(); // No lists selected. Skip here to avoid annoying the user with email confirmation. It is useless to confirm a subscription to no lists. if (empty($subscriber->list_id)) { return true; } // Name field may be absent. JNews will assign an empty name to the user. $subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : ""; $subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']); // JNews saves users with empty email address, so we have to check it if (empty($subscriber->email)) { $this->logger->Write(get_class($this) . " Process(): Email address empty. User save aborted."); return true; } // It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration $subscriber->confirmed = !(bool) $config->get('require_confirmation'); $subscriber->receive_html = 1; // Avoid Notice: Undefined property while JNews libraries access undefined properties $subscriber->ip = jNews_Subscribers::getIP(); $subscriber->subscribe_date = jnews::getNow(); $subscriber->language_iso = "eng"; $subscriber->timezone = "00:00:00"; $subscriber->blacklist = 0; $subscriber->user_id = JFactory::getUser()->id; // Subscription $sub_id = null; jNews_Subscribers::saveSubscriber($subscriber, $sub_id, true); if (empty($sub_id)) { // User save failed. Probably email address is empty or invalid $this->logger->Write(get_class($this) . " Process(): User save failed"); return true; } // Subscribe $subscriber to $subscriber->list_id //$subscriber->id = $sub_id; // jNews_ListsSubs::saveToListSubscribers() doesn't work well. When only one list is passed to, it reads the value $listids[0], // but the element 0 is not always the first element of the array. In our case is $listids[1] //jNews_ListsSubs::saveToListSubscribers($subscriber); $this->SaveSubscription($subscriber); // Log $this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $subscriber->list_id)); return true; }
public static function updateUserstojNews($force = false) { $db = JFactory::getDBO(); $time = isset($GLOBALS[JNEWS . 'last_sub_update']) && $GLOBALS[JNEWS . 'last_sub_update'] > 0 ? $GLOBALS[JNEWS . 'last_sub_update'] : 10000; $newTask = mktime(date("H") - 1, date("i"), date("s"), date("m"), date("d") - 1, date("Y")); if ($force || $newTask > $GLOBALS[JNEWS . 'last_sub_update']) { $xf = new jNews_Config(); $newtime = mktime(date("H", $time) - 1, date("i", $time), date("s", $time), date("m", $time), date("d", $time), date("Y", $time)); $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}', '{$row->name}', '{$row->email}' , 1 ) "; $db->setQuery($query); $db->query(); $xf->plus('totalsubcribers0', 1); $xf->plus('act_totalsubcribers0', 1); } } } }
$mySess->clear('flexi_countries', 'JNEWLSETTER'); $mySess->clear('flexi_industries', 'JNEWLSETTER'); $mySess->clear('modjnewsflexi_listid', 'JNEWLSETTER'); echo '<div id=mod_message><span style="color:green;">You have been successfully subscribed to smartflexi articles.</span></div>'; //echo jnews::printM('green','Successfully subscribed to smartflexi articles.'); // break; //echo jnews::printM('green','Successfully subscribed to smartflexi articles.'); // break; default: if (class_exists('jNews_Auto')) { $showPanel = false; switch ($action) { case 'cron': //we save here the time the cron has been launched $config['lasttime_cron_triggerred'] = time(); $jNewsConfig = new jNews_Config(); $jNewsConfig->saveConfig($config); if (!empty($GLOBALS[JNEWS . 'j_cron']) || $GLOBALS[JNEWS . 'j_cron'] != '0') { //No Cron $password = JRequest::getVar('password', '', '', 'string'); if (!empty($password)) { $decodepass = base64_decode($password); if ($decodepass == $GLOBALS[JNEWS . 'cron_pass']) { echo "<br/>jNews Cron launched"; $status = jNews_Auto::execute(false); if ($status) { echo "<br/>Successfully processed queue!"; } } else { return false; }
/** Function for transferring the acajoom license to jnews */ function acaTojnewsLicenseUpd() { // get acajoom license key $query = " SELECT `text` FROM `#__acajoom_xonfig` WHERE `akey` = 'license'"; $license = jNews_TableUpdate::_getTableQuery($query, $loadAction = 'loadResult'); if (!empty($license)) { // update license jNews_Config::insert('license', $license, 0, true); // validate if (class_exists('jNews_Auto')) { jNews_Auto::good(); } } else { // no need to update if there are no license to be updated return false; } return true; }
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; }
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 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); }
public static function copyList($listId) { $db = JFactory::getDBO(); $xf = new jNews_Config(); $list = jNews_Lists::getOneList($listId); $copyList = $list; $ii = 0; $time = time(); $listname = $copyList->list_name . '_' . $time; $copyList->published = 0; $copyList->list_name = $listname; $query = "INSERT INTO `#__jnews_lists` (`list_name`,`list_desc` , `sendername` , `senderemail`, `bounceadres`, `layout` ," . " `template` , `subscribemessage`, \t`unsubscribemessage`,`notifyadminmsg` ,\t`unsubscribesend` , `unsubscribenotifyadmin`, `subnotifysend`,`subnotifymsg`, `html` ," . " `hidden` , `list_type`, `auto_add` ,\t`user_choose` , `cat_id` , \t`delay_min` ," . " \t`delay_max`, \t`follow_up` , \t`owner` , `acc_level` ,\t`acc_id` ,\t`published`,\t`footer`,\t`notify_id`\t) " . "\n VALUES ( '" . addslashes($copyList->list_name) . "', '" . addslashes($copyList->list_desc) . "', " . "'" . $copyList->sendername . "', " . "'" . $copyList->senderemail . "', " . "'" . $copyList->bounceadres . "', " . "'" . addslashes($copyList->layout) . "', " . "'" . $copyList->template . "', " . "'" . addslashes($copyList->subscribemessage) . "', " . "'" . addslashes($copyList->unsubscribemessage) . "', " . "'" . addslashes($copyList->notifyadminmsg) . "', " . "'" . $copyList->unsubscribesend . "', " . "'" . addslashes($copyList->subnotifymsg) . "', " . "'" . $copyList->subnotifysend . "', " . "'" . $copyList->unsubscribenotifyadmin . "', " . "'" . $copyList->html . "', " . "'" . $copyList->hidden . "', " . "'" . $copyList->list_type . "', " . "'" . $copyList->auto_add . "', " . "'" . $copyList->user_choose . "', " . "'" . $copyList->cat_id . "', " . "'" . $copyList->delay_min . "', " . "'" . $copyList->delay_max . "', " . "'" . $copyList->follow_up . "', " . "'" . $copyList->owner . "', " . "'" . $copyList->acc_level . "', " . "'" . $copyList->acc_id . "', " . "'" . $copyList->published . "', " . "'" . $copyList->footer . "', " . "'" . $copyList->notify_id . "' )"; $db->setQuery($query); $db->query(); $listname = $listname . $ii; $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist1', 1); $xf->plus('act_totallist1', 1); return true; }
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; }
public static function insertMailingData($mailing) { $db = JFactory::getDBO(); if ($mailing->mailing_type == 7) { //modified for the fix on smartnewsletter $mailing->senddate = !empty($mailing->send_date) ? $mailing->send_date : 0; if (empty($mailing->notify_id)) { $mailing->notify_id = 0; } if (empty($mailing->delay_max)) { $mailing->delay_max = 1; } if (empty($mailing->smart_date)) { $mailing->smart_date = 0; } if (empty($mailing->cat_id)) { $mailing->cat_id = '0:0'; } if (empty($mailing->attachments)) { $mailing->attachments = ''; } if (empty($mailing->images)) { $mailing->images = ''; } } if (is_array($mailing->attachments)) { $mailing->attachments = trim(implode("\n", $mailing->attachments)); } if (empty($mailing->senddate)) { $mailing->senddate = 0; } if (empty($mailing->list_id)) { $mailing->list_id = 0; } $xf = new jNews_Config(); $query = "INSERT INTO `#__jnews_mailings` ( `list_id`,\n `mailing_type`,\n `template_id`,\n `send_date`,\n `subject`,\n `htmlcontent`,\n `textonly`,\n " . "\n `attachments`,\n `images`,\n `published`,\n `html`,\n `visible`,\n `fromname`,\n `fromemail`,\n `frombounce`,\n " . "\n `author_id`,\n `delay`,\n `follow_up`,\n `cat_id`,\n `delay_min`,\n `delay_max`,\n `notify_id`,\n `next_date`,\n `start_date`,\n `smart_date`,\n `issue_nb`,\n `acc_level`,\n `createdate`) " . "\n VALUES (" . "{$mailing->list_id}, " . "{$mailing->mailing_type}, " . "{$mailing->template_id}, " . "'{$mailing->senddate}', " . "'" . addslashes($mailing->subject) . "', " . "'" . addslashes($mailing->htmlcontent) . "', " . "'" . addslashes($mailing->textonly) . "', " . "'{$mailing->attachments}', " . "'{$mailing->images}', " . "{$mailing->published}, " . "{$mailing->html}, " . "{$mailing->visible}, " . "'{$mailing->fromname}', " . "'{$mailing->fromemail}', " . "'{$mailing->frombounce}', " . "'{$mailing->author_id}', " . "{$mailing->delay}, " . "{$mailing->follow_up}, " . "'{$mailing->cat_id}', " . "{$mailing->delay_min}, " . "{$mailing->delay_max}, " . "{$mailing->notify_id}, " . "{$mailing->next_date}, " . "{$mailing->start_date}, " . "'{$mailing->smart_date}', " . "'{$mailing->issue_nb}', " . "'{$mailing->acc_level}', " . "{$mailing->createdate} ) "; $db->setQuery($query); $db->query(); $xf->plus('totalmailing0', 1); $xf->plus('act_totalmailing0', 1); $xf->plus('totalmailing' . $mailing->mailing_type, 1); $xf->plus('act_totalmailing' . $mailing->mailing_type, 1); $mailingId = jNews_Mailing::getLastMailingId(); jNews_Mailing::insertStatsGlobal($mailingId); return $mailingId; }
function lists($action, $task, $listId, $listType) { $db = JFactory::getDBO(); $my = JFactory::getUser(); $css = '.icon-48-lists { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/lists.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'lists.png'; $listsearch = JRequest::getVar('listsearch', ''); $message = ''; $xf = new jNews_Config(); $showLists = true; $checkToggle = false; // defined toggle for publish and unpublish of mailings if (!empty($task) && $task == 'togle') { $checkToggle = true; $id = JRequest::getVar('listid'); $col = JRequest::getVar('col'); $listId = !empty($id) && !empty($col) ? $id : $listId; $task = !empty($listId) && !empty($col) ? $col : $task; } switch ($task) { case 'new': case 'add': $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $acl = JFactory::getACL(); $groups = $acl->get_group_children_tree(null, 'USERS', false); } else { //j16 $db = JFactory::getDBO(); $db->setQuery('SELECT a.*, a.title as text, a.id as value FROM #__usergroups AS a ORDER BY a.lft ASC'); $groups = $db->loadObjectList(); } $allGroupIds = array(); foreach ($groups as $oneGroup) { $allGroupIds[] = $oneGroup->value; } $newList = new stdClass(); $showLists = false; $newList->id = ''; $newList->html = 1; $newList->new_letter = 1; $newList->list_name = ''; $newList->list_desc = ''; $newList->template = ''; if (empty($subscriber)) { $newList->sendername = ''; $newList->senderemail = ''; $newList->bounceadres = ''; } else { $newList->sendername = ''; $newList->senderemail = ''; $newList->bounceadres = ''; } $newList->hidden = 1; $newList->auto_add = 0; $newList->list_type = $listType; $newList->delay_min = 1; $newList->delay_max = 7; $newList->user_choose = 0; $newList->cat_id = '0:0'; $newList->follow_up = ''; $newList->notify_id = 0; $newList->owner = $my->id; $newList->acc_level = '24,25,7,8'; $newList->acc_id = implode(',', $allGroupIds); $newList->published = 1; $newList->start_date = date('Y-m-d', time()); $newList->next_date = jnews::getNow(); $newList->subscribemessage = _JNEWS_DEFAULT_SUBSCRIBE_MESS; $newList->unsubscribemessage = _JNEWS_DEFAULT_UNSUBSCRIBE_MESS; $newList->notifyadminmsg = _JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION; $newList->subnotifymsg = _JNEWS_SUBSDEFAULT_NOTIFYMSG; $newList->subnotifysend = 1; $newList->unsubscribesend = 1; $newList->unsubscribenotifyadmin = 1; $newList->footer = 1; $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $show = jNews_ListType::showType($newList->list_type, 'editlist'); if ($listType == 1) { backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_LIST, $img, $message, $task, $action); } else { backHTML::_header(_JNEWS_NEW . ' ' . _JNEWS_AUTORESP . ' ' . _JNEWS_LIST, $img, $message, $task, $action); } backHTML::formStart('editlist', $newList->html, ''); jNews_ListsHTML::editList($newList, $forms, $show, $listType); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('listid', $newList->id); backHTML::formEnd($go); break; case 'doNew': JRequest::checkToken() or die('Invalid Token'); $listname = JRequest::getVar('list_name', ''); if (empty($listname)) { echo "<script> alert(' List name must be filled out. '); window.history.go(-1);</script>\n"; return false; } $now = jnews::getNow(); $query = "SELECT `id` FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' "; $db->setQuery($query); $lId = $db->loadResult(); if ($lId > 0) { echo "<script> alert(' This list already exist, please choose another name. '); window.history.go(-1);</script>\n"; return false; } else { $query = "INSERT INTO `#__jnews_lists` (`list_name`,`createdate`) VALUES ( '" . addslashes($listname) . "' , '{$now}' )"; $db->setQuery($query); $db->query(); } $query = "SELECT * FROM `#__jnews_lists` WHERE `list_name`= '" . addslashes($listname) . "' "; $db->setQuery($query); $mynewlist = $db->loadObject(); $mynewlist->list_name = stripslashes($mynewlist->list_name); $mynewlist->list_desc = stripslashes($mynewlist->list_desc); $mynewlist->template = $mynewlist->template; $mynewlist->layout = stripslashes($mynewlist->layout); $mynewlist->subscribemessage = stripslashes($mynewlist->subscribemessage); $mynewlist->unsubscribemessage = stripslashes($mynewlist->unsubscribemessage); $mynewlist->notifyadminmsg = stripslashes($mynewlist->notifyadminmsg); $mynewlist->subnotifysend = stripslashes($mynewlist->subnotifysend); $mynewlist->subnotifymsg = stripslashes($mynewlist->subnotifymsg); $listId = $mynewlist->id; $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', true, $listType), _JNEWS_LIST_ADDED, _JNEWS_ERROR); $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist' . $listType, 1); $xf->plus('act_totallist' . $listType, 1); break; case 'edit': if ($listId == 0) { echo "<script> alert('" . addslashes(_JNEWS_SELECT_LIST) . "'); window.history.go(-1);</script>\n"; return false; } else { $showLists = false; $query = 'SELECT * FROM `#__jnews_lists` WHERE `id` = ' . intval($listId); $db->setQuery($query); $listEdit = $db->loadObject(); if ($listEdit->acc_id == 'all') { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $acl = JFactory::getACL(); $groups = $acl->get_group_children_tree(null, 'USERS', false); } else { //j16 $db = JFactory::getDBO(); $db->setQuery('SELECT a.*, a.title as text, a.id as value FROM #__usergroups AS a ORDER BY a.lft ASC'); $groups = $db->loadObjectList(); } $allGroupIds = array(); foreach ($groups as $oneGroup) { $allGroupIds[] = $oneGroup->value; } $listEdit->acc_id = implode(',', $allGroupIds); } $listEdit->list_name = stripslashes($listEdit->list_name); $listEdit->list_desc = stripslashes($listEdit->list_desc); $listEdit->template = $listEdit->template; $listEdit->layout = stripslashes($listEdit->layout); $listEdit->subscribemessage = stripslashes($listEdit->subscribemessage); $listEdit->unsubscribemessage = stripslashes($listEdit->unsubscribemessage); $listEdit->notifyadminmsg = stripslashes($listEdit->notifyadminmsg); $listEdit->subnotifysend = stripslashes($listEdit->subnotifysend); $listEdit->subnotifymsg = stripslashes($listEdit->subnotifymsg); $listEdit->new_letter = 0; $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $show = jNews_ListType::showType($listEdit->list_type, 'editlist'); backHTML::_header(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $listEdit->list_type]) . ' ' . _JNEWS_LIST, $img, $message, $task, $action); backHTML::formStart('listedit', $listEdit->html, ''); jNews_ListsHTML::editList($listEdit, $forms, $show, $listType); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('listid', $listEdit->id); backHTML::formEnd($go); } break; case 'update': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Lists::updateListFromEdit($listId, '', false, $listType), _JNEWS_LIST_UPDATED, _JNEWS_ERROR); break; case 'delete': JRequest::checkToken() or die('Invalid Token'); $query = "SELECT list_name FROM #__jnews_lists WHERE id = {$listId}"; $db->setQuery($query); $listName = $db->loadResult(); $message = jnews::printYN(jNews_Lists::deleteList($listId), '"' . $listName . '"' . _JNEWS_LIST . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Lists::copyList($listId), _JNEWS_LIST_COPY, _JNEWS_ERROR); break; case 'publish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Lists::updateListFromList($listId, true, false), _JNEWS_PUBLISHED, _JNEWS_ERROR); if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType); } break; case 'unpublish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Lists::updateListFromList($listId, false, false), _JNEWS_UNPUBLISHED, _JNEWS_ERROR); if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=' . $listType . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=' . $listType . '&listid=' . $listId); } break; case 'forms': case 'make': if (class_exists('jNews_CreateForm')) { jNews_CreateForm::taskOptions($task); $showLists = false; } else { $showLists = true; } break; case 'cpanel': backHTML::controlPanel(); return true; break; case 'toggle': $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); if (!empty($listid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_lists'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $listid; jnews::toggle($passObj); } if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=list&listype=1'); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=arlist&listype=2'); } break; } if ($showLists) { $limit = -1; //Title header if ($listType == 1) { backHTML::_header(_JNEWS_MENU_LIST, $img, $message, $task, $action); } else { backHTML::_header(_JNEWS_ARLIST, $img, $message, $task, $action); } $show = jNews_ListType::showType(0, 'showListsBack'); $forms['main'] = "<form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; backHTML::formStart('show_mailing', '', ''); $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_Lists::getListCount($listType); $limittotal = $limittotal[0]; $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; // recheck start if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } $setSort = new stdClass(); if ($listType == '2') { //autoresponder $key = JNEWS_OPTION . '.arlist'; $column = 'id'; $direction = 'desc'; } else { //newsletter $key = JNEWS_OPTION . '.list'; $column = 'list_name'; $direction = 'asc'; } $setSort->orderValue = $app->getUserStateFromRequest($key . 'filter_order', 'filter_order', $column, 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest($key . 'filter_order_Dir', 'filter_order_Dir', $direction, 'word'); if ($listType == 2) { ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'delete') { var $ok = confirm('Are you sure you want to delete?\r\nAll of the mailings attached in this auto-responder will be deleted as well.'); if ( $ok == true ){ form.action = 'index.php?option=<?php echo JNEWS_OPTION; ?> &act=arlist&task=delete'; }else{ return; } } submitform( pressbutton ); } </script> <?php } $listing = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setLimit, $setSort); if (isset($setLimit->total) && !empty($listsearch)) { $lists = jNews_Lists::getLists(0, $listType, 1, '', false, false, false, false, false, $listsearch, $setSort); $setLimit->total = !empty($lists) ? count($lists) : $setLimit->total; } $totalSubs = array(); $totalUnSubs = array(); $db = JFactory::getDBO(); if (!empty($listing)) { foreach ($listing as $list) { $totalSubs[] = jNews_Subscribers::getSubscribersCount($list->id, true); $totalUnSubs[] = jNews_Subscribers::getSubscribersCount($list->id, 2); } } jNews_ListsHTML::showListingLists($listing, $action, 'edit', $forms, $show, $listsearch, $setLimit->end, $setLimit, $totalSubs, $setSort, $totalUnSubs); $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; } }
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; }