/** * <p>Tags Controller</p> * <p>This function is the controller to view the tags view</p> * @author Joobi Limited <wwww.joobi.co> */ function fwdtofriend($action, $task) { $doc = JFactory::getDocument(); $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css'); $mailing = new stdClass(); if ($GLOBALS[JNEWS . 'level'] > 2) { $mailing->delay_max = JRequest::getInt('delay_max', 0, 'request'); $mailing->notify_id = JRequest::getInt('notify_id', 0, 'request'); $mailing->cat_id = JRequest::getVar('cat_id', 0, 'request'); } jNews_TagsHTML::menuTags($mailing); switch ($task) { case 'datetime': jNews_TagsHTML::datetimeTags(); break; case 'subscription': jNews_TagsHTML::subscriptionTags(); break; case 'subscriber': jNews_TagsHTML::subscriberTags(); break; case 'mod': //joomla module if ($GLOBALS[JNEWS . 'level'] > 1) { $linkFriendd = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkFriendd . " method='post' name='adminForm' id=\"adminForm\">"; jNews_TagsHTML::modTags($forms); } else { echo 'This functionality in only available for Plus and PRO version.'; } break; case 'content': //joomla content jNews_TagsHTML::contentTags(); break; case 'smart': //smart news if ($GLOBALS[JNEWS . 'level'] > 2) { jNews_Autonews::selectCat($mailing); } else { echo 'This functionality in only available for PRO version.'; } break; case 'smartk2': //smart news if ($GLOBALS[JNEWS . 'level'] > 2) { jNews_Autonews::selectCatK2($mailing); } else { echo 'This functionality in only available for PRO version.'; } break; case 'site': $linkFriendd = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkFriendd . " method='post' name='adminForm' id=\"adminForm\">"; jNews_TagsHTML::siteTags($forms); break; default: $linkFriendd = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkFriendd . " method='post' name='adminForm' id=\"adminForm\">"; jNews_TagsHTML::subscriptionTags($forms); } return true; }
/** * <p>public static function to create the header or the subject area of the smart newsletter</p> */ public static function smartNewsHead($mailingEdit, $lists, $show) { $option = array(); $my = JFactory::getUser(); $acl = JFactory::getACL(); //$gtree = $acl->get_group_children_tree( null, 'USERS', false ); $option[] = jnews::HTML_SelectOption('1800', 'Every 30 minutes'); $option[] = jnews::HTML_SelectOption('3600', 'Every hour'); $option[] = jnews::HTML_SelectOption('43200', 'Every 12 hours'); $option[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_DAY_CH1); $option[] = jnews::HTML_SelectOption('3', _JNEWS_AUTO_DAY_CH3); $option[] = jnews::HTML_SelectOption('5', _JNEWS_AUTO_DAY_CH5); $option[] = jnews::HTML_SelectOption('6', _JNEWS_AUTO_DAY_CH6); $option[] = jnews::HTML_SelectOption('7', _JNEWS_AUTO_DAY_CH7); $option[] = jnews::HTML_SelectOption('8', _JNEWS_AUTO_DAY_CH8); $option[] = jnews::HTML_SelectOption('9', _JNEWS_AUTO_DAY_CH9); $auto_option[] = jnews::HTML_SelectOption('0', _JNEWS_AUTO_OPTION_NONE); $auto_option[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_OPTION_NEW); if (isset($mailingEdit->new_letter) && $mailingEdit->new_letter == 1) { $auto_option[] = jnews::HTML_SelectOption('2', _JNEWS_AUTO_OPTION_ALL); } if (!isset($lists['delay_min'])) { $lists['delay_min'] = null; } $lists['delay_min'] = jnews::HTML_GenericList($option, 'delay_min', 'class="inputbox" size="1"', 'value', 'text', isset($mailingEdit->delay_min) ? $mailingEdit->delay_min : 1); $lists['catid'] = !empty($mailingEdit->cat_id) ? $mailingEdit->cat_id : ''; $lists['notify_id'] = !empty($mailingEdit->notify_id) ? $mailingEdit->notify_id : ''; $lists['delay_max'] = !empty($mailingEdit->delay_max) ? $mailingEdit->delay_max : ''; $lists['smart_date'] = !empty($mailingEdit->smart_date) ? $mailingEdit->smart_date : ''; if (!empty($mailingEdit->delay_max)) { JRequest::setVar('delay_max', $mailingEdit->delay_max); } if (!empty($mailingEdit->notify_id)) { JRequest::setVar('notify_id', $mailingEdit->notify_id); } if (!empty($mailingEdit->cat_id)) { JRequest::setVar('cat_id', base64_encode($mailingEdit->cat_id)); } // if(!empty($mailingEdit->template_id))JRequest::setVar('template_id', base64_encode($mailingEdit->template_id)); jNews_Autonews::edit($mailingEdit, $lists, $show); }
public static function getMailingView($mailingId, $listId = 0) { $archivemailing = new stdClass(); if ($mailingId != 0) { if ($listId > 0) { $list = jNews_Lists::getOneList($listId); $archivemailing = jNews_Mailing::getOneMailing($list, $mailingId, 0, $new); } else { $archivemailing = jNews_Mailing::getOneMailing(0, $mailingId, 0, $new); } $mailingtype = JRequest::getInt('listype'); if ($mailingtype == '7') { $db = JFactory::getDBO(); $query = 'SELECT `delay` FROM `#__jnews_queue` WHERE `type` = 7 AND `mailing_id` = ' . $archivemailing->id; $db->setQuery($query); $snDelay = $db->loadResult(); if (!empty($snDelay)) { $myTime = jnews::getNow(); $computedDate = jNews_Autonews::computeSmartDate($archivemailing->delay_min, $snDelay, $myTime); //We use the start date to previous the first one $computedDate->lastDate = $archivemailing->start_date; $newMailing = jNews_Autonews::loadSmartContent($archivemailing, $computedDate->lastDate, $snDelay); $archivemailing = !empty($newMailing) ? $newMailing : $archivemailing; } } if ($new) { return ''; } else { $mainframe = JFactory::getApplication(); JPluginHelper::importPlugin('jnews'); $bot_results = $mainframe->triggerEvent('jnewsbot_transformall', array(&$archivemailing->htmlcontent, &$archivemailing->textonly, &$archivemailing->subject)); $myReceiver = JFactory::getUser(); $db = JFactory::getDBO(); $query = "SELECT A.`id`, A.`receive_html` "; //we retreive the extra columns info of the user if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro if ($GLOBALS[JNEWS . 'show_column1']) { $query .= ', A.`column1`'; } if ($GLOBALS[JNEWS . 'show_column2']) { $query .= ',A.`column2`'; } if ($GLOBALS[JNEWS . 'show_column3']) { $query .= ',A.`column3`'; } if ($GLOBALS[JNEWS . 'show_column4']) { $query .= ',A.`column4`'; } if ($GLOBALS[JNEWS . 'show_column5']) { $query .= ',A.`column5`'; } } $query .= " FROM `#__jnews_subscribers` AS A WHERE A.`user_id`=" . $myReceiver->id; $db->setQuery($query); $myReceiverColumns = $db->loadObject(); if ($GLOBALS[JNEWS . 'level'] > 2) { //check if the version of jnews is pro if ($GLOBALS[JNEWS . 'show_column1']) { $myReceiver->column1 = $myReceiverColumns->column1; } if ($GLOBALS[JNEWS . 'show_column2']) { $myReceiver->column2 = $myReceiverColumns->column2; } if ($GLOBALS[JNEWS . 'show_column3']) { $myReceiver->column3 = $myReceiverColumns->column3; } if ($GLOBALS[JNEWS . 'show_column4']) { $myReceiver->column4 = $myReceiverColumns->column4; } if ($GLOBALS[JNEWS . 'show_column5']) { $myReceiver->column5 = $myReceiverColumns->column5; } } $myReceiver->receive_html = !empty($myReceiverColumns->id) ? $myReceiverColumns->receive_html : 1; $oneQueue = new stdClass(); $oneQueue->id = $mailingId; $archivemailing->subject = jNews_ProcessMail::replaceTags($archivemailing->subject, $myReceiver, $oneQueue, false, null, false); $archivemailing->htmlcontent = jNews_ProcessMail::replaceTags($archivemailing->htmlcontent, $myReceiver, $oneQueue, true); preg_match_all('/<img([^>]*)src="([^">]+)"([^>]*)>/i', $archivemailing->htmlcontent, $images, PREG_SET_ORDER); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $imgfolders = '/images/stories'; } else { //j16 $imgfolders = '/images/sampledata'; } foreach ($images as $image) { $image[2] = preg_replace('/(\\.\\.\\/)+/', '/', $image[2]); $image[2] = str_replace(array(JNEWS_JPATH_LIVE, JNEWS_JPATH_LIVE_NO_HTTPS), '', $image[2]); $image[2] = preg_replace('/^\\//', '', $image[2]); if (stristr($image[2], 'http://') === false) { // remove unneeded directory information if (stristr($image[2], $imgfolders) !== false) { $image[2] = '/' . stristr($image[2], $imgfolders); } // end if $replacement = '<img ' . $image[1] . 'src="' . JNEWS_JPATH_LIVE_NO_HTTPS . $image[2] . '"' . $image[3] . '>'; } else { $replacement = '<img ' . $image[1] . 'src="' . $image[2] . '"' . $image[3] . '>'; } // end if } } } return $archivemailing; }
/** * <p>Tags Controller</p> * <p>This function is the controller to view the fwdtofrien view</p> * @author Joobi Limited <wwww.joobi.co> */ function tags($action, $task, $templateid = '') { $doc = JFactory::getDocument(); $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css'); $mailing = new stdClass(); $new = JRequest::getInt('new', 0, 'request'); if ($GLOBALS[JNEWS . 'level'] > 2 && !$new) { $mailing->delay_max = JRequest::getInt('delay_max', 0, 'request'); $mailing->notify_id = JRequest::getInt('notify_id', 0, 'request'); $mailing->cat_id = JRequest::getVar('cat_id', 0, 'request'); } jNews_TagsHTML::menuTags($mailing, $new); switch ($task) { case 'datetime': jNews_TagsHTML::datetimeTags(); break; case 'virtuemartproduct': $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); //second parameter was false $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::virtuemartproduct($forms); break; case 'subscription': jNews_TagsHTML::subscriptionTags(); break; case 'lyften': //for lyften blog $forms['main'] = " <form action='" . jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true) . "' method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::lyftenblog(); break; case 'deals': //for deals $forms['main'] = " <form action='" . jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true) . "' method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::deals(); break; case 'subscriber': jNews_TagsHTML::subscriberTags(); break; case 'mod': ## joomla module if ($GLOBALS[JNEWS . 'level'] > 1) { $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); //second parameter was false $forms['main'] = " <form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::modTags($forms); } else { echo 'This functionality in only available for Plus and PRO version.'; } break; case 'content': ## joomla content $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); //second parameter was false $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::contentTags($forms); break; case 'k2content': ## k2 content jNews_TagsHTML::k2contentTags(); break; case 'smart': ## smart news if ($GLOBALS[JNEWS . 'level'] > 2) { jNews_Autonews::selectCat($mailing); } else { echo 'This functionality in only available for PRO version.'; } break; case 'smartk2': ## smart news if ($GLOBALS[JNEWS . 'level'] > 2) { jNews_Autonews::selectCatK2($mailing); } else { echo 'This functionality in only available for PRO version.'; } break; case 'site': $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::siteTags($forms); break; case 'jomsocial': $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::jomsocialTags($forms); break; case 'share': $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::shareTags($forms); break; case 'flexicontent': if ($GLOBALS[JNEWS . 'level'] > 2) { $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::flexicontent($mailing); } else { echo 'This functionality in only available for PRO version.'; } break; default: $linkTagg = jNews_Tools::completeLink('option=' . JNEWS_OPTION, false, false, true); $forms['main'] = "<form action=" . $linkTagg . " method='post' name=\"adminForm\" id=\"adminForm\">"; jNews_TagsHTML::subscriptionTags($forms); } 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; }