Ejemplo n.º 1
0
 function listing()
 {
     $app = JFactory::getApplication();
     global $Itemid;
     $config = acymailing_config();
     $jsite = JFactory::getApplication('site');
     $menus = $jsite->getMenu();
     $menu = $menus->getActive();
     if (empty($menu) and !empty($Itemid)) {
         $menus->setActive($Itemid);
         $menu = $menus->getItem($Itemid);
     }
     if (empty($menu)) {
         acymailing_enqueueMessage(JText::_('ACY_NOTALLOWED'));
         $app->redirect('index.php');
     }
     $selectedLists = 'all';
     if (is_object($menu)) {
         jimport('joomla.html.parameter');
         $menuparams = new acyParameter($menu->params);
         $this->assign('listsintrotext', $menuparams->get('listsintrotext'));
         $this->assign('listsfinaltext', $menuparams->get('listsfinaltext'));
         $selectedLists = $menuparams->get('lists', 'all');
         $document = JFactory::getDocument();
         if ($menuparams->get('menu-meta_description')) {
             $document->setDescription($menuparams->get('menu-meta_description'));
         }
         if ($menuparams->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $menuparams->get('menu-meta_keywords'));
         }
         if ($menuparams->get('robots')) {
             $document->setMetadata('robots', $menuparams->get('robots'));
         }
         if ($menuparams->get('page_title')) {
             acymailing_setPageTitle($menuparams->get('page_title'));
         }
     }
     if (empty($menuparams)) {
         $pathway = $app->getPathway();
         $pathway->addItem(JText::_('MAILING_LISTS'));
     }
     $document = JFactory::getDocument();
     $link = '&format=feed&limitstart=';
     if ($config->get('acyrss_format') == 'rss' || $config->get('acyrss_format') == 'both') {
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
     }
     if ($config->get('acyrss_format') == 'atom' || $config->get('acyrss_format') == 'both') {
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     $listsClass = acymailing_get('class.list');
     $allLists = $listsClass->getLists('', $selectedLists);
     if (acymailing_level(1)) {
         $allLists = $listsClass->onlyCurrentLanguage($allLists);
     }
     $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
     $this->assignRef('rows', $allLists);
     $this->assignRef('item', $myItem);
 }
Ejemplo n.º 2
0
 function view()
 {
     $mailid = acymailing_getCID('mailid');
     if (empty($mailid)) {
         $db =& JFactory::getDBO();
         $query = 'SELECT m.`mailid` FROM `#__acymailing_list` as l LEFT JOIN `#__acymailing_listmail` as lm ON l.listid=lm.listid LEFT JOIN `#__acymailing_mail` as m on lm.mailid = m.mailid';
         $query .= ' WHERE l.`visible` = 1 AND l.`published` = 1 AND m.`visible`= 1 AND m.`published` = 1';
         if (!empty($listid)) {
             $query .= ' AND l.`listid` = ' . (int) $listid;
         }
         $query .= ' ORDER BY m.`mailid` DESC LIMIT 1';
         $db->setQuery($query);
         $mailid = $db->loadResult();
         if (empty($mailid)) {
             return JError::raiseError(404, 'Newsletter not found');
         }
     }
     $access_sub = true;
     $mailClass = acymailing_get('helper.mailer');
     $mailClass->loadedToSend = false;
     $oneMail = $mailClass->load($mailid);
     if (empty($oneMail->mailid)) {
         return JError::raiseError(404, 'Newsletter not found : ' . $mailid);
     }
     if (!$access_sub or !$oneMail->published or !$oneMail->visible) {
         $key = JRequest::getString('key');
         if (empty($key) or $key !== $oneMail->key) {
             $app = JFactory::getApplication();
             $app->enqueueMessage('You can not have access to this e-mail', 'error');
             $app->redirect(acymailing_completeLink('lists', false, true));
             return false;
         }
     }
     $user = JFactory::getUser();
     if (!empty($user->email)) {
         $userClass = acymailing_get('class.subscriber');
         $receiver = $userClass->get($user->email);
     } else {
         $receiver = new stdClass();
         $receiver->name = JText::_('VISITOR');
     }
     $oneMail->sendHTML = true;
     $mailClass->dispatcher->trigger('acymailing_replaceusertags', array(&$oneMail, &$receiver, false));
     acymailing_setPageTitle($oneMail->subject);
     if (!empty($oneMail->text)) {
         echo nl2br($mailClass->textVersion($oneMail->text, false));
     } else {
         echo nl2br($mailClass->textVersion($oneMail->body, true));
     }
 }
Ejemplo n.º 3
0
	function view(){

		global $Itemid;

		$app = JFactory::getApplication();

		$document = JFactory::getDocument();

		$this->addFeed();



		$pathway = $app->getPathway();
		$my = JFactory::getUser();

		$frontEndManagement = false;
		$listid = acymailing_getCID('listid');

		$values = new stdClass();
		$values->suffix = '';
		$jsite = JFactory::getApplication('site');
		$menus = $jsite->getMenu();
		$menu	= $menus->getActive();

		if(empty($menu) AND !empty($Itemid)){
			$menus->setActive($Itemid);
			$menu	= $menus->getItem($Itemid);
		}

		if (is_object( $menu )) {
			jimport('joomla.html.parameter');
			$menuparams = new acyParameter( $menu->params );
		}

		if(!empty($menuparams)){
			$values->suffix = $menuparams->get('pageclass_sfx','');
		}

		if(empty($listid) && !empty($menuparams)){
			$listid = $menuparams->get('listid');
			if ($menuparams->get('menu-meta_description')) $document->setDescription($menuparams->get('menu-meta_description'));
			if ($menuparams->get('menu-meta_keywords')) $document->setMetadata('keywords',$menuparams->get('menu-meta_keywords'));
			if ($menuparams->get('robots')) $document->setMetadata('robots',$menuparams->get('robots'));
			if ($menuparams->get('page_title')) acymailing_setPageTitle($menuparams->get('page_title'));
		}

		$config = acymailing_config();
		$indexFollow = $config->get('indexFollow', '');
		$tagIndFol = array();
		if(strpos($indexFollow, 'noindex') !== false) $tagIndFol[] = 'noindex';
		if(strpos($indexFollow, 'nofollow') !== false) $tagIndFol[] = 'nofollow';
		if(!empty($tagIndFol)) $document->setMetadata('robots',implode(',',$tagIndFol));

		if(!empty($listid)){
			 $listClass = acymailing_get('class.list');
			 $oneList = $listClass->get($listid);
			 if(!empty($oneList->visible) AND $oneList->published AND (empty($menuparams) || !$menuparams->get('listid'))){
				 $pathway->addItem($oneList->name,acymailing_completeLink('archive&listid='.$oneList->listid.':'.$oneList->alias));
			 }

			 if(!empty($oneList->listid) AND acymailing_level(3)){
				if(!empty($my->id) AND (int)$my->id == (int)$oneList->userid){
					$frontEndManagement = true;
				}
				if(!empty($my->id)){
					if($oneList->access_manage == 'all' OR acymailing_isAllowed($oneList->access_manage)){
						 $frontEndManagement = true;
					}
				}
			}
		}

		$mailid = JRequest::getString('mailid','nomailid');
		if(empty($mailid)){
			die('This is a Newsletter-template... and you can not access the online version of a Newsletter-template!<br />Please <a href="administrator/index.php?option=com_acymailing&ctrl=newsletter&task=edit" >create a Newsletter</a> using your template and then try again your "view it online" link!');
			exit;
		}

		if($mailid == 'nomailid'){
			$db = JFactory::getDBO();
			$query = 'SELECT m.`mailid` FROM `#__acymailing_list` as l JOIN `#__acymailing_listmail` as lm ON l.listid=lm.listid JOIN `#__acymailing_mail` as m on lm.mailid = m.mailid';
			$query .= ' WHERE l.`visible` = 1 AND l.`published` = 1 AND m.`visible`= 1 AND m.`published` = 1 AND m.`type` = "news" AND l.`type` = "list"';
			if(!empty($listid)) $query .= ' AND l.`listid` = '.(int) $listid;
			$query .= ' ORDER BY m.`senddate` DESC, m.`mailid` DESC LIMIT 1';
			$db->setQuery($query);
			$mailid = $db->loadResult();
		}
		$mailid = intval($mailid);
		if(empty($mailid)) return JError::raiseError( 404, 'Newsletter not found');

		$access_sub = true;
		 if(acymailing_level(3)){
			$listmail = acymailing_get('class.listmail');
			$allLists = $listmail->getLists($mailid);
			$access_sub = false;
			if(!empty($allLists)){
				foreach($allLists as $alist){
					if(empty($alist->mailid)) continue;
					if(!$alist->published OR !$alist->visible OR $alist->access_sub == 'none') continue;
					if(acymailing_isAllowed($alist->access_sub)){
						$access_sub = true;
						break;
					}

				}
			}
		}

		$mailClass = acymailing_get('helper.mailer');
		$mailClass->loadedToSend = false;
		$oneMail = $mailClass->load($mailid);

		if(empty($oneMail->mailid)){
			return JError::raiseError( 404, 'Newsletter not found : '.$mailid );
		}

		if(!$frontEndManagement AND (!$access_sub OR !$oneMail->published OR !$oneMail->visible)){
			$key = JRequest::getCmd('key');
			if(empty($key) OR $key !== $oneMail->key){
				$reason = (!$oneMail->published) ? 'Newsletter not published' : (!$oneMail->visible ? 'Newsletter not visible' : (!$access_sub ? 'Access not allowed' : ''));
				$app->enqueueMessage('You can not have access to this e-mail : '.$reason,'error');
				$app->redirect(acymailing_completeLink('lists',false,true));
				return false;
			}
		}

		$fshare = '';
		if(preg_match('#<img[^>]*id="pictshare"[^>]*>#i',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[0],$pict)){
			$fshare = $pict[1];
		}elseif(preg_match('#<img[^>]*class="[^"]*pictshare[^"]*"[^>]*>#i',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[0],$pict)){
			$fshare = $pict[1];
		}elseif(preg_match('#class="acymailing_content".*(<img[^>]*>)#is',$oneMail->body,$pregres) && preg_match('#src="([^"]*)"#i',$pregres[1],$pict)){
			if(strpos($pregres[1],JText::_('JOOMEXT_READ_MORE')) === false) $fshare = $pict[1];
		}

		if(!empty($fshare)){
			$document->setMetadata('og:image', $fshare);
		}

		$document->setMetadata('og:url',acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid='.$oneMail->mailid,JRequest::getCmd('tmpl') == 'component' ? true : false));
		$document->setMetadata('og:title',$oneMail->subject);
		if(!empty($oneMail->metadesc))$document->setMetadata('og:description',$oneMail->metadesc);

		$subkeys = JRequest::getString('subid',JRequest::getString('sub'));
		if(!empty($subkeys)){
			$db = JFactory::getDBO();
			$subid = intval(substr($subkeys,0,strpos($subkeys,'-')));
			$subkey = substr($subkeys,strpos($subkeys,'-')+1);
			$db->setQuery('SELECT * FROM '.acymailing_table('subscriber').' WHERE `subid` = '.$db->Quote($subid).' AND `key` = '.$db->Quote($subkey).' LIMIT 1');
			$receiver = $db->loadObject();
		}

		if(empty($receiver) AND !empty($my->email)){
			$userClass = acymailing_get('class.subscriber');
			$receiver = $userClass->get($my->email);
		}

		if(empty($receiver)){
			$receiver = new stdClass();
			$receiver->name = JText::_('VISITOR');
		}

		$oneMail->sendHTML = true;
		$mailClass->dispatcher->trigger('acymailing_replaceusertags',array(&$oneMail,&$receiver,false));

		$pathway->addItem($oneMail->subject);

		$document	= JFactory::getDocument();
		acymailing_setPageTitle($oneMail->subject);

		if (!empty($oneMail->metadesc)) {
			$document->setDescription( $oneMail->metadesc );
		}
		if (!empty($oneMail->metakey)) {
			$document->setMetadata('keywords', $oneMail->metakey);
		}

		$this->assignRef('mail',$oneMail);
		$this->assignRef('frontEndManagement',$frontEndManagement);
		$this->assignRef('list',$oneList);
		$config =& acymailing_config();
		$this->assignRef('config',$config);
		$this->assignRef('my',$my);
		$this->assignRef('receiver',$receiver);
		$this->assignRef('values',$values);

		if($oneMail->html){
			$templateClass = acymailing_get('class.template');
			$templateClass->archiveSection = true;
			$templateClass->displayPreview('newsletter_preview_area',$oneMail->tempid,$oneMail->subject);
		}
	}
Ejemplo n.º 4
0
    function form()
    {
        $db = JFactory::getDBO();
        $config = acymailing_config();
        if (JRequest::getVar('task') == 'filterDisplayUsers') {
            $action = array();
            $action['type'] = array('displayUsers');
            $action[] = array('displayUsers' => array());
            $filterClass = acymailing_get('class.filter');
            $filterClass->subid = JRequest::getString('subid');
            $filterClass->execute(JRequest::getVar('filter'), $action);
            if (!empty($filterClass->report)) {
                $this->assignRef('filteredUsers', $filterClass->report[0]);
            }
        }
        $filid = acymailing_getCID('filid');
        $filterClass = acymailing_get('class.filter');
        $testFilter = JRequest::getVar('filter');
        if (!empty($filid) && empty($testFilter)) {
            $filter = $filterClass->get($filid);
        } else {
            $filter = new stdClass();
            $filter->action = JRequest::getVar('action');
            $filter->filter = JRequest::getVar('filter');
            $filter->published = 1;
        }
        JPluginHelper::importPlugin('acymailing');
        $this->dispatcher = JDispatcher::getInstance();
        $typesFilters = array();
        $typesActions = array();
        $outputFilters = implode('', $this->dispatcher->trigger('onAcyDisplayFilters', array(&$typesFilters, 'massactions')));
        $outputActions = implode('', $this->dispatcher->trigger('onAcyDisplayActions', array(&$typesActions)));
        $typevaluesFilters = array();
        $typevaluesActions = array();
        $typevaluesFilters[] = JHTML::_('select.option', '', JText::_('FILTER_SELECT'));
        $typevaluesActions[] = JHTML::_('select.option', '', JText::_('ACTION_SELECT'));
        $doc = JFactory::getDocument();
        foreach ($typesFilters as $oneType => $oneName) {
            $typevaluesFilters[] = JHTML::_('select.option', $oneType, $oneName);
        }
        foreach ($typesActions as $oneType => $oneName) {
            $typevaluesActions[] = JHTML::_('select.option', $oneType, $oneName);
        }
        $js = "function updateAction(actionNum){\r\n\t\t\t\tvar actiontype = window.document.getElementById('actiontype'+actionNum);\r\n\t\t\t\tif(actiontype == 'undefined' || actiontype == null) return;\r\n\t\t\t\tcurrentActionType = actiontype.value;\r\n\t\t\t\tif(!currentActionType){\r\n\t\t\t\t\twindow.document.getElementById('actionarea_'+actionNum).innerHTML = '';\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tactionArea = 'action__num__'+currentActionType;\r\n\t\t\t\twindow.document.getElementById('actionarea_'+actionNum).innerHTML = window.document.getElementById(actionArea).innerHTML.replace(/__num__/g,actionNum);\r\n\t\t\t\tif(typeof(window['onAcyDisplayAction_'+currentActionType]) == 'function') {\r\n\t\t\t\t\ttry{ window['onAcyDisplayAction_'+currentActionType](actionNum); }catch(e){alert('Error in the onAcyDisplayAction_'+currentActionType+' function : '+e); }\r\n\t\t\t\t}\r\n\r\n\t\t\t}";
        $js .= "var numActions = 0;\r\n\t\t\t\tfunction addAction(){\r\n\t\t\t\t\tvar newdiv = document.createElement('div');\r\n\t\t\t\t\tnewdiv.id = 'action'+numActions;\r\n\t\t\t\t\tnewdiv.className = 'plugarea';\r\n\t\t\t\t\tnewdiv.innerHTML = document.getElementById('actions_original').innerHTML.replace(/__num__/g, numActions);\r\n\t\t\t\t\tvar allactions = document.getElementById('allactions');\r\n\t\t\t\t\tif(allactions != 'undefined' && allactions != null) allactions.appendChild(newdiv); updateAction(numActions); numActions++;\r\n\t\t\t\t}";
        $js .= "window.addEvent('domready', function(){ addAcyFilter(); addAction(); });";
        if (!ACYMAILING_J16) {
            $js .= 'function submitbutton(pressbutton){
						if (pressbutton != \'save\') {
							submitform( pressbutton );
							return;
						}';
        } else {
            $js .= 'Joomla.submitbutton = function(pressbutton) {
						if (pressbutton != \'save\') {
							Joomla.submitform(pressbutton,document.adminForm);
							return;
						}';
        }
        if (ACYMAILING_J30) {
            $js .= "if(window.document.getElementById('filterinfo').style.display == 'none'){\r\n\t\t\t\t\t\twindow.document.getElementById('filterinfo').style.display = 'block';\r\n\t\t\t\t\t\treturn false;}\r\n\t\t\t\t\tif(window.document.getElementById('title').value.length < 2){alert('" . JText::_('ENTER_TITLE', true) . "'); return false;}";
        } else {
            $js .= "if(window.document.getElementById('filterinfo').style.display == 'none'){\r\n\t\t\t\t\t\twindow.document.getElementById('filterinfo').style.display = 'block';\r\n\t\t\t\t\t\treturn false;}\r\n\t\t\t\t\tif(window.document.getElementById('title').value.length < 2){alert('" . JText::_('ENTER_TITLE', true) . "'); return false;}";
        }
        if (!ACYMAILING_J16) {
            $js .= "submitform( pressbutton );} ";
        } else {
            $js .= "Joomla.submitform(pressbutton,document.adminForm);}; ";
        }
        $doc->addScriptDeclaration($js);
        $filterClass->addJSFilterFunctions();
        $js = '';
        $data = array('addAction' => 'action', 'addAcyFilter' => 'filter');
        foreach ($data as $jsFunction => $datatype) {
            if (empty($filter->{$datatype})) {
                continue;
            }
            foreach ($filter->{$datatype}['type'] as $num => $oneType) {
                if (empty($oneType)) {
                    continue;
                }
                $js .= "while(!document.getElementById('" . $datatype . "type{$num}')){" . $jsFunction . "();}\r\n\t\t\t\t\t\tdocument.getElementById('" . $datatype . "type{$num}').value= '{$oneType}';\r\n\t\t\t\t\t\tupdate" . ucfirst($datatype) . "({$num});";
                if (empty($filter->{$datatype}[$num][$oneType])) {
                    continue;
                }
                foreach ($filter->{$datatype}[$num][$oneType] as $key => $value) {
                    if (is_array($value)) {
                        $js .= "try{";
                        foreach ($value as $subkey => $subval) {
                            $js .= "document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $subval)) . "';";
                            $js .= "if(document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].type && document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].type == 'checkbox'){ document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}][{$subkey}]'].checked = 'checked'; }";
                        }
                        $js .= "}catch(e){}";
                    }
                    $myVal = is_array($value) ? implode(',', $value) : $value;
                    $js .= "try{";
                    $js .= "document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].value = '" . addslashes(str_replace(array("\n", "\r"), ' ', $myVal)) . "';";
                    $js .= "if(document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].type && document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].type == 'checkbox'){ document.adminForm.elements['" . $datatype . "[{$num}][{$oneType}][{$key}]'].checked = 'checked'; }";
                    $js .= "}catch(e){}";
                }
                $js .= "\n" . " if(typeof(onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . ") == 'function'){\r\n\t\t\t\t\ttry{ onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . "({$num}); }catch(e){alert('Error in the onAcyDisplay" . ucfirst($datatype) . "_" . $oneType . " function : '+e); }\r\n\t\t\t\t}";
                if ($datatype == 'filter') {
                    $js .= " countresults({$num});";
                }
            }
        }
        $listid = JRequest::getInt('listid');
        if (!empty($listid)) {
            $js .= "document.getElementById('actiontype0').value = 'list'; updateAction(0); document.adminForm.elements['action[0][list][selectedlist]'].value = '" . $listid . "';";
        }
        $doc->addScriptDeclaration("window.addEvent('domready', function(){ {$js} });");
        $triggers = array();
        $triggers['daycron'] = JText::_('AUTO_CRON_FILTER');
        $nextDate = $config->get('cron_plugins_next');
        $listHours = array();
        $listMinutess = array();
        for ($i = 0; $i < 24; $i++) {
            $listHours[] = JHTML::_('select.option', $i, $i < 10 ? '0' . $i : $i);
        }
        $hours = JHTML::_('select.genericlist', $listHours, 'triggerhours', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', acymailing_getDate($nextDate, 'H'));
        for ($i = 0; $i < 60; $i += 5) {
            $listMinutess[] = JHTML::_('select.option', $i, $i < 10 ? '0' . $i : $i);
        }
        $defaultMin = floor(acymailing_getDate($nextDate, 'i') / 5) * 5;
        $minutes = JHTML::_('select.genericlist', $listMinutess, 'triggerminutes', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', $defaultMin);
        $this->assign('hours', $hours);
        $this->assign('minutes', $minutes);
        $this->assign('nextDate', !empty($nextDate) ? ' (' . JText::_('NEXT_RUN') . ' : ' . acymailing_getDate($nextDate, '%d %B %Y  %H:%M') . ')' : '');
        $triggers['allcron'] = JText::_('ACY_EACH_TIME');
        $triggers['subcreate'] = JText::_('ON_USER_CREATE');
        $triggers['subchange'] = JText::_('ON_USER_CHANGE');
        $this->dispatcher->trigger('onAcyDisplayTriggers', array(&$triggers));
        $name = empty($filter->name) ? '' : ' : ' . $filter->name;
        if (JRequest::getCmd('tmpl', '') != 'component') {
            $acyToolbar = acymailing::get('helper.toolbar');
            $acyToolbar->custom('filterDisplayUsers', JText::_('FILTER_VIEW_USERS'), 'user', false, '');
            $acyToolbar->custom('process', JText::_('PROCESS'), 'process', false, '');
            $acyToolbar->divider();
            if (acymailing_level(3)) {
                $acyToolbar->save();
                if (!empty($filter->filid)) {
                    $acyToolbar->link(acymailing_completeLink('filter&task=edit&filid=0'), JText::_('ACY_NEW'), 'new');
                }
            }
            $acyToolbar->link(acymailing_completeLink('dashboard'), JText::_('ACY_CLOSE'), 'cancel');
            $acyToolbar->divider();
            $acyToolbar->help('filter');
            $acyToolbar->setTitle(JText::_('ACY_MASS_ACTIONS') . $name, 'filter&task=edit&filid=' . $filid);
            $acyToolbar->display();
        } else {
            acymailing_setPageTitle(JText::_('ACY_MASS_ACTIONS') . $name);
        }
        $subid = JRequest::getString('subid');
        if (!empty($subid)) {
            $subArray = explode(',', trim($subid, ','));
            JArrayHelper::toInteger($subArray);
            $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . implode(',', $subArray) . ')');
            $users = $db->loadObjectList();
            if (!empty($users)) {
                $this->assignRef('users', $users);
                $this->assignRef('subid', $subid);
            }
        }
        $this->assignRef('typevaluesFilters', $typevaluesFilters);
        $this->assignRef('typevaluesActions', $typevaluesActions);
        $this->assignRef('outputFilters', $outputFilters);
        $this->assignRef('outputActions', $outputActions);
        $this->assignRef('filter', $filter);
        $this->assignRef('triggers', $triggers);
        if (JRequest::getCmd('tmpl') == 'component') {
            $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css?v=' . filemtime(ACYMAILING_MEDIA . 'css' . DS . 'frontendedition.css'));
        }
        if (acymailing_level(3) and JRequest::getCmd('tmpl') != 'component') {
            $db->setQuery('SELECT * FROM #__acymailing_filter ORDER BY `published` DESC, `filid` DESC');
            $filters = $db->loadObjectList();
            $toggleClass = acymailing_get('helper.toggle');
            $this->assignRef('toggleClass', $toggleClass);
            $this->assignRef('filters', $filters);
        }
    }
Ejemplo n.º 5
0
 function setTitle($name, $link = '')
 {
     $this->title = $name;
     $this->titleLink = $link;
     acymailing_setPageTitle($name);
 }
Ejemplo n.º 6
0
function acymailing_setTitle($name, $picture, $link)
{
    $extra = '';
    $style = '';
    $before = '';
    $after = '';
    if (!JRequest::getInt('hidemainmenu')) {
        $config = acymailing_config();
        if ($config->get('menu_position', 'under') == 'under') {
            $app = JFactory::getApplication();
            $currentTemplate = $app->getTemplate();
            if (ACYMAILING_J30 || in_array($currentTemplate, array('rt_missioncontrol', 'aplite', 'adminpraise3'))) {
                $newConfig = new stdClass();
                $newConfig->menu_position = 'above';
                $config->save($newConfig);
            }
            $menuHelper = acymailing_get('helper.acymenu');
            $extra = $menuHelper->display($link);
            $style = 'style="line-height:30px;"';
            $before = '<div style="min-height:48px">';
            $after = '</div>';
        }
    }
    JToolBarHelper::title($before . '<a ' . $style . ' href="' . acymailing_completeLink($link) . '">' . htmlspecialchars($name, ENT_COMPAT, 'UTF-8') . '</a>' . $extra . $after, $picture . '.png');
    acymailing_setPageTitle($name);
}
Ejemplo n.º 7
0
 function unsub()
 {
     $subscriberClass = acymailing_get('class.subscriber');
     $config = acymailing_config();
     $this->assignRef('config', $config);
     $subscriber = $subscriberClass->identify();
     $this->assignRef('subscriber', $subscriber);
     $mailid = JRequest::getInt('mailid');
     $this->assignRef('mailid', $mailid);
     $replace = array();
     $replace['{list:name}'] = '';
     foreach ($subscriber as $oneProp => $oneVal) {
         $replace['{user:'******'}'] = $oneVal;
     }
     if (!empty($mailid)) {
         $classListmail = acymailing_get('class.listmail');
         $lists = $classListmail->getLists($mailid);
         $this->assignRef('lists', $lists);
         if (!empty($lists)) {
             $oneList = reset($lists);
             foreach ($oneList as $oneProp => $oneVal) {
                 $replace['{list:' . $oneProp . '}'] = $oneVal;
             }
         }
         $mailClass = acymailing_get('class.mail');
         $news = $mailClass->get($mailid);
         if (!empty($news)) {
             foreach ($news as $oneProp => $oneVal) {
                 if (!is_string($oneVal)) {
                     continue;
                 }
                 $replace['{mail:' . $oneProp . '}'] = $oneVal;
             }
         }
     }
     $intro = str_replace('UNSUB_INTRO', JText::_('UNSUB_INTRO'), $config->get('unsub_intro', 'UNSUB_INTRO'));
     $intro = '<div class="unsubintro">' . nl2br(str_replace(array_keys($replace), $replace, $intro)) . '</div>';
     $this->assignRef('intro', $intro);
     $this->assignRef('replace', $replace);
     $unsubtext = str_replace(array_keys($replace), $replace, JText::_('UNSUBSCRIBE'));
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     $pathway->addItem($unsubtext);
     acymailing_setPageTitle($unsubtext);
 }
Ejemplo n.º 8
0
 function abtesting()
 {
     $app = JFactory::getApplication();
     $mailids = JRequest::getString('mailid');
     $validationStatus = JRequest::getString('validationStatus');
     $noMsg = false;
     $noBtn = false;
     if (!empty($mailids) && strpos($mailids, ',') !== false) {
         $db = JFactory::getDBO();
         $warningMsg = array();
         $mailsArray = explode(',', $mailids);
         JArrayHelper::toInteger($mailsArray);
         $mailids = implode(',', $mailsArray);
         $this->assign('mailid', $mailids);
         $query = 'SELECT abtesting FROM #__acymailing_mail WHERE mailid IN (' . implode(',', $mailsArray) . ') AND abtesting IS NOT NULL';
         $db->setQuery($query);
         $resDetail = acymailing_loadResultArray($db);
         if (!empty($resDetail) && count($resDetail) != count($mailsArray)) {
             $titlePage = JText::_('ABTESTING');
             acymailing_display(JText::_('ABTESTING_MISSINGEMAIL'), 'warning');
             $this->assign('missingMail', true);
         } else {
             $abTestDetail = array();
             if (empty($resDetail)) {
                 $abTestDetail['mailids'] = $mailids;
                 $abTestDetail['prct'] = 10;
                 $abTestDetail['delay'] = 2;
                 $abTestDetail['action'] = 'manual';
             } else {
                 $abTestDetail = unserialize($resDetail[0]);
                 $savedIds = explode(',', $abTestDetail['mailids']);
                 sort($savedIds);
                 sort($mailsArray);
                 if (!empty($abTestDetail['status']) && in_array($abTestDetail['status'], array('inProgress', 'testSendOver', 'abTestFinalSend')) && $savedIds != $mailsArray) {
                     $warningMsg[] = JText::_('ABTESTING_TESTEXIST');
                     $mailsArray = $savedIds;
                     $mailids = implode(',', $mailsArray);
                 }
                 $this->assign('savedValues', true);
                 if ($abTestDetail['status'] == 'inProgress') {
                     $warningMsg[] = JText::_('ABTESTING_INPROGRESS');
                 }
             }
             if ($validationStatus == 'abTestAdd') {
                 $noMsg = true;
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'abTestFinalSend' && !empty($abTestDetail['newMail'])) {
                 $mailInQueueErrorMsg = JText::_('ABTESTING_FINALMAILINQUEUE');
                 $mailTocheck = '=' . $abTestDetail['newMail'];
             } else {
                 $mailInQueueErrorMsg = JText::_('ABTESTING_TESTMAILINQUEUE');
                 $mailTocheck = ' IN (' . implode(',', $mailsArray) . ')';
             }
             $query = "SELECT COUNT(*) FROM #__acymailing_queue WHERE mailid" . $mailTocheck;
             $db->setQuery($query);
             $queueCheck = $db->loadResult();
             if (!empty($queueCheck) && $validationStatus != 'abTestAdd') {
                 acymailing_enqueueMessage($mailInQueueErrorMsg, 'error');
                 $noMsg = true;
             }
             if (!empty($resDetail) && empty($queueCheck) && in_array($abTestDetail['status'], array('inProgress', 'abTestFinalSend'))) {
                 if ($abTestDetail['status'] == 'inProgress') {
                     $abTestDetail['status'] = 'testSendOver';
                 } else {
                     $abTestDetail['status'] = 'completed';
                 }
                 $query = "UPDATE #__acymailing_mail SET abtesting=" . $db->quote(serialize($abTestDetail)) . " WHERE mailid IN (" . implode(',', $mailsArray) . ")";
                 $db->setQuery($query);
                 $db->query();
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'testSendOver') {
                 acymailing_enqueueMessage(JText::_('ABTESTING_READYTOSEND'), 'info');
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'completed') {
                 acymailing_enqueueMessage(JText::_('ABTESTING_COMPLETE'), 'info');
             }
             $this->assign('abTestDetail', $abTestDetail);
             $nbMails = count($mailsArray);
             $titleStr = "A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z";
             $titlePage = JText::sprintf('ABTESTING_TITLE', substr($titleStr, 0, min($nbMails, 26) * 2 - 1));
             $mailClass = acymailing_get('class.mail');
             $mailsDetails = array();
             foreach ($mailsArray as $mailid) {
                 $mailsDetails[] = $mailClass->get($mailid);
             }
             $this->assign('mailsdetails', $mailsDetails);
             $mailerHelper = acymailing_get('helper.mailer');
             $mailerHelper->loadedToSend = false;
             $mailReceiver = $mailerHelper->load($mailsArray[0]);
             $listmailClass = acymailing_get('class.listmail');
             $lists = $listmailClass->getReceivers($mailReceiver->mailid, true, false);
             $this->assign('lists', $lists);
             $this->assign('mailReceiver', $mailReceiver);
             $filterClass = acymailing_get('class.filter');
             $this->assign('filterClass', $filterClass);
             $listids = array();
             foreach ($lists as $oneList) {
                 $listids[] = $oneList->listid;
             }
             $nbTotalReceivers = $filterClass->countReceivers($listids, $this->mailReceiver->filter, $this->mailReceiver->mailid);
             if ($nbTotalReceivers < 50) {
                 $warningMsg[] = JText::sprintf('ABTESTING_NOTENOUGHUSER', $nbTotalReceivers);
                 $noBtn = true;
             }
             $this->assign('nbTotalReceivers', $nbTotalReceivers);
             $this->assign('nbTestReceivers', floor($nbTotalReceivers * $abTestDetail['prct'] / 100));
             if ($noMsg || $noBtn) {
                 $noButton = true;
             }
             $queryStat = 'SELECT mailid, openunique, clickunique, senthtml, senttext, bounceunique FROM #__acymailing_stats WHERE mailid IN (' . $mailids . ')';
             $db->setQuery($queryStat);
             $resStat = $db->loadObjectList('mailid');
             if (!empty($resStat)) {
                 $this->assign('statMail', $resStat);
                 $warningMsg[] = JText::_('ABTESTING_STAT_WARNING');
             }
             if (!empty($warningMsg) && $noMsg == false) {
                 acymailing_enqueueMessage(implode('<br />', $warningMsg), 'warning');
             }
         }
     } else {
         $titlePage = JText::_('ABTESTING');
     }
     $acyToolbar = acymailing::get('helper.toolbar');
     if (empty($noButton)) {
         $acyToolbar->custom('test', JText::_('ABTESTING_TEST'), 'test', false, "javascript:if(confirm('" . JText::_('PROCESS_CONFIRMATION', true) . "')){submitbutton('abtest');} return false;");
     }
     $acyToolbar->setTitle(JText::_('ABTESTING'));
     $acyToolbar->topfixed = false;
     $acyToolbar->display();
     $this->assign('validationStatus', $validationStatus);
     $this->assign('titlePage', $titlePage);
     $this->assign('app', $app);
     if ($app->isAdmin()) {
         acymailing_setPageTitle(JText::_('ABTESTING'));
     }
 }
Ejemplo n.º 9
0
 function mailing()
 {
     $doc = JFactory::getDocument();
     $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css?v=' . filemtime(ACYMAILING_MEDIA . 'css' . DS . 'frontendedition.css'));
     $doc->addStyleSheet(ACYMAILING_CSS . 'acyprint.css', 'text/css', 'print');
     $mailid = JRequest::getInt('mailid');
     if (empty($mailid)) {
         return;
     }
     $db = JFactory::getDBO();
     $db->setQuery('SELECT * FROM ' . acymailing_table('stats') . ' WHERE mailid = ' . intval($mailid));
     $mailingstats = $db->loadObject();
     if (empty($mailingstats->mailid)) {
         return;
     }
     $db->setQuery('SELECT COUNT(browser) as nbBrowser, browser FROM ' . acymailing_table('userstats') . ' WHERE browser IS NOT NULL AND mailid = ' . intval($mailid) . ' GROUP BY browser ORDER BY nbBrowser DESC');
     $browserstats = $db->loadObjectList('browser');
     $db->setQuery('SELECT COUNT(*) as nbMobile, is_mobile FROM ' . acymailing_table('userstats') . ' WHERE is_mobile IS NOT NULL AND mailid = ' . intval($mailid) . ' GROUP BY is_mobile');
     $ismobilestats = $db->loadObjectList('is_mobile');
     $db->setQuery('SELECT COUNT(mobile_os) as nbOS, mobile_os FROM ' . acymailing_table('userstats') . ' WHERE mobile_os IS NOT NULL AND mobile_os <> \'\' AND mailid = ' . intval($mailid) . ' GROUP BY mobile_os ORDER BY nbOS DESC');
     $mobileosstats = $db->loadObjectList('mobile_os');
     $mailClass = acymailing_get('class.mail');
     $mailing = $mailClass->get($mailid);
     acymailing_setPageTitle($mailing->subject);
     $db->setQuery('SELECT COUNT(*) FROM `#__acymailing_queue` WHERE `mailid` = ' . $mailingstats->mailid . ' GROUP BY `mailid`');
     $mailingstats->queue = $db->loadResult();
     $db->setQuery('SELECT min(opendate) as minval, max(opendate) as maxval FROM ' . acymailing_table('userstats') . ' WHERE opendate > 0 AND mailid = ' . intval($mailid));
     $datesOpen = $db->loadObject();
     $db->setQuery('SELECT min(`date`) as minval, max(`date`) as maxval FROM ' . acymailing_table('urlclick') . ' WHERE  mailid = ' . intval($mailid));
     $datesClick = $db->loadObject();
     $spaces = array();
     $intervals = 10;
     $minDate = min($datesOpen->minval, $datesClick->minval);
     if (empty($minDate)) {
         $minDate = max($datesOpen->minval, $datesClick->minval);
     }
     $maxDate = max($datesOpen->maxval, $datesClick->maxval) + 1;
     $delay = ($maxDate - $minDate) / $intervals;
     for ($i = 0; $i < $intervals; $i++) {
         $spaces[$i] = (int) ($minDate + $delay * $i);
     }
     $spaces[$intervals] = $maxDate;
     $openclick = new stdClass();
     $openclick->open = array();
     $openclick->click = array();
     $openclick->legend = array();
     $dateFormat = '%d %B %Y';
     if (date('Y', $maxDate) == date('Y', $minDate)) {
         $dateFormat = '%d %B';
         if (date('m', $maxDate) == date('m', $minDate)) {
             $dateFormat = '%A %d';
             if ($delay < 172800) {
                 $dateFormat = '%a %d %H:%M';
             }
         }
     }
     $openresults = array();
     $legendX = array();
     for ($i = 0; $i <= $intervals; $i++) {
         if ($i % 2 == 0) {
             $openclick->legend[$i] = acymailing_getDate($spaces[$i], $dateFormat);
         }
         $db->setQuery('SELECT count(subid) FROM ' . acymailing_table('userstats') . ' WHERE opendate < ' . $spaces[$i] . ' AND opendate > 0 AND mailid = ' . intval($mailid));
         $openclick->open[$i] = (int) $db->loadResult();
         $db->setQuery('SELECT count(subid) FROM ' . acymailing_table('urlclick') . ' WHERE date < ' . $spaces[$i] . ' AND mailid = ' . intval($mailid));
         $openclick->click[$i] = (int) $db->loadResult();
     }
     $joomConfig = JFactory::getConfig();
     $timeoffset = ACYMAILING_J30 ? $joomConfig->get('offset') : $joomConfig->getValue('config.offset');
     $diffTime = $timeoffset - date('Z');
     $groupingFormat = '%Y %j';
     $phpformat = '%d %B';
     $diff = 86400;
     if ($delay < 3600) {
         $groupingFormat = '%Y %j %H';
         $phpformat = '%a %d %H';
         $diff = 3600;
     }
     $query = "SELECT DATE_FORMAT(FROM_UNIXTIME(a.opendate + {$diffTime}),'{$groupingFormat}') AS openday, a.opendate, COUNT(a.subid) AS totalopen ";
     $query .= 'FROM #__acymailing_userstats AS a WHERE opendate > 0 AND mailid = ' . intval($mailid);
     $query .= ' GROUP BY openday ORDER BY openday DESC LIMIT 10';
     $db->setQuery($query);
     $datesOpen = $db->loadObjectList('openday');
     $query = "SELECT DATE_FORMAT(FROM_UNIXTIME(a.date + {$diffTime}),'{$groupingFormat}') AS clickday, a.date, COUNT(a.subid) AS totalclick ";
     $query .= 'FROM #__acymailing_urlclick AS a WHERE mailid = ' . intval($mailid);
     $query .= ' GROUP BY clickday ORDER BY clickday DESC LIMIT 10';
     $db->setQuery($query);
     $datesClick = $db->loadObjectList('clickday');
     $openclickday = array();
     foreach ($datesOpen as $time => $oneDate) {
         $openclickday[$time] = array();
         $openclickday[$time]['date'] = acymailing_getDate($oneDate->opendate, $phpformat);
         $openclickday[$time]['nextdate'] = acymailing_getDate($oneDate->opendate - $diff, $phpformat);
         $openclickday[$time]['open'] = $oneDate;
     }
     foreach ($datesClick as $time => $oneDate) {
         if (!isset($openclickday[$time])) {
             $openclickday[$time] = array();
             $openclickday[$time]['date'] = acymailing_getDate($oneDate->date, $phpformat);
             $openclickday[$time]['nextdate'] = acymailing_getDate($oneDate->date - $diff, $phpformat);
         }
         $openclickday[$time]['click'] = $oneDate;
     }
     krsort($openclickday);
     $query = 'SELECT c.*, COUNT(a.click) as uniqueclick, SUM(a.click) as totalclick  FROM #__acymailing_urlclick as a';
     $query .= ' JOIN ' . acymailing_table('url') . ' as c on a.urlid = c.urlid';
     $query .= ' WHERE a.mailid = ' . intval($mailid) . ' GROUP BY a.urlid ORDER BY uniqueclick DESC LIMIT 5';
     $db->setQuery($query);
     $mailinglinks = $db->loadObjectList();
     $this->assignRef('mailinglinks', $mailinglinks);
     $this->assignRef('mailing', $mailing);
     $this->assignRef('mailingstats', $mailingstats);
     $this->assignRef('openclick', $openclick);
     $this->assignRef('openclickday', $openclickday);
     $this->assignRef('ctrl', $this->ctrl);
     $this->assignRef('config', acymailing_config());
     $this->assign('browserstats', $browserstats);
     $this->assign('ismobilestats', $ismobilestats);
     $this->assign('mobileosstats', $mobileosstats);
     $this->setLayout('mailing');
 }