Your IP : 216.73.216.61


Current Path : /home/w/u/e/wuectly/www/03cbe/
Upload File :
Current File : /home/w/u/e/wuectly/www/03cbe/acymailing.tar

share/share.xml000060400000007222152455610250007476 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing : share on social networks</name>
	<creationDate>August 2010</creationDate>
	<version>1.0.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add a share icon for social networks</description>
	<files>
		<filename plugin="share">share.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-share"/>
		<param name="template" type="radio" default="component" label="Display the online version" description="Select if you want to display the online version (when the user will share your link on the social network) without any Joomla module (no template) or inside your default Joomla Template">
			<option value="standard">Standard template</option>
			<option value="component">No template</option>
		</param>

		<param name="picturefb" type="text" label="Facebook picture - DEPRECATED" default="media/com_acymailing/images/facebookshare.png" />
		<param name="picturetwitter" type="text" label="Twitter picture - DEPRECATED" default="media/com_acymailing/images/twittershare.png" />
		<param name="picturelinkedin" type="text" label="LinkedIn picture - DEPRECATED" default="media/com_acymailing/images/linkedin.png" />
		<param name="picturegoogleplus" type="text" label="Google+ picture - DEPRECATED" default="media/com_acymailing/images/google_plusshare.png" />
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>

	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-share"/>
				<field name="template" type="radio" default="component" label="Display the online version" description="Select if you want to display the online version (when the user will share your link on the social network) without any Joomla module (no template) or inside your default Joomla Template">
					<option value="standard">Standard template</option>
					<option value="component">No template</option>
				</field>

				<field name="picturefb" type="text" label="Facebook picture - DEPRECATED" default="media/com_acymailing/images/facebookshare.png" />
				<field name="picturetwitter" type="text" label="Twitter picture - DEPRECATED" default="media/com_acymailing/images/twittershare.png" />
				<field name="picturelinkedin" type="text" label="LinkedIn picture - DEPRECATED" default="media/com_acymailing/images/linkedin.png" />
				<field name="picturegoogleplus" type="text" label="Google+ picture - DEPRECATED" default="media/com_acymailing/images/google_plusshare.png" />
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>

			</fieldset>
		</fields>
	</config>
</extension>
share/share.php000060400000021016152455610250007462 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingShare extends JPlugin{
	var $pictresults = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'share');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){

		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation_sprintf('SOCIAL_SHARE', '...');
		$onePlugin->function = 'acymailingtagshare_show';
		$onePlugin->help = 'plugin-share';

		return $onePlugin;
	}

	function _getPictures($folder){
		$allFolders = acymailing_getFolders($folder);
		foreach($allFolders as $oneFolder){
			$this->_getPictures($folder.DS.$oneFolder);
		}
		$allFiles = acymailing_getFiles($folder, $this->regex);
		foreach($allFiles as $oneFile){
			$this->pictresults[substr($oneFile, 0, 4)][$oneFile.filesize($folder.DS.$oneFile)] = $folder.DS.$oneFile;
		}
	}

	function acymailingtagshare_show(){
		$uploadFolders = acymailing_getFilesFolder('upload', true);
		$uploadFolder = acymailing_getVar('string', 'currentFolder', $uploadFolders[0]);
		$uploadPath = acymailing_cleanPath(ACYMAILING_ROOT.trim(str_replace('/', DS, trim($uploadFolder)), DS));
		$uploadedFile = acymailing_getVar('array', 'socialfile', array(), 'files');
		
		if(!empty($uploadedFile) && !empty($uploadedFile['name'])){
			$uploadedFile['name'] = acymailing_getVar('string', 'socialchoice').substr($uploadedFile['name'], strrpos($uploadedFile['name'], '.'));
			acymailing_importFile($uploadedFile, $uploadPath, true, 150);
		}
		
		
		$networks = array();
		$networks['facebook'] = 'Facebook';
		$networks['linkedin'] = 'LinkedIn';
		$networks['twitter'] = 'Twitter';
		$networks['google'] = 'Google+';
		$networks['print'] = acymailing_translation('ACY_PRINT');

		$k = 0;
		
		$this->regex = '('.implode('|', array_keys($networks)).').*(png|gif|jpeg|jpg)';
		$this->_getPictures(ACYMAILING_MEDIA);

		$socialList = array();
		$socialList[] = acymailing_selectOption('facebook', 'Facebook');
		$socialList[] = acymailing_selectOption('linkedIn', 'LinkedIn');
		$socialList[] = acymailing_selectOption('twitter', 'Twitter');
		$socialList[] = acymailing_selectOption('google', 'Google+');
		$socialChoice = acymailing_select($socialList, 'socialchoice', 'size="1" style="width:100px;"');
?>
		<br style="clear:both;">

		<div class="onelineblockoptions">
			<span class="acyblocktitle"><?php echo acymailing_translation('UPLOAD_NEW_IMAGE'); ?></span>

			<table>
				<tr>
					<td style="padding: 5px;"><?php echo $socialChoice; ?></td>
					<td style="padding: 5px;"><input type="file" name="socialfile"></td>
					<td style="padding: 5px;"><input class="acymailing_button_grey" type="submit" value="Upload"></td>
				</tr>
			</table>
		</div>
<?php
		foreach($networks as $name => $desc){
			$shortName = substr($name, 0, 4);
			if(empty($this->pictresults[$shortName])) continue;

			if($desc == acymailing_translation('ACY_PRINT')){
				$legendTxt = $desc;
			}else{
				$legendTxt = acymailing_translation_sprintf('SOCIAL_SHARE', $desc);
			}

			echo '<div class="onelineblockoptions">
					<span class="acyblocktitle">'.$legendTxt.'</span>';
			foreach($this->pictresults[$shortName] as $onePict){
				$imgPath = preg_replace('#^'.preg_quote(ACYMAILING_ROOT, '#').'#i', ACYMAILING_LIVE, $onePict);
				$imgPath = str_replace(DS, '/', $imgPath);

				if($desc == acymailing_translation('ACY_PRINT')){
					$insertedtag = '<a target="_blank" href="{print:newsletter}" title="'.acymailing_translation('ACY_PRINT').'" ><img src="'.$imgPath.'" alt="'.$desc.'" /></a>';
				}else{
					$insertedtag = '<a target="_blank" href="{sharelink:'.$name.'}" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', $desc).'" ><img src="'.$imgPath.'" alt="'.$desc.'" /></a>';
				}

				echo '<img style="max-width:200px;cursor:pointer;padding:5px;" onclick="setTag(\''.htmlentities($insertedtag).'\');insertTag();" src="'.$imgPath.'" />';
			}
			echo '</div>';
			$k = 1 - $k;
		}
	}

	function acymailing_replacetags(&$email, $send = true){
		if(acymailing_getVar('none', 'task', '') == 'replacetags') return;
		$this->_print($email, $send);
		$this->_shareButtons($email, $send);
	}

	function _shareButtons(&$email, $send = true){
		$match = '#(?:{|%7B)(share|sharelink):(.*)(?:}|%7D)#Ui';
		$variables = array('body', 'altbody');
		$found = false;
		$results = array();
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found) return;

		$archiveLink = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid='.$email->mailid, false, $this->params->get('template', 'component') == 'component' ? true : false);
		if(empty($email->published)){
			$archiveLink .= (strpos($archiveLink, '?') ? '&' : '?').'time='.time();
		}

		$tags = array();
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $numres => $tagname){
				if(isset($tags[$tagname])) continue;
				$arguments = explode('|', $allresults[2][$numres]);
				$tag = new stdClass();
				$tag->network = $arguments[0];
				for($i = 1, $a = count($arguments); $i < $a; $i++){
					$args = explode(':', $arguments[$i]);
					if(isset($args[1])){
						$tag->{$args[0]} = $args[1];
					}else{
						$tag->{$args[0]} = true;
					}
				}

				$link = '';
				if($tag->network == 'facebook'){
					$link = 'http://www.facebook.com/sharer.php?u='.urlencode($archiveLink).'&t='.urlencode($email->subject);
					$tags[$tagname] = '<a target="_blank" href="'.$link.'" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', 'Facebook').'"><img alt="Facebook" src="'.ACYMAILING_LIVE.$this->params->get('picturefb', 'media/com_acymailing/images/facebookshare.png').'" /></a>';
				}elseif($tag->network == 'twitter'){
					$text = acymailing_translation_sprintf('SHARE_TEXT', $archiveLink);
					$link = 'http://twitter.com/home?status='.urlencode($text);
					$tags[$tagname] = '<a target="_blank" href="'.$link.'" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', 'Twitter').'"><img alt="Twitter" src="'.ACYMAILING_LIVE.$this->params->get('picturetwitter', 'media/com_acymailing/images/twittershare.png').'" /></a>';
				}elseif($tag->network == 'linkedin'){
					$link = 'http://www.linkedin.com/shareArticle?mini=true&url='.urlencode($archiveLink).'&title='.urlencode($email->subject);
					$tags[$tagname] = '<a target="_blank" href="'.$link.'" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', 'LinkedIn').'"><img alt="LinkedIn" src="'.ACYMAILING_LIVE.$this->params->get('picturelinkedin', 'media/com_acymailing/images/linkedin.png').'" /></a>';
				}elseif($tag->network == 'google'){
					$link = 'https://plus.google.com/share?url='.urlencode($archiveLink);
					$tags[$tagname] = '<a target="_blank" href="'.$link.'" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', 'Google+').'"><img alt="Google+" src="'.ACYMAILING_LIVE.$this->params->get('picturegoogleplus', 'media/com_acymailing/images/google_plusshare.png').'" /></a>';
				}

				if($allresults[1][$numres] == 'sharelink'){
					$tags[$tagname] = $link;
				}

				if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'share.php')){
					ob_start();
					require(ACYMAILING_MEDIA.'plugins'.DS.'share.php');
					$tags[$tagname] = ob_get_clean();
				}
			}
		}

		$email->body = str_replace(array_keys($tags), $tags, $email->body);
		$email->altbody = str_replace(array_keys($tags), '', $email->altbody);
	}

	private function _print(&$email, $send = true){
		$variables = array('subject', 'body', 'altbody');
		$acypluginsHelper = acymailing_get('helper.acyplugins');
		$tags = $acypluginsHelper->extractTags($email, 'print');

		$archiveLink = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid='.$email->mailid, true, $this->params->get('template', 'component') == 'component' ? true : false);
		$addkey = (!empty($email->key)) ? '&key='.$email->key : '';
		$adduserkey = '&subid={subtag:subid}-{subtag:key}';
		$link = $archiveLink.'&print=1'.$addkey.$adduserkey;

		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$email->$var = str_replace(array_keys($tags), $link, $email->$var);
		}
	}
}//endclass
share/index.html000060400000000054152455610250007643 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tagsubscription/tagsubscription.php000060400000104064152455610250013723 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTagsubscription extends JPlugin{
	var $listunsubscribe = false;
	var $lists = array();
	var $listsowner = array();
	var $listsinfo = array();
	var $campaigns = array();
	var $unsubscribeLink = false;
	var $unsubscribeItem = '';

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tagsubscription');
			$this->params = new acyParameter($plugin->params);
		}
		$this->acypluginsHelper = acymailing_get('helper.acyplugins');
	}

	function acymailing_getPluginType(){

		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('SUBSCRIPTION');
		$onePlugin->function = 'acymailingtagsubscription_show';
		$onePlugin->help = 'plugin-tagsubscription';

		return $onePlugin;
	}

	function acymailingtagsubscription_show(){

		$others = array();
		$others['unsubscribe'] = array('name' => acymailing_translation('UNSUBSCRIBE_LINK'), 'default' => acymailing_translation('UNSUBSCRIBE', true));
		$others['modify'] = array('name' => acymailing_translation('MODIFY_SUBSCRIPTION_LINK'), 'default' => acymailing_translation('MODIFY_SUBSCRIPTION', true));
		$others['confirm'] = array('name' => acymailing_translation('CONFIRM_SUBSCRIPTION_LINK'), 'default' => acymailing_translation('CONFIRM_SUBSCRIPTION', true));
		$others['subscribe'] = array('name' => acymailing_translation('SUBSCRIBE_LINK'), 'default' => acymailing_translation('SUBSCRIBE', true));

		?>
		<script language="javascript" type="text/javascript">
			<!--
			var openLists = true;
			var selectedTag = '';
			function changeTag(tagName){
				selectedTag = tagName;
				defaultText = [];
				<?php
				$k = 0;
				foreach($others as $tagname => $tag){
					echo "document.getElementById('tr_$tagname').className = 'row$k';";
					echo "defaultText['$tagname'] = '".$tag['default']."';";
					$k = 1 - $k;
				}
				?>
				document.getElementById('tr_' + tagName).className = 'selectedrow';
				document.adminForm.tagtext.value = defaultText[tagName];
				if(tagName == 'subscribe'){
					document.getElementById('iframelists').style.display = '';
					document.getElementById('subscriptionlists').style.display = '';
					if(openLists) displayLists();
				}else{
					document.getElementById('iframelists').style.display = 'none';
					document.getElementById('subscriptionlists').style.display = 'none';
				}
				setSubscriptionTag();
			}

			function setSubscriptionTag(){
				var tag = '{' + selectedTag;

				if(document.getElementById('tagmenu').value != 0) tag += "|itemid:" + document.getElementById('tagmenu').value;
				if(selectedTag == 'subscribe') tag += "|lists:" + document.getElementById('paramslistids').value;

				tag += '}' + document.adminForm.tagtext.value + '{/' + selectedTag + '}'
				setTag(tag);
			}

			function displayLists(){
				var box = document.getElementById('iframelists');
				if(openLists){
					box.style.display = 'block';
					box.className += ' slide_open';
				}else{
					box.className = box.className.replace('slide_open', 'slide_close');
				}

				if(!openLists) setSubscriptionTag();
				openLists = !openLists;
			}
			//-->
		</script>
		<?php

		acymailing_addScript(true, "document.addEventListener(\"DOMContentLoaded\", function(){ changeTag('unsubscribe'); });");

		$text = '<div id="iframelists" style="display:none;"><iframe src="index.php?option=com_acymailing&tmpl=component&ctrl='.(acymailing_isAdmin() ? '' : 'front').'chooselist&popup=0&task=listids&all=0" width="98%" height="100%" scrolling="auto"></iframe></div>
				<div class="onelineblockoptions">
					<span class="acyblocktitle">'.acymailing_translation('SUBSCRIPTION').'</span>
					<table class="acymailing_table" cellpadding="1">';
		$menus = acymailing_loadObjectList('SELECT 0 AS id, "- - -" AS title UNION SELECT id, title FROM #__menu WHERE link LIKE "%com_acymailing%" AND client_id = 0 AND published = 1');
		$text .= '<tr>
					<td><label for="tagtext">'.acymailing_translation('FIELD_TEXT').': </label><input type="text" name="tagtext" id="tagtext" onchange="setSubscriptionTag();"></td>
					<td><label for="tagmenu">'.acymailing_translation('ACY_MENU').': </label>'.acymailing_select($menus, "tagmenu", 'class="inputbox" size="1" onchange="setSubscriptionTag();"', 'id', 'title', '').'</td>
				</tr>
				<tr id="subscriptionlists">
					<td colspan="2">
						<button class="acymailing_button_grey" onclick="displayLists();return false;">'.acymailing_translation('LISTS').'</button>
						<input class="inputbox" id="paramslistids" name="listids" type="text" style="width:100px" value="">
					</td>
				</tr>';
		$text .= '</table>
					<table class="acymailing_table" cellpadding="1">';

		$k = 0;
		foreach($others as $tagname => $tag){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="changeTag(\''.$tagname.'\');" id="tr_'.$tagname.'" ><td class="acytdcheckbox"></td><td>'.$tag['name'].'</td></tr>';
			$k = 1 - $k;
		}
		$text .= '</table></div>';

		$others = array();
		$others['name'] = acymailing_translation('LIST_NAME');
		$others['names'] = acymailing_translation('ACY_LIST_NAMES');
		$others['description'] = acymailing_translation('ACY_DESCRIPTION');
		$others['count'] = trim(acymailing_translation('GEOLOC_NB_USERS', true), ':');
		$others['count|listid:0'] = trim(acymailing_translation('GEOLOC_NB_USERS', true), ':').' ('.acymailing_translation('ALL_LISTS').')';
		$others['id'] = acymailing_translation('ACY_ID', true);

		$text .= '<div class="onelineblockoptions">
					<span class="acyblocktitle">'.acymailing_translation('LIST').'</span>
					<table class="acymailing_table" cellpadding="1">';

		$k = 0;
		foreach($others as $tagname => $tag){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\'{list:'.$tagname.'}\');insertTag();" id="tr_'.$tagname.'" ><td class="acytdcheckbox"></td><td>'.$tag.'</td></tr>';
			$k = 1 - $k;
		}

		$text .= '</table></div>';

		$text .= '<div class="onelineblockoptions">
					<span class="acyblocktitle">'.acymailing_translation('NEWSLETTER').'</span>
					<table class="acymailing_table" cellpadding="1">';
		$othersMail = array('mailid', 'subject', 'alias', 'key', 'altbody');
		$k = 0;
		foreach($othersMail as $tag){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\'{mail:'.$tag.'}\');insertTag();" id="tr_'.$tag.'" ><td class="acytdcheckbox"></td><td>'.$tag.'</td></tr>';
			$k = 1 - $k;
		}
		$text .= '</table></div>';

		echo $text;
	}

	function onAcyDisplayActions(&$type){
		$type['list'] = acymailing_translation('ACYMAILING_LIST');
		$status = array();
		$status[] = acymailing_selectOption(1, acymailing_translation('SUBSCRIBE_TO'));
		$status[] = acymailing_selectOption(0, acymailing_translation('REMOVE_FROM'));
		$status[] = acymailing_selectOption(-1, acymailing_translation('ACY_UNSUB_FROM'));

		$lists = $this->_getLists();
		$otherlists = array();
		$onChange = '';
		if(acymailing_level(3)){
			$otherlists = acymailing_loadObjectList('SELECT b.listid, b.name FROM #__acymailing_listcampaign as a JOIN #__acymailing_list as b on a.listid = b.listid GROUP BY b.listid ORDER BY b.ordering ASC', 'listid');
			$onChange = 'onchange="onAcyDisplayAction_list(__num__);"';

			$js = "function onAcyDisplayAction_list(num){
				if(!document.getElementById('campaigndelay'+num)) return;
				if(document.getElementById('subliststatus'+num).value == 1 && document.getElementById('sublistvalue'+num).value.indexOf('_campaign') > 0){
					document.getElementById('campaigndelay'+num).style.display = 'inline';
				}else{
					document.getElementById('campaigndelay'+num).style.display = 'none';
				}
			}";
			acymailing_addScript(true, $js);
		}

		$listsdrop = array();
		foreach($lists as $oneList){
			if(!empty($otherlists[$oneList->listid])) $listsdrop[] = acymailing_selectOption($oneList->listid.'_campaign', $otherlists[$oneList->listid]->name.' + '.acymailing_translation('CAMPAIGN'));
			$listsdrop[] = acymailing_selectOption($oneList->listid, $oneList->name);
		}

		$return = '<div id="action__num__list">'.acymailing_select($status, "action[__num__][list][status]", 'class="inputbox" size="1" '.$onChange, 'value', 'text', '', 'subliststatus__num__').' '.acymailing_select($listsdrop, "action[__num__][list][selectedlist]", 'class="inputbox" size="1" '.$onChange, 'value', 'text', '', 'sublistvalue__num__');
		if(!empty($otherlists)){
			$delay = array();
			$delay[] = acymailing_selectOption('day', acymailing_translation('DAYS'));
			$delay[] = acymailing_selectOption('week', acymailing_translation('WEEKS'));
			$delay[] = acymailing_selectOption('month', acymailing_translation('MONTHS'));

			$listHours = array();
			$listHours[] = acymailing_selectOption('', '- -');
			for($i = 0; $i < 24; $i++){
				$listHours[] = acymailing_selectOption(($i < 10 ? '0'.$i : $i), ($i < 10 ? '0'.$i : $i));
			}
			$hours = acymailing_select($listHours, 'action[__num__][list][sendhours]', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', '');

			$listMinutess = array();
			$listMinutess[] = acymailing_selectOption('', '- -');
			for($i = 0; $i < 60; $i += 5){
				$listMinutess[] = acymailing_selectOption(($i < 10 ? '0'.$i : $i), ($i < 10 ? '0'.$i : $i));
			}
			$minutes = acymailing_select($listMinutess, 'action[__num__][list][sendminutes]', 'class="inputbox" size="1" style="width:60px;"', 'value', 'text', '');

			$return .= '<br /><span id="campaigndelay__num__">'.acymailing_translation_sprintf('TRIGGER_CAMPAIGN', '<input type="text" name="action[__num__][list][delaynum]" value="0" style="width:50px" />', acymailing_select($delay, "action[__num__][list][delaytype]", 'class="inputbox" size="1" style="width:120px;"', 'value', 'text')).' @ '.$hours.' : '.$minutes;
			$return .= '<br />'.acymailing_translation_sprintf('ACY_CAMPAIGN_NB_FOLLOW_SKIPED', '<input type="text" name="action[__num__][list][skipedfollowups]" value="0" style="width:25px;" />').'</span>';
		}
		$return .= '</div>';

		return $return;
	}

	private function _getLists(){
		if(!empty($this->allLists)) return $this->allLists;
		$list = acymailing_get('class.list');
		if(acymailing_isAdmin()){
			$this->allLists = $list->getLists();
		}else{
			$this->allLists = $list->getFrontendLists();
		}

		return $this->allLists;
	}

	private function _getCampaigns(){

		$list = acymailing_get('class.list');
		if(acymailing_isAdmin()){
			return $list->getAllCampaigns();
		}
		return $list->getFrontendCampaigns();
	}

	function onAcyDisplayFilters(&$type, $context = "massactions"){

		if($this->params->get('displayfilter_'.$context, true) == false) return;

		$type['list'] = acymailing_translation('ACYMAILING_LIST');
		$status = acymailing_get('type.statusfilterlist');
		$status->extra = 'onchange="countresults(__num__);"';

		$lists = $this->_getLists();
		$campaigns = $this->_getCampaigns();
		$listsdrop = array();

		$listsdrop[] = acymailing_selectOption('<OPTGROUP>', acymailing_translation('LISTS'));
		foreach($lists as $oneList){
			$listsdrop[] = acymailing_selectOption($oneList->listid, $oneList->name);
		}
		$listsdrop[] = acymailing_selectOption('</OPTGROUP>');

		if(count($campaigns) > 0){
			$listsdrop[] = acymailing_selectOption('<OPTGROUP>', acymailing_translation('ACY_CAMPAIGNS'));
			foreach($campaigns as $campaign){
				$listsdrop[] = acymailing_selectOption($campaign->listid, $campaign->name);
			}
			$listsdrop[] = acymailing_selectOption('</OPTGROUP>');
		}
		
		$dates = array();
		$dates[] = acymailing_selectOption(0, acymailing_translation('SUBSCRIPTION_DATE'));
		$dates[] = acymailing_selectOption(1, acymailing_translation('UNSUBSCRIPTION_DATE'));

		$filter = '<div id="filter__num__list">'.$status->display("filter[__num__][list][status]", 1, false).' '.acymailing_select($listsdrop, "filter[__num__][list][selectedlist]", 'class="inputbox" style="max-width:200px" size="1" onchange="countresults(__num__)"', 'value', 'text');
		$filter .= '<br /><input type="text" name="filter[__num__][list][subdateinf]" onclick="displayDatePicker(this,event)" onchange="countresults(__num__)" style="width:60px;" /> < '.acymailing_select($dates, "filter[__num__][list][dates]", 'class="inputbox" style="max-width:200px" size="1" onchange="countresults(__num__)"', 'value', 'text').' < <input type="text" name="filter[__num__][list][subdatesup]" onclick="displayDatePicker(this,event)" onchange="countresults(__num__)" style="width:60px;" /></div>';
		return $filter;
	}

	function onAcyProcessFilter_list(&$query, $filter, $num){
		$otherconditions = '';
		$field = empty($filter['dates']) ? 'subdate' : 'unsubdate';
		if(!empty($filter['subdateinf'])){
			$filter['subdateinf'] = acymailing_replaceDate($filter['subdateinf']);
			if(!is_numeric($filter['subdateinf'])) $filter['subdateinf'] = strtotime($filter['subdateinf']);
			if(!empty($filter['subdateinf'])) $otherconditions .= ' AND list'.$num.'.'.$field.' > '.$filter['subdateinf'];
		}

		if(!empty($filter['subdatesup'])){
			$filter['subdatesup'] = acymailing_replaceDate($filter['subdatesup']);
			if(!is_numeric($filter['subdatesup'])) $filter['subdatesup'] = strtotime($filter['subdatesup']);
			if(!empty($filter['subdatesup'])) $otherconditions .= ' AND list'.$num.'.'.$field.' < '.$filter['subdatesup'];
		}

		$query->leftjoin['list'.$num] = '#__acymailing_listsub AS list'.$num.' ON sub.subid = list'.$num.'.subid AND list'.$num.'.listid = '.intval($filter['selectedlist']).$otherconditions;
		if($filter['status'] == -2){
			$query->where[] = 'list'.$num.'.listid IS NULL';
		}else{
			$query->where[] = 'list'.$num.'.status = '.intval($filter['status']);
		}
	}

	function onAcyProcessFilterCount_list(&$query, $filter, $num){
		$this->onAcyProcessFilter_list($query, $filter, $num);
		return acymailing_translation_sprintf('SELECTED_USERS', $query->count());
	}

	function onAcyProcessAction_list($cquery, $action, $num){
		$listid = intval($action['selectedlist']);
		$listClass = acymailing_get('class.list');
		if(is_numeric($action['selectedlist'])){
			$myList = $listClass->get($listid);
			if(empty($myList->listid)){
				return 'ERROR : List '.$listid.' not found';
			}

			if(empty($action['status'])){
				$query = 'DELETE listremove.* FROM '.acymailing_table('listsub').' AS listremove ';
				$query .= 'JOIN #__acymailing_subscriber AS sub ON listremove.subid = sub.subid ';
				if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
				if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);
				$query .= ' WHERE listremove.listid = '.$listid;
				if(!empty($cquery->where)) $query .= ' AND ('.implode(') AND (', $cquery->where).')';
			}elseif($action['status'] == -1){
				$query = 'UPDATE '.acymailing_table('listsub').' AS listsub'.$num.' JOIN '.acymailing_table('subscriber').' AS sub ON listsub'.$num.'.subid = sub.subid ';
				if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
				if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);
				$query .= ' SET listsub'.$num.'.status = -1, listsub'.$num.'.unsubdate = '.time().' WHERE listsub'.$num.'.listid = '.$listid;
				if(!empty($cquery->where)) $query .= ' AND ('.implode(') AND (', $cquery->where).')';
			}else{
				$query = 'INSERT IGNORE INTO '.acymailing_table('listsub').' (listid,subid,subdate,status) ';
				$query .= $cquery->getQuery(array($listid, 'sub.subid', time(), 1));
			}
			$nbsubscribed = acymailing_query($query);

			if(empty($action['status'])){
				return acymailing_translation_sprintf('IMPORT_REMOVE', $nbsubscribed, '<b><i>'.$myList->name.'</i></b>');
			}elseif($action['status'] == -1){
				return acymailing_translation_sprintf('NB_UNSUB_USERS', $nbsubscribed);
			}else{
				return acymailing_translation_sprintf('IMPORT_SUBSCRIBE_CONFIRMATION', $nbsubscribed, '<b><i>'.$myList->name.'</i></b>');
			}
		}

		$myList = $listClass->get($listid);
		if(empty($myList->listid)){
			return 'ERROR : List '.$listid.' not found';
		}
		if(empty($action['status'])){
			$query = 'SELECT listremove.`subid` FROM #__acymailing_listsub as listremove';
			$query .= ' JOIN #__acymailing_subscriber as sub ON listremove.subid = sub.subid ';
			$condition = ' WHERE listremove.listid = '.$listid;
		}elseif($action['status'] == -1){
			$query = 'SELECT listunsub.`subid` FROM #__acymailing_listsub as listunsub JOIN #__acymailing_subscriber as sub ON listunsub.subid = sub.subid ';
			$condition = ' WHERE listunsub.listid = '.$listid.' AND listunsub.status != -1';
		}else{
			$query = 'SELECT sub.`subid` FROM #__acymailing_subscriber as sub';
			$query .= ' LEFT JOIN #__acymailing_listsub as listsubscribe ON listsubscribe.subid = sub.subid AND listsubscribe.listid = '.$listid;
			$condition = ' WHERE listsubscribe.subid IS NULL';
		}
		if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
		if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);
		$query .= $condition;
		if(!empty($cquery->where)) $query .= ' AND ('.implode(') AND (', $cquery->where).')';
		if(!empty($cquery->orderBy)) $query .= ' ORDER BY '.$cquery->orderBy;
		if(!empty($cquery->limit)) $query .= ' LIMIT '.intval($cquery->limit);
		$subids = acymailing_loadResultArray($query);

		if(!empty($subids)){
			$listsubClass = acymailing_get('class.listsub');
			$time = time();
			$timeFunction = 'acymailing_getTime';
			if(!isset($action['sendhours']) || strlen($action['sendhours']) < 1){
				$action['sendhours'] = '%H';
				$timeFunction = 'strftime';
			}
			if(!isset($action['sendminutes']) || strlen($action['sendminutes']) < 1) $action['sendminutes'] = '%M';
			$format = '%Y-%m-%d '.$action['sendhours'].':'.$action['sendminutes'].':00';
			if($action['status'] == 1 && !empty($action['delaynum'])){
				$listsubClass->campaigndelay = $timeFunction(strftime($format, strtotime('+'.intval($action['delaynum']).' '.$action['delaytype'])));
			}else{
				$listsubClass->campaigndelay = $timeFunction(strftime($format, $time));
			}
			if($listsubClass->campaigndelay < $time){
				$listsubClass->campaigndelay = 0;
			}else $listsubClass->campaigndelay -= $time;

			if(!empty($action['skipedfollowups'])){
				$action['skipedfollowups'] = intval($action['skipedfollowups']);
				if(!empty($action['skipedfollowups'])) $listsubClass->skipedfollowups = $action['skipedfollowups'];
			}
			$listsubClass->checkAccess = false;
			$listsubClass->sendNotif = false;
			$listsubClass->sendConf = false;
			foreach($subids as $subid){
				if(empty($action['status'])){
					$listsubClass->removeSubscription($subid, array($listid));
				}elseif($action['status'] == -1) $listsubClass->updateSubscription($subid, array('-1' => array($listid)));
				else $listsubClass->addSubscription($subid, array('1' => array($listid)));
			}
		}

		$nbsubscribed = count($subids);
		if(empty($action['status'])){
			return acymailing_translation_sprintf('IMPORT_REMOVE', $nbsubscribed, '<b><i>'.$myList->name.'</i></b>');
		}elseif($action['status'] == -1){
			return acymailing_translation_sprintf('NB_UNSUB_USERS', $nbsubscribed);
		}else{
			return acymailing_translation_sprintf('IMPORT_SUBSCRIBE_CONFIRMATION', $nbsubscribed, '<b><i>'.$myList->name.'</i></b>');
		}
	}

	function acymailing_replaceusertags(&$email, &$user, $send = true){
		$this->_replacelisttags($email, $user, $send);

		if(empty($user->key) && !empty($user->subid)){
			$user->key = acymailing_generateKey(14);
			acymailing_query('UPDATE '.acymailing_table('subscriber').' SET `key`= '.acymailing_escapeDB($user->key).' WHERE subid = '.(int)$user->subid.' LIMIT 1');
		}

		if(!isset($user->key)) $user->key = '';

		if($this->unsubscribeLink && !$this->listunsubscribe && $this->params->get('listunsubscribe', 0) && method_exists($email, 'addCustomHeader')){
			$lang = empty($email->language) ? '' : '&lang='.$email->language;
			$myLink = 'index.php?subid='.intval($user->subid).'&option=com_acymailing&ctrl=user&task=out&mailid='.$email->mailid.'&key='.urlencode($user->key).$this->unsubscribeItem.$lang;
			
			$mainurl = acymailing_mainURL($myLink);
			$myLink = $mainurl.$myLink;
			if((bool)$this->params->get('unsubscribetemplate', false)) $myLink .= '&tmpl=component';

			$this->listunsubscribe = true;
			$mailto = $this->params->get('listunsubscribeemail');
			if(empty($mailto)) $mailto = @$email->replyemail;
			if(empty($mailto)){
				$config = acymailing_config();
				$mailto = $config->get('reply_email');
			}
			$email->addCustomHeader('List-Unsubscribe: <'.$myLink.'>, <mailto:'.$mailto.'?subject=unsubscribe_user_'.$user->subid.'&body=Please%20unsubscribe%20user%20ID%20'.$user->subid.'>');
		}
	}

	function acymailing_replacetags(&$email, $send = true){
		if(acymailing_getVar('none', 'task', '') == 'replacetags') return;
		
		$this->_replacesubscriptiontags($email);
		$this->_replacemailtags($email);
	}

	private function _replacemailtags(&$email){
		$variables = array('subject', 'body', 'altbody');
		$acypluginsHelper = acymailing_get('helper.acyplugins');
		$result = $acypluginsHelper->extractTags($email, 'mail');
		$tags = array();

		foreach($result as $key => $oneTag){
			$field = $oneTag->id;
			if(!empty($email) && !empty($email->$field)){
				$text = $email->$field;
				$acypluginsHelper->formatString($text, $oneTag);
				$tags[$key] = $text;
			}else{
				$tags[$key] = $oneTag->default;
			}
		}

		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$email->$var = str_replace(array_keys($tags), $tags, $email->$var);
		}
	}

	private function _replacelisttags(&$email, &$user, $send){
		if(!empty($email->ReplyTo)){
			$toDelete = 0;
			foreach($email->ReplyTo as $i => $replyto){
				if(trim($i) != '{list:members}') continue;
				$toDelete = $i;
				break;
			}
			if(!empty($toDelete)){
				unset($email->ReplyTo[$toDelete]);
				$acyConfig = acymailing_config();
				$listMembers = $this->loadlistmembers($email, $user);
				foreach($listMembers as $member){
					if($acyConfig->get('add_names', true) && !empty($member->name)){
						$replyToName = $email->cleanText(trim($member->name));
					}else{
						$replyToName = '';
					}
					$email->AddReplyTo($email->cleanText($member->email), $replyToName);
				}
			}
		}

		$this->acypluginsHelper = acymailing_get('helper.acyplugins');
		$tags = $this->acypluginsHelper->extractTags($email, 'list');
		if(empty($tags)) return;

		$replaceTags = array();
		foreach($tags as $oneTag => $parameter){
			$method = '_list'.trim(strtolower($parameter->id));

			if(method_exists($this, $method)){
				$replaceTags[$oneTag] = $this->$method($email, $user, $parameter);
			}else{
				$replaceTags[$oneTag] = 'Method not found : '.$method;
			}
		}

		$this->acypluginsHelper->replaceTags($email, $replaceTags, true);
	}

	private function _getattachedlistid($email, $subid){

		$mailid = $email->mailid;
		$type = strtolower($email->type);

		if(isset($this->lists[$mailid][$subid])) return $this->lists[$mailid][$subid];


		if($type == 'followup'){
			$listid = acymailing_loadResult('SELECT a.listid
							FROM #__acymailing_listsub AS a
							JOIN #__acymailing_listcampaign AS b
								ON a.listid = b.listid
							JOIN #__acymailing_listmail AS c
								ON b.campaignid = c.listid
							WHERE a.subid = '.intval($subid).'
								AND c.mailid = '.intval($mailid).'
							ORDER BY a.status DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}

		if(in_array($type, array('news', 'autonews'))){
			if(!empty($subid)){
				$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_listsub as a JOIN #__acymailing_listmail as b ON a.listid = b.listid WHERE a.subid = '.intval($subid).' AND b.mailid = '.intval($mailid).' ORDER BY a.status DESC LIMIT 1');
				if(!empty($listid)){
					$this->lists[$mailid][$subid] = $listid;
					return $listid;
				}
			}

			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_listmail as a JOIN #__acymailing_list as b ON a.listid = b.listid WHERE a.mailid = '.intval($mailid).' ORDER BY b.published DESC , b.visible DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}

		if($type == 'welcome' && !empty($subid)){
			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_list as a JOIN #__acymailing_listsub as b ON a.listid = b.listid WHERE a.welmailid = '.intval($mailid).' AND b.subid = '.intval($subid).' ORDER BY b.subdate DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}

		if($type == 'unsub' && !empty($subid)){
			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_list as a JOIN #__acymailing_listsub as b ON a.listid = b.listid WHERE a.unsubmailid = '.intval($mailid).' AND b.subid = '.intval($subid).' ORDER BY b.unsubdate DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}

		$allLists = array_merge(acymailing_getVar('array', 'subscription', '', ''), explode(',', acymailing_getVar('string', 'hiddenlists', '', '')));
		$data = acymailing_getVar('array', 'data', '', '');
		if(!empty($data['listsub'])){
			$allLists = array_merge($allLists, array_keys($data['listsub']));
		}

		if(!empty($allLists) && in_array($type, array('unsub', 'welcome'))){
			acymailing_arrayToInteger($allLists);
			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_list as a WHERE (a.welmailid = '.intval($mailid).' OR unsubmailid = '.intval($mailid).') AND listid IN ('.implode(',', $allLists).') ORDER BY a.published DESC, a.visible DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}

			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_list as a WHERE (a.welmailid = '.intval($mailid).' OR unsubmailid = '.intval($mailid).') ORDER BY a.published DESC, a.visible DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}

		if(!empty($allLists)){
			foreach($allLists as $listid){
				if(!empty($listid)){
					$this->lists[$mailid][$subid] = intval($listid);
					return intval($listid);
				}
			}
		}

		if(!empty($subid)){
			$listid = acymailing_loadResult('SELECT a.listid FROM #__acymailing_listsub as a JOIN #__acymailing_list as b ON a.listid = b.listid WHERE a.subid = '.intval($subid).' ORDER BY b.published DESC , b.visible DESC LIMIT 1');
			if(!empty($listid)){
				$this->lists[$mailid][$subid] = $listid;
				return $listid;
			}
		}
	}


	private function _listcount(&$email, &$user, &$parameter){
		if(!isset($parameter->listid)){
			$listid = $this->_getattachedlistid($email, $user->subid);
		}else{
			$listid = $parameter->listid;
		}

		if(empty($listid)){
			return acymailing_loadResult('SELECT COUNT(subid) FROM #__acymailing_subscriber');
		}else{
			return acymailing_loadResult('SELECT COUNT(subid) FROM #__acymailing_listsub WHERE listid = '.intval($listid).' AND status = 1');
		}
	}

	private function _listsubscription(&$email, &$user, &$parameter){
		if(empty($user->subid)) return "";
		$listSubClass = acymailing_get('class.listsub');
		return $listSubClass->getSubscriptionString($user->subid);
	}

	private function _listnames(&$email, &$user, &$parameter){
		if(empty($user->subid)) return "";
		$listSubClass = acymailing_get('class.listsub');
		$usersubscription = $listSubClass->getSubscription($user->subid);
		if(empty($usersubscription)){
			$subscribedLists = $this->_getFormListNames();
			if(empty($subscribedLists)) return '';
			return implode(isset($parameter->separator) ? $parameter->separator : ', ', $subscribedLists);
		}
		$lists = array();
		if(!empty($usersubscription)){
			foreach($usersubscription as $onesub){
				if($onesub->status < 1 || empty($onesub->published)) continue;
				$lists[] = $onesub->name;
			}
		}
		return implode(isset($parameter->separator) ? $parameter->separator : ', ', $lists);
	}


	private function _getFormListNames(){
		$allLists = array_merge(acymailing_getVar('array', 'subscription', '', ''), explode(',', acymailing_getVar('string', 'hiddenlists', '', '')));
		$data = acymailing_getVar('array', 'data', '', '');
		if(!empty($data['listsub'])){
			foreach($data['listsub'] as $i => $oneList){
				if($oneList['status'] != 1) unset($data['listsub'][$i]);
			}
			$allLists = array_merge($allLists, array_keys($data['listsub']));
		}
		if(empty($allLists)) return array();

		acymailing_arrayToInteger($allLists);
		foreach($allLists as $i => $oneList){
			if(empty($oneList)) unset($allLists[$i]);
		}
		if(empty($allLists)) return array();

		return acymailing_loadResultArray('SELECT name FROM #__acymailing_list WHERE listid IN ('.implode(',', $allLists).')');
	}

	private function _listowner(&$email, &$user, &$parameter){
		if(empty($user->subid)) return '';
		$listid = $this->_getattachedlistid($email, $user->subid);
		if(empty($listid)) return "";

		if(!isset($this->listsowner[$listid])){
			$this->listsowner[$listid] = acymailing_loadObject('SELECT u.* FROM #__acymailing_list as list JOIN #__users as u ON u.id = list.userid WHERE list.listid = '.intval($listid));
		}

		if(!in_array($parameter->field, array('username', 'name', 'email'))) return 'Field not found : '.$parameter->field;
		return @$this->listsowner[$listid]->{$parameter->field};
	}

	private function _loadlist($listid){
		if(isset($this->listsinfo[$listid])) return;

		$this->listsinfo[$listid] = acymailing_loadObject('SELECT * FROM #__acymailing_list WHERE listid = '.intval($listid));
	}

	private function _listname(&$email, &$user, &$parameter){
		if(empty($user->subid)) return '';
		$listid = $this->_getattachedlistid($email, $user->subid);
		if(empty($listid)) return "No list => no name!";

		$this->_loadlist($listid);

		return @$this->listsinfo[$listid]->name;
	}

	private function _listdescription(&$email, &$user, &$parameter){
		if(empty($user->subid)) return '';
		$listid = $this->_getattachedlistid($email, $user->subid);
		if(empty($listid)) return "No list => no description!";

		$this->_loadlist($listid);

		return @$this->listsinfo[$listid]->description;
	}

	private function _listid(&$email, &$user, &$parameter){
		if(empty($user->subid)) return '';
		$listid = $this->_getattachedlistid($email, $user->subid);
		if(empty($listid)) return "No list => no ID!";

		return $listid;
	}

	private function loadlistmembers(&$email, &$user){
		if(empty($user->subid)) return '';
		$listid = $this->_getattachedlistid($email, $user->subid);
		if(empty($listid)) return array();

		return acymailing_loadObjectList('SELECT s.email, s.name FROM #__acymailing_listsub AS l JOIN #__acymailing_subscriber AS s ON s.subid=l.subid WHERE l.listid='.intval($listid).' AND l.status=1 AND s.enabled=1 AND s.accept=1');
	}

	private function _replacesubscriptiontags(&$email){
		$match = '#(?:{|%7B)(modify[^}]*|confirm[^}]*|unsubscribe(?:\|[^}]*)?|subscribe[^}]*)(?:}|%7D)(.*)(?:{|%7B)/(modify|confirm|unsubscribe|subscribe)(?:}|%7D)#Uis';
		$variables = array('subject', 'body', 'altbody');
		$found = false;
		$results = array();
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found) return;

		$tags = array();
		$this->listunsubscribe = false;
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($tags[$oneTag])) continue;
				$tags[$oneTag] = $this->replaceSubscriptionTag($allresults, $i, $email);
			}
		}

		foreach(array_keys($results) as $var){
			$email->$var = str_replace(array_keys($tags), $tags, $email->$var);
		}
	}

	function replaceSubscriptionTag(&$allresults, $i, &$email){
		$config = acymailing_config();
		$lang = empty($email->language) ? '' : '&lang='.$email->language;

		$parameters = $this->acypluginsHelper->extractTag($allresults[1][$i]);
		$itemId = $this->params->get(strtolower($parameters->id).'itemid', $config->get('itemid', 0));
		$itemId = empty($parameters->itemid) ? $itemId : intval($parameters->itemid);
		$item = empty($itemId) ? '' : '&Itemid='.$itemId;

		if($parameters->id == 'confirm'){ //confirm your subscription link
			$myLink = acymailing_frontendLink('index.php?subid={subtag:subid}&option=com_acymailing&ctrl=user&task=confirm&key={subtag:key|urlencode}'.$item.$lang, true, (bool)$this->params->get('confirmtemplate', false));
			if(empty($allresults[2][$i])) return $myLink;
			return '<a target="_blank" href="'.$myLink.'">'.$allresults[2][$i].'</a>';
		}elseif($parameters->id == 'modify'){ //modify your subscription link
			$myLink = acymailing_frontendLink('index.php?subid={subtag:subid}&option=com_acymailing&ctrl=user&task=modify&key={subtag:key|urlencode}'.$item.$lang, true, (bool)$this->params->get('modifytemplate', false));
			if(empty($allresults[2][$i])) return $myLink;
			return '<a style="text-decoration:none;" target="_blank" href="'.$myLink.'"><span class="acymailing_modify">'.$allresults[2][$i].'</span></a>';
		}elseif($parameters->id == 'subscribe'){ //add a direct subscription link
			if(empty($parameters->lists)) return 'You must select at least one list';
			$lists = explode(',', $parameters->lists);
			acymailing_arrayToInteger($lists);
			$captchaKey = $config->get('captcha_enabled') ? '&seckey='.$config->get('security_key', '') : '';
			$myLink = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=sub&task=optin&hiddenlists='.implode(',', $lists).'&user[email]={subtag:email|urlencode}'.$item.$lang.$captchaKey);
			if(empty($allresults[2][$i])) return $myLink;
			return '<a style="text-decoration:none;" target="_blank" href="'.$myLink.'"><span class="acymailing_sub">'.$allresults[2][$i].'</span></a>';
		}//unsubscribe link
		$myLink = acymailing_frontendLink('index.php?subid={subtag:subid}&option=com_acymailing&ctrl=user&task=out&mailid='.$email->mailid.'&key={subtag:key|urlencode}'.$item.$lang, true, (bool)$this->params->get('unsubscribetemplate', false));

		$this->unsubscribeLink = true;
		$this->unsubscribeItem = $item;

		if(empty($allresults[2][$i])) return $myLink;
		return '<a style="text-decoration:none;" target="_blank" href="'.$myLink.'"><span class="acymailing_unsub">'.$allresults[2][$i].'</span></a>';
	}
}//endclass
tagsubscription/tagsubscription.xml000060400000013625152455610250013736 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : Manage the Subscription</name>
	<creationDate>March 2018</creationDate>
	<version>5.9.6</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add link to manage the subscription of the user</description>
	<files>
		<filename plugin="tagsubscription">tagsubscription.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagsubscription"/>
		<param name="unsubscribetemplate" type="radio" default="0" label="Display the unsubscribe page" description="Select if you want to display the unsubscribe page (when the user clicks on the unsubscribe link) without any Joomla module (no template) or inside your default Joomla Template">
			<option value="0">Standard template</option>
			<option value="1">No template</option>
		</param>
		<param name="listunsubscribe" type="radio" default="0" label="Add list-unsubscribe header" description="If you insert an unsubscribe link, should Acy also insert the link in the list-unsubscribe field? See www.list-unsubscribe.com">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
		<param name="listunsubscribeemail" type="text" size="20" default="" label="List-unsubscribe e-mail" description="The GMail feedback loops works with a list-unsubscribe e-mail address. By default Acy will add the reply-to e-mail address but you can specify another e-mail address there" />
		<param name="modifytemplate" type="radio" default="0" label="Display the modify your subscription" description="Select if you want to display the modify your subscription page (when the user clicks on the modify you subscription link) without any Joomla module (no template) or inside your default Joomla Template">
			<option value="0">Standard template</option>
			<option value="1">No template</option>
		</param>
		<param name="confirmtemplate" type="radio" default="0" label="Display the confirmation page" description="Select if you want to display the confirmation page (when the user clicks on the confirmation link) without any Joomla module (no template) or inside your default Joomla Template">
			<option value="0">Standard template</option>
			<option value="1">No template</option>
		</param>
		<param name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the subscription filter on the Newsletter creation interface">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagsubscription"/>
				<field name="unsubscribetemplate" type="radio" default="0" label="Display the unsubscribe page" description="Select if you want to display the unsubscribe page (when the user clicks on the unsubscribe link) without any Joomla module (no template) or inside your default Joomla Template">
					<option value="0">Standard template</option>
					<option value="1">No template</option>
				</field>
				<field name="listunsubscribe" type="radio" default="0" label="Add list-unsubscribe header" description="If you insert an unsubscribe link, should Acy also insert the link in the list-unsubscribe field? See www.list-unsubscribe.com">
					<option value="0">JOOMEXT_NO</option>
					<option value="1">JOOMEXT_YES</option>
				</field>
				<field name="listunsubscribeemail" type="text" size="20" default="" label="List-unsubscribe e-mail" description="The GMail feedback loops works with a list-unsubscribe e-mail address. By default Acy will add the reply-to e-mail address but you can specify another e-mail address there" />
				<field name="modifytemplate" type="radio" default="0" label="Display the modify your subscription" description="Select if you want to display the modify your subscription page (when the user clicks on the modify you subscription link) without any Joomla module (no template) or inside your default Joomla Template">
					<option value="0">Standard template</option>
					<option value="1">No template</option>
				</field>
				<field name="confirmtemplate" type="radio" default="0" label="Display the confirmation page" description="Select if you want to display the confirmation page (when the user clicks on the confirmation link) without any Joomla module (no template) or inside your default Joomla Template">
					<option value="0">Standard template</option>
					<option value="1">No template</option>
				</field>
				<field name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the subscription filter on the Newsletter creation interface">
					<option value="0">JOOMEXT_NO</option>
					<option value="1">JOOMEXT_YES</option>
				</field>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
tagsubscription/index.html000060400000000054152455610250011761 0ustar00<html><body bgcolor="#FFFFFF"></body></html>index.html000060400000000054152455610250006541 0ustar00<html><body bgcolor="#FFFFFF"></body></html>online/online.php000060400000013366152455610250010037 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingOnline extends JPlugin{
	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'online');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){

		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('WEBSITE_LINKS');
		$onePlugin->function = 'acymailingtagonline_show';
		$onePlugin->help = 'plugin-online';

		return $onePlugin;
	}

	function acymailingtagonline_show(){

		$others = array();
		$config = acymailing_config();
		$others['readonline'] = array('default' => acymailing_translation('VIEW_ONLINE', true), 'desc' => acymailing_translation('VIEW_ONLINE_LINK'));
		if($config->get('forward', true)){
			$others['forward'] = array('default' => acymailing_translation('FORWARD_FRIEND', true), 'desc' => acymailing_translation('FORWARD_FRIEND_LINK'));
		}

		?>
		<script language="javascript" type="text/javascript">
			<!--
			var selectedTag = '';
			function changeTag(tagName){
				selectedTag = tagName;
				defaultText = new Array();
				<?php
								$k = 0;
								foreach($others as $tagname => $tag){
									echo "document.getElementById('tr_$tagname').className = 'row$k';";
									echo "defaultText['$tagname'] = '".$tag['default']."';";
								}
								$k = 1-$k;
				?>
				document.getElementById('tr_' + tagName).className = 'selectedrow';
				document.adminForm.tagtext.value = defaultText[tagName];
				setOnlineTag();
			}

			function setOnlineTag(){
				if(!selectedTag) changeTag('readonline');
				otherinfo = '';
				for(var i = 0; i < document.adminForm.template.length; i++){
					if(document.adminForm.template[i].checked){
						otherinfo += '|template:' + document.adminForm.template[i].value;
					}
				}
				setTag('<a href=' + '"{' + selectedTag + otherinfo + '}{/' + selectedTag + '}" target="_blank" style="text-decoration:none;"><span class="acymailing_online">' + document.adminForm.tagtext.value + '</span></a>');
			}
			//-->
		</script>
		<?php
		echo acymailing_translation('FIELD_TEXT').' : <input type="text" name="tagtext" size="100px" onchange="setOnlineTag();" /><br /><br />';
		$radios = array();
		$radios[] = acymailing_selectOption("standard", acymailing_translation('IN_TEMPLATE'));
		$radios[] = acymailing_selectOption("notemplate", acymailing_translation('WITHOUT_TEMPLATE'));
		echo acymailing_radio($radios, 'template', 'size="1" onclick="setOnlineTag();"', 'value', 'text', 'notemplate');
		echo '<div class="onelineblockoptions">
				<table class="acymailing_table" cellpadding="1">';
		$k = 0;
		foreach($others as $tagname => $tag){
			echo '<tr style="cursor:pointer" class="row'.$k.'" onclick="changeTag(\''.$tagname.'\');" id="tr_'.$tagname.'" ><td class="acytdcheckbox" ></td><td>'.$tag['desc'].'</td></tr>';
			$k = 1 - $k;
		}
		echo '</table></div>';
	}

	function acymailing_replacetags(&$email, $send = true){
		if(acymailing_getVar('none', 'task', '') == 'replacetags') return;

		$match = '#(?:{|%7B)(readonline|forward)([^}]*)(?:}|%7D)(.*)(?:{|%7B)/(readonline|forward)(?:}|%7D)#Uis';
		$variables = array('body', 'altbody');
		$found = false;
		$results = array();
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found) return;

		$config = acymailing_config();

		$tags = array();

		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($tags[$oneTag])) continue;
				$arguments = explode('|', strip_tags(str_replace('%7C', '|', $allresults[2][$i])));
				$tag = new stdClass();
				$tag->type = $allresults[1][$i];
				$tag->template = ($tag->type == 'readonline') ? $this->params->get('viewtemplate', 'notemplate') : $this->params->get('forwardtemplate', 'notemplate');
				$tag->itemid = $config->get('itemid', 0);
				for($j = 0, $a = count($arguments); $j < $a; $j++){
					$args = explode(':', $arguments[$j]);
					$arg0 = trim($args[0]);
					if(empty($arg0)) continue;
					if(isset($args[1])){
						$tag->$arg0 = $args[1];
					}else{
						$tag->$arg0 = true;
					}
				}

				$addkey = (!empty($email->key) && $this->params->get('addkey', 'yes') == 'yes') ? '&key='.$email->key : '';
				$adduserkey = $this->params->get('adduserkey', 'yes') == 'yes' ? '&subid={subtag:subid}-{subtag:key}' : '';
				$tmpl = ($tag->template == 'notemplate') ? '&tmpl=component' : '';
				$item = empty($tag->itemid) ? '' : '&Itemid='.$tag->itemid;
				$lang = empty($email->language) ? '' : '&lang='.$email->language;

				if($tag->type == 'readonline'){
					$link = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid='.$email->mailid.$addkey.$adduserkey.$tmpl.$item.$lang);
				}elseif($tag->type == 'forward'){
					$link = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=archive&task=forward&mailid='.$email->mailid.$addkey.$adduserkey.$tmpl.$item.$lang);
				}

				if(empty($allresults[3][$i])){
					$tags[$oneTag] = $link;
				}else $tags[$oneTag] = '<a style="text-decoration:none;" href="'.$link.'"><span class="acymailing_online">'.$allresults[3][$i].'</span></a>';
			}
		}

		$email->body = str_replace(array_keys($tags), $tags, $email->body);
		if(!empty($email->altbody)) $email->altbody = str_replace(array_keys($tags), $tags, $email->altbody);
	}
}//endclass
online/online.xml000060400000010346152455610250010043 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : Website links</name>
	<creationDate>September 2009</creationDate>
	<version>3.7.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add links in your Newsletter such as "read in your browser" or "forward to a friend"</description>
	<files>
		<filename plugin="online">online.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-online"/>
		<param name="addkey" type="radio" default="yes" label="Add Newsletter key" description="Add the Newsletter key in the link so the online version will be always accessible from the link inserted in the Newsletter">
			<option value="yes">Yes</option>
			<option value="no">No</option>
		</param>
		<param name="adduserkey" type="radio" default="yes" label="Add User key" description="Add the user key in the link so the online version will contain the personal information as well">
			<option value="yes">Yes</option>
			<option value="no">No</option>
		</param>
		<param name="viewtemplate" type="radio" default="notemplate" label="Display the online version - DEPRECATED" description="This option is not useful any more, please use the option when inserting the tag instead">
			<option value="standard">Standard template</option>
			<option value="notemplate">No template</option>
		</param>
		<param name="forwardtemplate" type="radio" default="notemplate" label="Display the forward version - DEPRECATED" description="This option is not useful any more, please use the option when inserting the tag instead">
			<option value="standard">Standard template</option>
			<option value="notemplate">No template</option>
		</param>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-online"/>
				<field name="addkey" type="radio" default="yes" label="Add Newsletter key" description="Add the Newsletter key in the link so the online version will be always accessible from the link inserted in the Newsletter">
					<option value="yes">Yes</option>
					<option value="no">No</option>
				</field>
				<field name="adduserkey" type="radio" default="yes" label="Add User key" description="Add the user key in the link so the online version will contain the personal information as well">
					<option value="yes">Yes</option>
					<option value="no">No</option>
				</field>
				<field name="viewtemplate" type="radio" default="notemplate" label="Display the online version - DEPRECATED" description="This option is not useful any more, please use the option when inserting the tag instead">
					<option value="standard">Standard template</option>
					<option value="notemplate">No template</option>
				</field>
				<field name="forwardtemplate" type="radio" default="notemplate" label="Display the forward version - DEPRECATED" description="This option is not useful any more, please use the option when inserting the tag instead">
					<option value="standard">Standard template</option>
					<option value="notemplate">No template</option>
				</field>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
online/index.html000060400000000054152455610250010025 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tablecontents/index.html000060400000000054152455610250011406 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tablecontents/tablecontents.php000060400000021112152455610250012765 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php
defined('_JEXEC') or die('Restricted access');

class plgAcymailingTablecontents extends JPlugin{

	var $noResult = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tablecontents');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('ACY_TABLECONTENTS');
		$onePlugin->function = 'acymailingtablecontents_show';
		$onePlugin->help = 'plugin-tablecontents';

		return $onePlugin;
	}

	function acymailingtablecontents_show(){

		$contenttype = array();
		$contenttype[] = acymailing_selectOption('', acymailing_translation('ACY_EXISTINGANCHOR'));
		for($i = 1; $i < 6; $i++){
			$contenttype[] = acymailing_selectOption("|type:h".$i, 'H'.$i);
		}
		$contenttype[] = acymailing_selectOption('class', acymailing_translation('CLASS_NAME'));

		$contentsubtype = array();
		$contentsubtype[] = acymailing_selectOption('', acymailing_translation('ACY_NONE'));
		for($i = 1; $i < 6; $i++){
			$contentsubtype[] = acymailing_selectOption("|subtype:h".$i, 'H'.$i);
		}
		$contentsubtype[] = acymailing_selectOption('class', acymailing_translation('CLASS_NAME'));

		?>

		<script language="javascript" type="text/javascript">
			<!--
			function updateTag(){
				var tag = '{tableofcontents';
				if(document.adminForm.contenttype.value){
					if(document.adminForm.contenttype.value == 'class'){
						document.adminForm.classvalue.style.display = '';
						tag += '|class:' + document.adminForm.classvalue.value;
					}else{
						document.adminForm.classvalue.style.display = 'none';
						tag += document.adminForm.contenttype.value;
					}
				}
				if(document.adminForm.contentsubtype.value){
					if(document.adminForm.contentsubtype.value == 'class'){
						document.adminForm.subclassvalue.style.display = '';
						tag += '|subclass:' + document.adminForm.subclassvalue.value;
					}else{
						document.adminForm.subclassvalue.style.display = 'none';
						tag += document.adminForm.contentsubtype.value;
					}
				}
				tag += '}';

				setTag(tag);
			}
			//-->
		</script>
		<div class="onelineblockoptions">
			<span class="acyblocktitle"><?php echo acymailing_translation('ACY_GENERATEANCHOR'); ?></span>
			<table width="100%" class="acymailing_table">
				<tr>
					<td><?php echo acymailing_translation_sprintf('ACY_LEVEL', 1)?></td>
					<td><?php echo acymailing_select($contenttype, 'contenttype', 'size="1" onchange="updateTag();"', 'value', 'text'); ?><input type="text" style="display:none" onchange="updateTag();" name="classvalue"/></td>
				</tr>
				<tr>
					<td><?php echo acymailing_translation_sprintf('ACY_LEVEL', 2)?></td>
					<td><?php echo acymailing_select($contentsubtype, 'contentsubtype', 'size="1" onchange="updateTag();"', 'value', 'text'); ?><input type="text" style="display:none" onchange="updateTag();" name="subclassvalue"/></td>
				</tr>
			</table>
		</div>
		<?php
		acymailing_addScript(true, "document.addEventListener(\"DOMContentLoaded\", function(){ updateTag(); });");
	}


	function acymailing_replaceusertags(&$email, &$user, $send = true){

		if(isset($this->noResult[intval($email->mailid)])) return;

		$match = '#{tableofcontents(.*)}#Ui';

		$variables = array('subject', 'body', 'altbody');

		$found = false;
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found){
			$this->noResult[intval($email->mailid)] = true;
			return;
		}

		$mailerHelper = acymailing_get('helper.mailer');

		$htmlreplace = array();
		$textreplace = array();
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($htmlreplace[$oneTag])) continue;

				$article = $this->_generateTable($allresults, $i, $email);
				$htmlreplace[$oneTag] = $article;
				$textreplace[$oneTag] = $mailerHelper->textVersion($article);
				$subjectreplace[$oneTag] = strip_tags($article);
			}
		}
		$email->body = str_replace(array_keys($htmlreplace), $htmlreplace, $email->body);
		$email->altbody = str_replace(array_keys($textreplace), $textreplace, $email->altbody);
		$email->subject = str_replace(array_keys($subjectreplace), $subjectreplace, $email->subject);
	}

	function _generateTable(&$results, $i, &$email){

		$arguments = explode('|', strip_tags($results[1][$i]));
		$tag = new stdClass();
		$tag->divider = $this->params->get('divider', 'br');
		$tag->before = '';
		$tag->after = '';
		$tag->subdivider = $this->params->get('divider', 'br');
		$tag->subbefore = '';
		$tag->subafter = '';
		for($i = 1, $a = count($arguments); $i < $a; $i++){
			$args = explode(':', $arguments[$i]);
			if(isset($args[1])){
				$tag->{$args[0]} = $args[1];
			}else{
				$tag->{$args[0]} = true;
			}
		}

		if($tag->divider == 'br'){
			$tag->divider = '<br />';
			$tag->subbefore = $tag->subdivider = '<br /> - ';
		}elseif($tag->divider == 'space'){
			$tag->subdivider = ', ';
			$tag->divider = ' ';
			$tag->subbefore = ' ( ';
			$tag->subafter = ' ) ';
		}elseif($tag->divider == 'li'){
			$tag->subdivider = $tag->divider = '</li><li>';
			$tag->subbefore = $tag->before = '<ul><li>';
			$tag->subafter = $tag->after = '</li></ul>';
		}

		$this->updateMail = array();
		$this->links = array();
		$this->sublinks = array();
		$anchorLinks = $this->_findLinks($tag, $email);
		if(!empty($tag->subtype) || !empty($tag->subclass)){
			$anchorSubLinks = $this->_findLinks($tag, $email, true);
			if(empty($this->links)){
				$this->links = $this->sublinks;
				unset($this->sublinks);
			}
		}

		$links = $this->links;
		if(!empty($tag->limit)){
			$links = array_slice($links, 0, $tag->limit);
		}

		if(empty($links)) return '';
		if(!empty($this->updateMail)) $email->body = str_replace(array_keys($this->updateMail), $this->updateMail, $email->body);

		if(!empty($this->sublinks)){
			$sublinks = $this->sublinks;
			foreach($links as $ilink => $oneLink){
				$allsublinks = array();
				$from = $anchorLinks['pos'][$ilink];
				$to = empty($anchorLinks['pos'][$ilink + 1]) ? 9999999999999 : $anchorLinks['pos'][$ilink + 1];
				foreach($sublinks as $isublink => $oneSubLink){
					if($anchorSubLinks['pos'][$isublink] > $to) break;
					if($anchorSubLinks['pos'][$isublink] > $from) $allsublinks[] = $oneSubLink;
				}
				if(!empty($allsublinks)) $links[$ilink] = $links[$ilink].$tag->subbefore.implode($tag->subdivider, $allsublinks).$tag->subafter;
			}
		}

		$result = '<div class="tableofcontents">'.$tag->before.implode($tag->divider, $links).$tag->after.'</div>';
		if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'tablecontents.php')){
			ob_start();
			require(ACYMAILING_MEDIA.'plugins'.DS.'tablecontents.php');
			$result = ob_get_clean();
		}
		return $result;
	}

	function _findLinks(&$tag, &$email, $sub = false){
		if($sub){
			$varType = 'subtype';
			$varClass = 'subclass';
			$varLink = &$this->sublinks;
		}else{
			$varType = 'type';
			$varClass = 'class';
			$varLink = &$this->links;
		}
		if(!empty($tag->$varType)){
			preg_match_all('#<'.$tag->$varType.'[^>]*>((?!</ *'.$tag->$varType.'>).)*</ *'.$tag->$varType.'>#Uis', $email->body, $anchorresults);
		}elseif(!empty($tag->class)){
			preg_match_all('#<[^>]*class="'.$tag->$varClass.'"[^>]*>(<[^>]*>|[^<>])*</.*>#Uis', $email->body, $anchorresults);
			$tag->$varType = 'item';
		}else{
			preg_match_all('#<a[^>]*name="([^">]*)"[^>]*>((?!</ *a>).)*</ *a>#Uis', $email->body, $anchorresults);
		}

		if(empty($anchorresults)) return '';


		foreach($anchorresults[0] as $i => $oneContent){
			$anchorresults['pos'][$i] = strpos($email->body, $oneContent);
			$linktext = strip_tags($oneContent);
			if(empty($linktext)) continue;
			if(empty($tag->$varType)){
				$varLink[$i] = '<a href="#'.$anchorresults[1][$i].'" class="oneitem" >'.$linktext.'</a>';
			}else{
				$varLink[$i] = '<a href="#'.$tag->$varType.$i.'" class="oneitem oneitem'.$tag->$varType.'" >'.$linktext.'</a>';
				if(preg_match('#<a[^>]*>[^<]*'.preg_quote($oneContent, '#').'#Uis', $email->body, $linkBefore)){
					$this->updateMail[$linkBefore[0]] = '<a name="'.$tag->$varType.$i.'"></a>'.$linkBefore[0];
				}else{
					$this->updateMail[$oneContent] = '<a name="'.$tag->$varType.$i.'"></a>'.$oneContent;
				}
			}
		}

		return $anchorresults;
	}
}//endclass
tablecontents/tablecontents.xml000060400000003220152455610250012776 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing table of contents generator</name>
	<creationDate>January 2011</creationDate>
	<version>1.0.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to generate table of contents</description>
	<files>
		<filename plugin="tablecontents">tablecontents.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tablecontents"/>
		<param name="divider" type="radio" default="br" label="Divider" description="Separator added between each link">
			<option value="br">Carriage return</option>
			<option value="space">Space</option>
			<option value="li">ul / li</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tablecontents"/>
				<field name="divider" type="radio" default="br" label="Divider" description="Separator added between each link">
					<option value="br">Carriage return</option>
					<option value="space">Space</option>
					<option value="li">ul / li</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
managetext/managetext.php000060400000032512152455610250011553 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php
defined('_JEXEC') or die('Restricted access');

class plgAcymailingManagetext extends JPlugin{
	var $foundtags = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'managetext');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_replacetags(&$email, $send = true){
		$this->_replaceConstant($email);
		$this->_replaceRandom($email);
	}

	function acymailing_replaceusertags(&$email, &$user, $send = true){
		$this->_removetext($email);
		$this->_addfooter($email);
		$this->_ifstatement($email, $user);
	}

	private function _replaceConstant(&$email){
		$acypluginsHelper = acymailing_get('helper.acyplugins');
		$tags = $acypluginsHelper->extractTags($email, '(?:const|trans|config)');
		if(empty($tags)) return;

		$jconfig = JFactory::getConfig();

		$tagsReplaced = array();
		foreach($tags as $i => $oneTag){
			$val = '';
			$arrayVal = array();
			foreach($oneTag as $valname => $oneValue){
				if($valname == 'id'){
					$val = trim(strip_tags($oneValue));
				}elseif($valname != 'default'){
					$arrayVal[] = '{'.$valname.'}';
				}
			}

			if(empty($val)) continue;
			$tagValues = explode(':', $i);
			$type = ltrim($tagValues[0], '{');
			if($type == 'const'){
				$tagsReplaced[$i] = defined($val) ? constant($val) : 'Constant not defined : '.$val;
			}elseif($type == 'config'){
				if($val == 'sitename'){
					$tagsReplaced[$i] = ACYMAILING_J30 ? $jconfig->get($val) : $jconfig->getValue('config.'.$val);
				}
			}else{
				static $done = false;
				if(!$done){
					$done = true;
					acymailing_loadLanguageFile('com_users', JPATH_SITE);
					acymailing_loadLanguageFile('com_users', JPATH_ADMINISTRATOR);
					acymailing_loadLanguageFile('plg_user_joomla', JPATH_ADMINISTRATOR);
				}
				if(!empty($arrayVal)){
					$tagsReplaced[$i] = nl2br(vsprintf(acymailing_translation($val), $arrayVal));
				}else{
					$tagsReplaced[$i] = acymailing_translation($val);
				}
			}
		}

		$acypluginsHelper->replaceTags($email, $tagsReplaced, true);
	}

	private function _replaceRandom(&$email){
		$pluginHelper = acymailing_get('helper.acyplugins');
		$randTag = $pluginHelper->extractTags($email, "rand");
		if(empty($randTag)) return;
		foreach($randTag as $oneRandTag){
			$results[$oneRandTag->id] = explode(';', $oneRandTag->id);
			$randNumber = rand(0, count($results[$oneRandTag->id]) - 1);
			$results[$oneRandTag->id][count($results[$oneRandTag->id])] = $results[$oneRandTag->id][$randNumber];
		}

		$tags = array();
		foreach(array_keys($results) as $oneResult){
			$tags['{rand:'.$oneResult.'}'] = end($results[$oneResult]);
		}

		if(empty($tags)) return;
		$pluginHelper->replaceTags($email, $tags, true);
	}


	private function _ifstatement(&$email, $user, $loop = 1){
		if(isset($this->noIfStatementTags[$email->mailid])) return;

		$isAdmin = JFactory::getApplication()->isAdmin();

		if($loop > 3){
			if($isAdmin) acymailing_display('You cannot have more than 3 nested {if} tags.', 'warning');
			return;
		}

		$match = '#{if:(((?!{if).)*)}(((?!{if).)*){/if}#Uis';
		$variables = array('subject', 'body', 'altbody', 'From', 'FromName', 'ReplyTo');
		$found = false;
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			if(is_array($email->$var)){
				foreach($email->$var as $i => &$arrayField){
					if(empty($arrayField) || !is_array($arrayField)) continue;
					foreach($arrayField as $key => &$oneval){
						$found = preg_match_all($match, $oneval, $results[$var.$i.'-'.$key]) || $found;
						if(empty($results[$var.$i.'-'.$key][0])) unset($results[$var.$i.'-'.$key]);
					}
				}
			}else{
				$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
				if(empty($results[$var][0])) unset($results[$var]);
			}
		}

		if(!$found){
			if($loop == 1) $this->noIfStatementTags[$email->mailid] = true;
			return;
		}

		static $a = false;

		$tags = array();
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($tags[$oneTag])) continue;
				$allresults[1][$i] = html_entity_decode($allresults[1][$i]);
				if(!preg_match('#^(.+)(!=|<|>|&gt;|&lt;|!~)([^=!<>~]+)$#is', $allresults[1][$i], $operators) && !preg_match('#^(.+)(=|~)([^=!<>~]+)$#is', $allresults[1][$i], $operators)){
					if($isAdmin) acymailing_display('Operation not found : '.$allresults[1][$i], 'error');
					$tags[$oneTag] = $allresults[3][$i];
					continue;
				};
				$field = trim($operators[1]);
				$prop = '';

				$operatorsParts = explode('.', $operators[1]);
				$operatorComp = 'acymailing';
				if(count($operatorsParts) > 1 && in_array($operatorsParts[0], array('acymailing', 'joomla', 'var'))){
					$operatorComp = $operatorsParts[0];
					unset($operatorsParts[0]);
					$field = implode('.', $operatorsParts);
				}
				
				if($operatorComp == 'joomla'){
					if(!empty($user->userid)){
						if($field == 'gid' && ACYMAILING_J16){
							$prop = implode(';', acymailing_loadResultArray('SELECT group_id FROM #__user_usergroup_map WHERE user_id = '.intval($user->userid)));
						}else{
							$juser = acymailing_loadObject('SELECT * FROM #__users WHERE id = '.intval($user->userid));
							if(isset($juser->{$field})){
								$prop = strtolower($juser->{$field});
							}else{
								if($isAdmin && !$a) acymailing_display('User variable not set : '.$field.' in '.$allresults[1][$i], 'error');
								$a = true;
							}
						}
					}
				}elseif($operatorComp == 'var'){
					$prop = strtolower($field);
				}else{
					if(!isset($user->{$field})){
						if($isAdmin && !$a) acymailing_display('User variable not set : '.$field.' in '.$allresults[1][$i], 'error');
						$a = true;
					}else{
						$prop = strtolower($user->{$field});
					}
				}

				$tags[$oneTag] = '';
				$val = trim(strtolower($operators[3]));
				if($operators[2] == '=' && ($prop == $val || in_array($prop, explode(';', $val)) || in_array($val, explode(';', $prop)))){
					$tags[$oneTag] = $allresults[3][$i];
				}elseif($operators[2] == '!=' && $prop != $val){
					$tags[$oneTag] = $allresults[3][$i];
				}elseif(($operators[2] == '>' || $operators[2] == '&gt;') && $prop > $val){
					$tags[$oneTag] = $allresults[3][$i];
				}elseif(($operators[2] == '<' || $operators[2] == '&lt;') && $prop < $val){
					$tags[$oneTag] = $allresults[3][$i];
				}elseif($operators[2] == '~' && strpos($prop, $val) !== false){
					$tags[$oneTag] = $allresults[3][$i];
				}elseif($operators[2] == '!~' && strpos($prop, $val) === false){
					$tags[$oneTag] = $allresults[3][$i];
				}
			}
		}

		foreach($variables as &$var){
			if(empty($email->$var)) continue;
			if(is_array($email->$var)){
				foreach($email->$var as &$arrayField){
					if(empty($arrayField) || !is_array($arrayField)) continue;
					foreach($arrayField as &$oneval){
						$oneval = str_replace(array_keys($tags), $tags, $oneval);
					}
				}
			}else{
				$email->$var = str_replace(array_keys($tags), $tags, $email->$var);
			}
		}
		$this->_ifstatement($email, $user, $loop + 1);
	}

	private function _removetext(&$email){
		$removetext = $this->params->get('removetext', '{reg},{/reg},{pub},{/pub}');
		if(!empty($removetext)){
			$removeArray = explode(',', trim($removetext, ' ,'));
			if(!empty($email->body)) $email->body = str_replace($removeArray, '', $email->body);
			if(!empty($email->altbody)) $email->altbody = str_replace($removeArray, '', $email->altbody);
		}


		$removetags = $this->params->get('removetags', 'youtube');
		if(!empty($removetags)){
			$regex = array();
			$removeArray = explode(',', trim($removetags, ' ,'));
			foreach($removeArray as $oneTag){
				if(empty($oneTag)) continue;
				$regex[] = '#(?:{|%7B)'.preg_quote($oneTag, '#').'(?:}|%7D).*(?:{|%7B)/'.preg_quote($oneTag, '#').'(?:}|%7D)#Uis';
				$regex[] = '#(?:{|%7B)'.preg_quote($oneTag, '#').'[^}]*(?:}|%7D)#Uis';
			}

			if(!empty($email->body)) $email->body = preg_replace($regex, '', $email->body);
			if(!empty($email->altbody)) $email->altbody = preg_replace($regex, '', $email->altbody);
		}
	}

	private function _addfooter(&$email){
		$footer = $this->params->get('footer');
		if(!empty($footer)){
			if(strpos($email->body, '</body>')){
				$email->body = str_replace('</body>', '<br />'.$footer.'</body>', $email->body);
			}else{
				$email->body .= '<br />'.$footer;
			}

			if(!empty($email->altbody)){
				$email->altbody .= "\n".$footer;
			}
		}
	}

	function onAcyDisplayFilters(&$type, $context = "massactions"){
		if($this->params->get('displayfilter_'.$context, true) == false || ($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin())) return;

		$type['limitrand'] = acymailing_translation_sprintf('ACY_RAND_LIMIT', 'X');

		$return = '<div id="filter__num__limitrand">'.acymailing_translation_sprintf('ACY_RAND_LIMIT', '<input type="text" style="width:60px" value="30" name="filter[__num__][limitrand][nbusers]" />').'</div>';

		return $return;
	}

	function onAcyDisplayFilter_limitrand($filter){
		return acymailing_translation_sprintf('ACY_RAND_LIMIT', $filter['nbusers']);
	}


	function onAcyProcessFilter_limitrand(&$query, $filter, $num){
		$query->limit = intval($filter['nbusers']);
		$query->orderBy = 'RAND()';
	}

	function onAcyDisplayActions(&$type){
		$type['addqueue'] = acymailing_translation('ADD_QUEUE');
		$type['removequeue'] = acymailing_translation('REMOVE_QUEUE');

		$allEmails = acymailing_loadObjectList("SELECT `mailid`,`subject`, `type` FROM `#__acymailing_mail` WHERE `type` NOT IN ('notification','autonews','joomlanotification') OR `alias` = 'confirmation' ORDER BY `type`,`senddate` DESC LIMIT 5000");

		$emailsToDisplay = array();
		$typeNews = '';
		foreach($allEmails as $oneMail){
			$oneMail->subject = acyEmoji::Decode($oneMail->subject);
			if($oneMail->type != $typeNews){
				if(!empty($typeNews)) $emailsToDisplay[] = acymailing_selectOption('</OPTGROUP>');
				$typeNews = $oneMail->type;
				if($oneMail->type == 'news'){
					$label = acymailing_translation('NEWSLETTERS');
				}elseif($oneMail->type == 'followup'){
					$label = acymailing_translation('FOLLOWUP');
				}elseif($oneMail->type == 'welcome'){
					$label = acymailing_translation('MSG_WELCOME');
				}elseif($oneMail->type == 'unsub'){
					$label = acymailing_translation('MSG_UNSUB');
				}else{
					$label = $oneMail->type;
				}
				$emailsToDisplay[] = acymailing_selectOption('<OPTGROUP>', $label);
			}
			$emailsToDisplay[] = acymailing_selectOption($oneMail->mailid, $oneMail->subject.' ['.$oneMail->mailid.']');
		}
		$emailsToDisplay[] = acymailing_selectOption('</OPTGROUP>');

		$addqueue = '<div id="action__num__addqueue">'.acymailing_select($emailsToDisplay, "action[__num__][addqueue][mailid]", 'class="inputbox" size="1"').'<br /><label for="addqueuesenddate__num__">'.acymailing_translation('SEND_DATE').' </label> <input type="text" value="{time}" id="addqueuesenddate__num__" name="action[__num__][addqueue][senddate]" onclick="displayDatePicker(this,event)"/></div>';

		$allMessages = acymailing_selectOption(0, acymailing_translation('ACY_ALL'));
		array_unshift($emailsToDisplay, $allMessages);
		$removequeue = '<div id="action__num__removequeue">'.acymailing_select($emailsToDisplay, "action[__num__][removequeue][mailid]", 'class="inputbox" size="1"').'</div>';
		return $addqueue.$removequeue;
	}

	function onAcyProcessAction_addqueue($cquery, $action, $num){
		$action['mailid'] = intval($action['mailid']);
		if(empty($action['mailid'])) return 'Mailid not valid';
		if(empty($action['senddate'])) return 'Send date not valid';

		$action['senddate'] = acymailing_replaceDate($action['senddate']);
		if(!is_numeric($action['senddate'])) $action['senddate'] = acymailing_getTime($action['senddate']);
		if(empty($action['senddate'])) return 'send date not valid';

		$query = 'INSERT IGNORE INTO `#__acymailing_queue` (`mailid`,`subid`,`senddate`,`priority`) '.$cquery->getQuery(array($action['mailid'], 'sub.`subid`', $action['senddate'], '2'));
		$affected = acymailing_query($query);
		return acymailing_translation_sprintf('ADDED_QUEUE', $affected);
	}

	function onAcyProcessAction_removequeue($cquery, $action, $num){
		$action['mailid'] = intval($action['mailid']);
		if(!empty($action['mailid'])) $cquery->where['queueremove'] = 'queueremove.mailid = '.$action['mailid'];

		$query = 'DELETE queueremove.* FROM `#__acymailing_queue` as queueremove ';
		$query .= 'JOIN `#__acymailing_subscriber` as sub ON queueremove.subid = sub.subid ';
		if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
		if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);
		if(!empty($cquery->where)) $query .= ' WHERE ('.implode(') AND (', $cquery->where).')';

		$affected = acymailing_query($query);

		unset($cquery->where['queueremove']);

		return acymailing_translation_sprintf('SUCC_DELETE_ELEMENTS', $affected);
	}

	function onAcyProcessAction_displayUsers($cquery, $action, $num){

		$res = array();
		$res['countTotal'] = $cquery->count();

		if(empty($cquery->limit) || $cquery->limit > 50) $cquery->limit = 20;

		$query = $cquery->getQuery(array('sub.`subid`', 'sub.email', 'sub.name'));
		$users = acymailing_loadObjectList($query);

		$res['users'] = $users;
		return $res;
	}

}//endclass
managetext/index.html000060400000000054152455610250010676 0ustar00<html><body bgcolor="#FFFFFF"></body></html>managetext/managetext.xml000060400000006441152455610250011566 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Manage text</name>
	<creationDate>October 2010</creationDate>
	<version>1.0.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to remove some text from your Newsletter or add a signature at the end of all your Newsletters or add/remove an e-mail from the queue...</description>
	<files>
		<filename plugin="managetext">managetext.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-managetext"/>
		<param name="removetext" type="text" size="100" default="{reg},{/reg},{pub},{/pub}" label="Text to remove" description="Enter the different strings you want AcyMailing to remove and separate them with a comma. Example : {reg},{/reg},{pub},{/pub}" />
		<param name="removetags" type="text" size="100" default="youtube" label="Code to remove" description="AcyMailing will remove all tags specified in this option and its content, separate them with a comma" />

		<param name="footer" type="textarea" rows="5" cols="35" default="" label="Footer" description="Write the text you want to be added at the end of each e-mail" />
		<param name="@spacer" type="spacer" default="" label="" description="" />

		<param name="frontendaccess" type="list" default="all" label="Front-end Access for filter" description="You can restrict the access to the filter 'Randomly select X Users' on the Front-end">
			<option value="all">Always display this filter</option>
			<option value="none">Don't display this filter on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-managetext"/>
				<field name="removetext" type="text" size="100" default="{reg},{/reg},{pub},{/pub}" label="Text to remove" description="Enter the different strings you want AcyMailing to remove and separate them with a comma. Example : {reg},{/reg},{pub},{/pub}" />
				<field name="removetags" type="text" size="100" default="youtube" label="Code to remove" description="AcyMailing will remove all tags specified in this option and its content, separate them with a comma" />

				<field name="footer" type="textarea" rows="5" cols="35" default="" label="Footer" description="Write the text you want to be added at the end of each e-mail" filter="SAFEHTML" />
				<field name="@spacer" type="spacer" default="" label="" description="" />

				<field name="frontendaccess" type="list" default="all" label="Front-end Access for filter" description="You can restrict the access to the filter 'Randomly select X Users' on the Front-end">
					<option value="all">Always display this filter</option>
					<option value="none">Don't display this filter on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
template/index.html000060400000000054152455610250010354 0ustar00<html><body bgcolor="#FFFFFF"></body></html>template/template.php000060400000027114152455610250010711 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTemplate extends JPlugin{

	var $templates = array();
	var $tags = array();
	var $headerstyles = array();
	var $others = array();
	var $stylesheets = array();
	var $templateClass = '';
	var $config;

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'template');
			$this->params = new acyParameter($plugin->params);
		}
		$this->config = acymailing_config();
		if(version_compare(PHP_VERSION, '5.0.0', '>=') && class_exists('DOMDocument') && function_exists('mb_convert_encoding')){
			require_once(ACYMAILING_FRONT.'inc'.DS.'emogrifier'.DS.'emogrifier.php');
		}
	}

	private function _applyTemplate(&$email, $addbody){
		if(empty($email->tempid)) return;

		if(!isset($this->templates[$email->tempid])){
			$this->headerstyles[$email->tempid] = array();
			$this->headerstyles[$email->tempid][] = '.ReadMsgBody{width: 100%;}';
			$this->headerstyles[$email->tempid][] = '.ExternalClass{width: 100%;}';
			$this->headerstyles[$email->tempid][] = 'div, p, a, li, td { -webkit-text-size-adjust:none; }';
			$this->headerstyles[$email->tempid][] = 'a[x-apple-data-detectors]{
			color: inherit !important;
			text-decoration: inherit !important;
			font-size: inherit !important;
			font-family: inherit !important;
			font-weight: inherit !important;
			line-height: inherit !important;
			}';

			$this->templates[$email->tempid] = array();
			if(empty($this->templateClass)){
				$this->templateClass = acymailing_get('class.template');
			}
			if(!empty($email->template) && $email->tempid == $email->template->tempid){
				$template = $email->template;
			}else{
				$template = $email->template = $this->templateClass->get($email->tempid);
			}

			if(!empty($template->styles) OR !empty($template->stylesheet)){
				$this->stylesheets[$email->tempid] = $this->templateClass->buildCSS($template->styles, $template->stylesheet);

				if(preg_match_all('#@import[^;]*;#is', $this->stylesheets[$email->tempid], $results)){
					foreach($results[0] as $oneResult){
						array_unshift($this->headerstyles[$email->tempid], trim($oneResult));
					}
				}

				if(preg_match_all('#@media.*}[^{}]*}#Uis', $this->stylesheets[$email->tempid], $results)){

					foreach($results[0] as $oneResult){
						$this->stylesheets[$email->tempid] = str_replace($oneResult, '', $this->stylesheets[$email->tempid]);
						$this->headerstyles[$email->tempid][] = trim($oneResult);
					}
				}

				if(preg_match_all('#}([^}]+:hover[^{]*{[^{]*})#Uis', '} '.$this->stylesheets[$email->tempid], $results)){
					foreach($results[1] as $oneResult){
						$this->stylesheets[$email->tempid] = str_replace($oneResult, '', $this->stylesheets[$email->tempid]);
						$this->headerstyles[$email->tempid][] = trim($oneResult);
					}
				}
			}


			if(!empty($template->styles)){
				foreach($template->styles as $class => $style){
					if(empty($style)) continue;
					if(preg_match('#^tag_(.*)$#', $class, $result)){
						$this->tags[$email->tempid]['#< *'.$result[1].'((?:(?!style).)*)>#Ui'] = '<'.$result[1].' style="'.$style.'" $1>';
						if(strpos($style, '!important')) $this->headerstyles[$email->tempid][] = $result[1].'{ '.str_replace('!important', '', $style).' }';
					}elseif($class == 'color_bg'){
						$this->others[$email->tempid][$class] = $style;
					}else{
						$this->templates[$email->tempid]['class="'.$class.'"'] = 'style="'.$style.'"';
					}
				}
				if(!empty($template->styles['tag_a'])){
					$this->headerstyles[$email->tempid][] = 'a:visited{'.$template->styles['tag_a'].'}';
				}
			}
		}

		if($addbody AND !strpos($email->body, '</body>')){
			$before = '<html><head>'."\n";
			if(!empty($template->header)) $before .= $template->header."\n";
			$before .= '<meta http-equiv="Content-Type" content="text/html; charset='.strtolower($this->config->get('charset')).'" />'."\n";
			$before .= '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n";
			$before .= '<title>'.$email->subject.'</title>'."\n";
			if(!empty($this->headerstyles[$email->tempid])){
				$before .= '<style type="text/css">'."\n";
				$before .= implode("\n", $this->headerstyles[$email->tempid])."\n";
				$before .= '</style>'."\n";
			}
			$before .= '</head>'."\n".'<body yahoo="fix"';
			if(!empty($this->others[$email->tempid]['color_bg'])) $before .= ' bgcolor="'.$this->others[$email->tempid]['color_bg'].'" ';
			$before .= '>'."\n";
			$email->body = $before.$email->body.'</body>'."\n".'</html>';
		}

		if(!empty($this->stylesheets[$email->tempid]) AND class_exists('acymailingEmogrifier')){
			$emogrifier = new acymailingEmogrifier($email->body, $this->stylesheets[$email->tempid]);
			$email->body = $emogrifier->emogrify();

			if(!$addbody AND strpos($email->body, '<!DOCTYPE') !== false){
				$email->body = preg_replace('#<\!DOCTYPE.*<body([^>]*)>#Usi', '', $email->body);
				$email->body = preg_replace('#</body>.*$#si', '', $email->body);
			}
		}else{
			if(!empty($this->templates[$email->tempid])){
				$email->body = str_replace(array_keys($this->templates[$email->tempid]), $this->templates[$email->tempid], $email->body);
			}

			if(!empty($this->tags[$email->tempid])){
				$email->body = preg_replace(array_keys($this->tags[$email->tempid]), $this->tags[$email->tempid], $email->body);
			}
		}

		$newbody = preg_replace('#(<(div|tr|td|table)[^>]*)title="[^"]*"#Uis', '$1', $email->body);
		if(!empty($newbody)) $email->body = $newbody;

		$newbody = preg_replace('# id="zone_[0-9]+"#Uis', ' ', $email->body);
		if(!empty($newbody)) $email->body = $newbody;

		$newbody = preg_replace('# *(acyeditor_text|acyeditor_picture|acyeditor_delete|acyeditor_sortable|ui-sortable) *#is', '', $email->body);
		$newbody = preg_replace('#(class|title|style|id)=" *"#Ui', '', $newbody);
		if(!empty($newbody)) $email->body = $newbody;
	}

	public function acymailing_replaceusertags(&$email, &$user, $send = true){

		if(!$email->sendHTML) return;

		if((!acymailing_level(1) || acymailing_level(4)) && !empty($email->type) && in_array($email->type, array('news', 'followup'))){
			$pict = '<div style="text-align:center;margin:10px auto;display:block;"><a target="_blank" href="https://www.acyba.com/?utm_source=acymailing&utm_medium=e-mail&utm_content=img&utm_campaign=powered-by"><img alt="Powered by AcyMailing" src="media/com_acymailing/images/poweredby.png" /></a></div>';

			if(strpos($email->body, '</body>')){
				$email->body = str_replace('</body>', $pict.'</body>', $email->body);
			}else{
				$email->body .= $pict;
			}
		}

		$this->_applyTemplate($email, $send);

		$email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\(\'?([^)\']*)\'?\);?#Ui', '<$1 background="$4" $2 $3', $email->body);
		$email->body = acymailing_absoluteURL($email->body);

		if(preg_match_all('#< *img([^>]*)>#Ui', $email->body, $allPictures)){

			foreach($allPictures[0] as $i => $onePict){
				if(strpos($onePict, 'align=') !== false) continue;
				if(!preg_match('#(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', $onePict, $pictParams)) continue;

				$newPict = str_replace('<img', '<img align="'.$pictParams[3].'" ', $onePict);

				$email->body = str_replace($onePict, $newPict, $email->body);

				if(strpos($onePict, 'hspace=') !== false) continue;

				$hspace = 5;
				if(preg_match('#margin(-right|-left)? *:([^";]*)#i', $onePict, $margins)){
					$currentMargins = explode(' ', trim($margins[2]));
					$myMargin = (count($currentMargins) > 1) ? $currentMargins[1] : $currentMargins[0];
					if(strpos($myMargin, 'px') !== false) $hspace = preg_replace('#[^0-9]#i', '', $myMargin);
				}

				$lastPict = str_replace('<img', '<img hspace="'.$hspace.'" ', $newPict);

				$email->body = str_replace($newPict, $lastPict, $email->body);
			}
		}

		if(!preg_match('#(<thead|<tfoot|< *tbody *[^> ]+ *>)#Ui', $email->body)){
			$email->body = preg_replace('#< *\/? *tbody *>#Ui', '', $email->body);
		}

		$email->body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', array($this, '_convertSpaces'), $email->body);

		$this->fixPictureSize($email->body);

		$acypluginsHelper = acymailing_get('helper.acyplugins');
		$acypluginsHelper->fixPictureDim($email->body);
	}//endfct

	public function acymailing_replacetags(&$email, $send = true){
		$this->linksSEF($email);
		$this->checkThumbnailYoutube($email);
	}

	public function linksSEF(&$email){
		$results = array();
		$altresults = array();
		$found = preg_match_all('#(?:{|%7B)acyfrontsef(?:}|%7D)(.*)(?:{|%7B)/acyfrontsef(?:}|%7D)#Uis', $email->body, $results);
		$found = preg_match_all('#(?:{|%7B)acyfrontsef(?:}|%7D)(.*)(?:{|%7B)/acyfrontsef(?:}|%7D)#Uis', $email->altbody, $altresults) || $found;

		if(!$found) return;

		$results[0] = array_merge($results[0], $altresults[0]);
		$results[1] = array_merge($results[1], $altresults[1]);

		$clearesults = array(0 => array(), 1 => array());
		foreach($results[0] as $i => $val){
			if(in_array($val, $clearesults[0])) continue;
			$clearesults[0][] = $val;
			$clearesults[1][] = $results[1][$i];
		}
		$results = $clearesults;

		$urls = '';
		$i = 0;
		$passedResults = array(0 => array(), 1 => array());
		foreach($results[1] as $key => $link){
			$urls .= '&urls['.$i.']='.base64_encode($link);
			$passedResults[0][] = $results[0][$key];
			$passedResults[1][] = $link;
			$i++;

			if($i > 40){
				$this->_callFrontURL($email, $urls, $passedResults);
				$passedResults = array(0 => array(), 1 => array());
				$urls = '';
				$i = 0;
			}
		}

		if(!empty($urls)) $this->_callFrontURL($email, $urls, $passedResults);
	}

	private function _callFrontURL(&$email, $urls, $results){
		$sefLinks = acymailing_fileGetContent(acymailing_rootURI().'index.php?option=com_acymailing&ctrl=url&task=sef'.$urls);
		$newLinks = json_decode($sefLinks, true);

		if($newLinks == null){
			if(!empty($sefLinks) && defined('JDEBUG') && JDEBUG) acymailing_enqueueMessage('Error trying to get the sef links: '.$sefLinks);

			$newLinks = array();
			foreach($results[1] as $link){
				$key = $link;
				$link = ltrim($link, '/');
				$mainurl = acymailing_mainURL($link);
				$newLinks[$key] = $mainurl.$link;
			}
		}
		$replacement = array();
		if(empty($newLinks)) return;

		foreach($results[1] as $key => $origin){
			$replacement[$results[0][$key]] = $newLinks[$results[1][$key]];
		}

		$email->body = str_replace(array_keys($replacement), $replacement, $email->body);
		$email->altbody = str_replace(array_keys($replacement), $replacement, $email->altbody);
	}

	public function _convertSpaces($matches){
		return "src='".str_replace(' ', '%20', $matches[1])."'";
	}

	private function fixPictureSize(&$body){
		if(!preg_match_all('#(<img)([^>]*>)#i', $body, $results)) return;

		$replace = array();
		$widthheight = array('width', 'height');
		foreach($results[0] as $num => $oneResult){
			$add = array();
			foreach($widthheight as $whword){
				if(preg_match('#'.$whword.' *=#i', $oneResult) || !preg_match('#[^a-z_\-]'.$whword.' *:([0-9 ]{1,8})px#i', $oneResult, $resultWH)) continue;

				if(empty($resultWH[1])) continue;
				$add[] = $whword.'="'.trim($resultWH[1]).'" ';
			}
			if(!empty($add)) $replace[$oneResult] = '<img '.implode(' ', $add).$results[2][$num];
		}

		if(empty($replace)) return;

		$body = str_replace(array_keys($replace), $replace, $body);
	}

	function checkThumbnailYoutube(&$mail){
		$acypluginsHelper = acymailing_get('helper.acyplugins');
		$mail->body = $acypluginsHelper->replaceVideos($mail->body);
	}
}//endclass
template/template.xml000060400000002177152455610250010724 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Template Class Replacer</name>
	<creationDate>March 2018</creationDate>
	<version>5.9.6</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved.</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables AcyMailing to replace CSS class in each email</description>
	<files>
		<filename plugin="template">template.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-template"/>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-template"/>
			</fieldset>
		</fields>
	</config>
</extension>
stats/stats.xml000060400000006276152455610250007576 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing : Statistics Plugin</name>
	<creationDate>September 2009</creationDate>
	<version>3.7.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin is used to handle statistics on any AcyMailing e-mail</description>
	<files>
		<filename plugin="stats">stats.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-stats"/>
		<param name="picture" type="text" size="60" label="Stat picture" default="media/com_acymailing/images/statpicture.png" description="Path of the statistic picture"/>
		<param name="alttext" type="text" size="60" default="" label="Alt Text" description="Alternatif text which will be displayed if the user does not accept to load your images" />
		<param name="width" type="text" size="2" default="50" label="Stat picture width" description="An image will be added in your HTML e-mails to be able to handle statistics. You can modify the width of the stat picture." />
		<param name="height" type="text" size="2" default="1" label="Stat picture height" description="An image will be added in your HTML e-mails to be able to handle statistics. You can modify the height of the stat picture." />
		<param name="displayfilter_mail" type="radio" default="0" label="Display filter" description="Display the statistics filter on the Newsletter creation interface">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-stats"/>
				<field name="picture" type="text" size="60" label="Stat picture" default="media/com_acymailing/images/statpicture.png" description="Path of the statistic picture"/>
				<field name="alttext" type="text" size="60" default="" label="Alt Text" description="Alternatif text which will be displayed if the user does not accept to load your images" />
				<field name="width" type="text" size="2" default="50" label="Stat picture width" description="An image will be added in your HTML e-mails to be able to handle statistics. You can modify the width of the stat picture." />
				<field name="height" type="text" size="2" default="1" label="Stat picture height" description="An image will be added in your HTML e-mails to be able to handle statistics. You can modify the height of the stat picture." />
				<field name="displayfilter_mail" type="radio" default="0" label="Display filter" description="Display the statistics filter on the Newsletter creation interface">
					<option value="0">JOOMEXT_NO</option>
					<option value="1">JOOMEXT_YES</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
stats/stats.php000060400000013340152455610250007553 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingStats extends JPlugin{
	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'stats');
			$this->params = new acyParameter($plugin->params);
		}
		$this->acypluginsHelper = acymailing_get('helper.acyplugins');
	}

	function acymailing_replacetags(&$email, $send = true){
		$this->statPicture($email, $send);
	}

	function statPicture(&$email, $send = true){
		if(!empty($email->altbody)){
			$email->altbody = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->altbody);
		}
		if(((isset($email->sendHTML) && !$email->sendHTML) || (isset($email->html) && !$email->html))
			|| empty($email->type)
			|| !in_array($email->type, array('news', 'autonews', 'followup', 'welcome', 'unsub', 'joomlanotification', 'action'))
			|| strpos($email->body, '{nostatpicture}')){
			$email->body = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->body);
			return;
		}

		if(!$send){
			$pictureLink = ACYMAILING_LIVE.$this->params->get('picture', 'media/com_acymailing/images/statpicture.png');
		}else {
			$config = acymailing_config();
			$itemId = $config->get('itemid', 0);
			$item = empty($itemId) ? '' : '&Itemid=' . $itemId;
			$pictureLink = acymailing_frontendLink('index.php?option=com_acymailing&ctrl=statistics&mailid=' . $email->mailid . '&subid={subtag:subid}' . $item, false);
		}

		$widthsize = $this->params->get('width', 50);
		$heightsize = $this->params->get('height', 1);
		$width = empty($widthsize) ? '' : ' width="'.$widthsize.'" ';
		$height = empty($heightsize) ? '' : ' height="'.$heightsize.'" ';

		$statPicture = '<img class="spict" alt="'.$this->params->get('alttext', '').'" src="'.$pictureLink.'"  border="0" '.$height.$width.'/>';

		if(strpos($email->body, '{statpicture}')){
			$email->body = str_replace('{statpicture}', $statPicture, $email->body);
		}elseif(strpos($email->body, '</body>')) $email->body = str_replace('</body>', $statPicture.'</body>', $email->body);
		else $email->body .= $statPicture;
	}//endfct

	function acymailing_getstatpicture(){
		return $this->params->get('picture', 'media/com_acymailing/images/statpicture.png');
	}

	function onAcyDisplayTriggers(&$triggers){
		$triggers['opennews'] = acymailing_translation('ON_OPEN_NEWS');
	}

	function onAcyDisplayFilters(&$type, $context = "massactions"){

		if($context != "massactions" AND !$this->params->get('displayfilter_'.$context, false)) return;

		$type['deliverstat'] = acymailing_translation('STATISTICS');

		$allemails = acymailing_loadObjectList("SELECT `mailid`,CONCAT(`subject`,' [',".acymailing_escapeDB(acymailing_translation('ACY_ID').' ').", CAST(`mailid` AS char),']') as 'value' FROM `#__acymailing_mail` WHERE `type` IN('news','welcome','unsub','followup','notification','joomlanotification') ORDER BY `senddate` DESC LIMIT 5000");
		$element = new stdClass();
		$element->mailid = 0;
		$element->value = acymailing_translation('EMAIL_NAME');
		array_unshift($allemails, $element);

		$actions = array();
		$actions[] = acymailing_selectOption('open', acymailing_translation('OPEN'));
		$actions[] = acymailing_selectOption('notopen', acymailing_translation('NOT_OPEN'));
		$actions[] = acymailing_selectOption('failed', acymailing_translation('FAILED'));
		if(acymailing_level(3)) $actions[] = acymailing_selectOption('bounce', acymailing_translation('BOUNCES'));
		$actions[] = acymailing_selectOption('htmlsent', acymailing_translation('SENT_HTML'));
		$actions[] = acymailing_selectOption('textsent', acymailing_translation('SENT_TEXT'));
		$actions[] = acymailing_selectOption('notsent', acymailing_translation('NOT_SENT'));

		$return = '<div id="filter__num__deliverstat">'.acymailing_select($actions, "filter[__num__][deliverstat][action]", 'class="inputbox" onchange="countresults(__num__);" size="1"', 'value', 'text');
		$return .= ' '.acymailing_select($allemails, "filter[__num__][deliverstat][mailid]", 'onchange="countresults(__num__)" class="inputbox" size="1" style="max-width:200px"', 'mailid', 'value').'</div>';

		return $return;
	}

	function onAcyProcessFilterCount_deliverstat(&$query, $filter, $num){
		$this->onAcyProcessFilter_deliverstat($query, $filter, $num);
		return acymailing_translation_sprintf('SELECTED_USERS', $query->count());
	}

	function onAcyProcessFilter_deliverstat(&$query, $filter, $num){

		$alias = 'stats'.$num;
		$jl = '#__acymailing_userstats AS '.$alias.' ON '.$alias.'.subid = sub.subid';
		if(!empty($filter['mailid'])) $jl .= ' AND '.$alias.'.mailid = '.intval($filter['mailid']);

		$query->leftjoin[$alias] = $jl;

		if($filter['action'] == 'open'){
			$where = $alias.'.open > 0';
		}elseif($filter['action'] == 'notopen'){
			if(empty($filter['mailid'])) {
				unset($query->leftjoin[$alias]);
				$usersNeverOpened = acymailing_loadResultArray('SELECT subid FROM #__acymailing_userstats GROUP BY subid HAVING MAX(open) = 0');
				if(empty($usersNeverOpened)) $usersNeverOpened = array(0);
				$where = 'sub.subid IN ('.implode(',', $usersNeverOpened).')';
			}else{
				$where = $alias.'.open = 0';
			}
		}elseif($filter['action'] == 'failed'){
			$where = $alias.'.fail = 1';
		}elseif($filter['action'] == 'bounce'){
			$where = $alias.'.bounce = 1';
		}elseif($filter['action'] == 'htmlsent'){
			$where = $alias.'.html = 1';
		}elseif($filter['action'] == 'textsent'){
			$where = $alias.'.html = 0';
		}elseif($filter['action'] == 'notsent'){
			$where = $alias.'.subid IS NULL';
		}

		$query->where[] = $where;
	}

}//endclass
stats/index.html000060400000000054152455610250007677 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tagtime/tagtime.xml000060400000003361152455610250010356 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : Date / Time</name>
	<creationDate>March 2018</creationDate>
	<version>5.9.6</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add time or date in your Newsletter</description>
	<files>
		<filename plugin="tagtime">tagtime.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagtime"/>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagtime"/>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
tagtime/tagtime.php000060400000007052152455610250010346 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTagtime extends JPlugin{

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tagtime');
			$this->params = new acyParameter($plugin->params);
		}
	}


	function acymailing_getPluginType(){

		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('ACY_TIME');
		$onePlugin->function = 'acymailingtagtime_show';
		$onePlugin->help = 'plugin-tagtime';

		return $onePlugin;
	}

	function acymailingtagtime_show(){

		$text = '<br style="clear:both;"/><div class="onelineblockoptions"><table class="acymailing_table" cellpadding="1">';

		$others = array();
		$others['{date}'] = 'DATE_FORMAT_LC';
		$others['{date:1}'] = 'DATE_FORMAT_LC1';
		$others['{date:2}'] = 'DATE_FORMAT_LC2';
		$others['{date:3}'] = 'DATE_FORMAT_LC3';
		$others['{date:4}'] = 'DATE_FORMAT_LC4';
		$others['{date:%m/%d/%Y}'] = '%m/%d/%Y';
		$others['{date:%d/%m/%y}'] = '%d/%m/%y';
		$others['{date:%A}'] = '%A';
		$others['{date:%B}'] = '%B';


		$k = 0;
		foreach($others as $tagname => $tag){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\''.$tagname.'\');insertTag();" ><td class="acytdcheckbox"></td><td>'.$tag.'</td><td>'.acymailing_getDate(time(), acymailing_translation($tag)).'</td></tr>';
			$k = 1 - $k;
		}

		$text .= '</table></div>';

		echo $text;
	}

	function acymailing_replacetags(&$email, $send = true){

		$match = '#{date:?([^:].*)?}#Ui';
		$variables = array('subject', 'body', 'altbody');

		foreach($variables as $var){
			$email->$var = str_replace(array('{mailid}', '%7Bmailid%7D', '{emailsubject}'), array($email->mailid, $email->mailid, $email->subject), $email->$var);
		}
		$email->body = str_replace('{textversion}', nl2br($email->altbody), $email->body);


		$found = false;
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found) return;

		$tags = array();
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($tags[$oneTag])) continue;
				$arguments = explode('|', strip_tags($allresults[1][$i]));
				$parameter = new stdClass();
				$parameter->format = $arguments[0];
				for($i = 1; $i < count($arguments); $i++){
					$args = explode(':', $arguments[$i]);
					$arg0 = trim($args[0]);
					if(isset($args[1])){
						$parameter->$arg0 = $args[1];
					}else{
						$parameter->$arg0 = true;
					}
				}

				$time = time();
				if(!empty($parameter->senddate) && !empty($email->senddate)) $time = $email->senddate;
				if(!empty($parameter->add)) $time += intval($parameter->add);
				if(!empty($parameter->remove)) $time -= intval($parameter->remove);

				if(empty($parameter->format) OR is_numeric($parameter->format)){
					$tags[$oneTag] = acymailing_getDate($time, acymailing_translation('DATE_FORMAT_LC'.$parameter->format));
				}else{
					$tags[$oneTag] = acymailing_getDate($time, $parameter->format);
				}
			}
		}

		foreach(array_keys($results) as $var){
			$email->$var = str_replace(array_keys($tags), $tags, $email->$var);
		}
	}
}//endclass
tagtime/index.html000060400000000054152455610250010173 0ustar00<html><body bgcolor="#FFFFFF"></body></html>contentplugin/index.html000060400000000054152455610250011432 0ustar00<html><body bgcolor="#FFFFFF"></body></html>contentplugin/contentplugin.php000060400000006166152455610250013051 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingContentplugin extends JPlugin
{

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);

		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'contentplugin');
			$this->params = new acyParameter( $plugin->params );
		}

		$this->paramsContent = JComponentHelper::getParams('com_content');
		acymailing_importPlugin('content');

		$excludedHandlers = array('plgContentEmailCloak','pluginImageShow');
		$excludedNames = array('system' => array('SEOGenerator','SEOSimple'), 'content' => array('webeecomment','highslide','smartresizer','phocagallery'));
		$excludedType = array_keys($excludedNames);

		if(!ACYMAILING_J16){
			$this->dispatcherContent = JDispatcher::getInstance();
			foreach ($this->dispatcherContent->_observers as $id => $observer){
				if (is_array($observer) AND in_array($observer['handler'],$excludedHandlers)){
					$this->dispatcherContent->_observers[$id]['event'] = '';
				}elseif(is_object($observer)){
					if(in_array($observer->_type,$excludedType) AND in_array($observer->_name,$excludedNames[$observer->_type])){
						$this->dispatcherContent->_observers[$id] = null;
					}
				}
			}
		}

		if(!class_exists('JSite')) include_once(ACYMAILING_ROOT.'includes'.DS.'application.php');

	}

	function acymailing_replacetags(&$email,$send = true){

		$art = new stdClass();
		$art->title = $email->subject;
		$art->introtext = $email->body;
		$art->fulltext = $email->body;
		$art->attribs = '';
		$art->state=1;
		$art->created_by=@$email->userid;
		$art->images = '';
		$art->id = 0;
		$art->section = 0;
		$art->catid = 0;

		$context = 'com_acymailing';


		try{
			if(!empty($email->body)){
				$art->text = $email->body;
				if(!ACYMAILING_J16){
					$resultsPlugin = acymailing_trigger('onPrepareContent', array(&$art, &$this->paramsContent, 0));
				}else{
					if($send) $art->text .= '{emailcloak=off}';
					$resultsPlugin = acymailing_trigger('onContentPrepare', array($context, &$art, &$this->paramsContent, 0));
					if($send) $art->text = str_replace(array('{emailcloak=off}','{* emailcloak=off}'),'',$art->text);
				}
				$email->body = $art->text;
			}
			if(!empty($email->altbody)){
				$art->text = $email->altbody;
				if(!ACYMAILING_J16){
					$resultsPlugin = acymailing_trigger('onPrepareContent', array(&$art, &$this->paramsContent, 0));
				}else{
					if($send) $art->text .= '{emailcloak=off}';
					$resultsPlugin = acymailing_trigger('onContentPrepare', array ($context,&$art, &$this->paramsContent, 0 ));
					if($send) $art->text = str_replace(array('{emailcloak=off}','{* emailcloak=off}'),'',$art->text);
				}
				$email->altbody = $art->text;
			}
		}catch(Exception $e){
			acymailing_display(array('An error occured with the AcyMailing contentplugin plugin, you may want to disable it from the AcyMailing configuration page',$e->getMessage()),'error');
		}

	}
}//endclass
contentplugin/contentplugin.xml000060400000002545152455610250013057 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing : trigger Joomla Content plugins</name>
	<creationDate>November 2009</creationDate>
	<version>3.7.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to trigger the content plugin system on AcyMailing. The Joomla Content plugin system has not been developed to be triggered from the backend and so you may have some non compatible plugins, that's why this plugin is not enabled by default</description>
	<files>
		<filename plugin="contentplugin">contentplugin.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-contentplugin"/>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-contentplugin"/>
			</fieldset>
		</fields>
	</config>
</extension>
tagcontent/tagcontent.xml000060400000020245152455610250011606 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : content insertion</name>
	<creationDate>September 2009</creationDate>
	<version>3.7.0</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This AcyMailing plugin enables you to include Joomla Articles in any e-mail sent by AcyMailing</description>
	<files>
		<filename plugin="tagcontent">tagcontent.php</filename>
		<filename>tagcontent.xml</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagcontent"/>
		<param name="customtemplate" type="customtemplate" label="Custom template" description="Click on the Custom template button to create a custom layout that will override the default view" default="tagcontent"/>
		<param name="displayart" type="radio" default="all" label="Display articles" description="Select if you want to display all articles in the popup for article selection or only published articles">
			<option value="all">All articles</option>
			<option value="onlypub">Only published articles</option>
		</param>
		<param name="contentaccess" type="radio" default="registered" label="Content Access" description="If you use the automatic article insertion (via the categories tab), AcyMailing will only include articles having the selected access in your Newsletter">
			<option value="public">Public only</option>
			<option value="registered">Public and Registered</option>
			<option value="all">All</option>
		</param>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="Using AcyMailing Enterprise, you can restrict the access to this tag system">
			<option value="all">Display all articles</option>
			<option value="author">Display only author's articles</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
		<param name="metaselect" type="radio" default="0" label="Select articles by meta tags" description="Do you want to display an interface on the content category insertion to filter articles by meta tags? Meta tags must be separated by a comma.">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
		<param name="integration" type="radio" default="0" label="Act for another component" description="Some Joomla components use the content table to store their articles. This option enables you to make sure Acy will act for this third part component and not for the default Joomla content system" >
			<option value="0">Joomla content</option>
			<option value="jreviews">jReviews</option>
			<option value="flexicontent">FlexiContent</option>
			<option value="jaggyblog">JaggyBlog</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="default_type" type="radio" default="intro" label="DISPLAY" description="FIELD_DEFAULT">
			<option value="title">TITLE_ONLY</option>
			<option value="intro">INTRO_ONLY</option>
			<option value="text">FIELD_TEXT</option>
			<option value="full">FULL_TEXT</option>
		</param>
		<param name="wordwrap" type="text" size="10" default="0" label="Intro Word Wrapping" description="If you insert only the introduction and you didn't insert the read more link, AcyMailing will only load the first XX characters of your content. If you specify 0, AcyMailing won't wrap your content" />
		<param name="default_titlelink" type="radio" default="link" label="CLICKABLE_TITLE" description="FIELD_DEFAULT">
			<option value="link">JOOMEXT_YES</option>
			<option value="0">JOOMEXT_NO</option>
		</param>
		<param name="default_author" type="radio" default="0" label="AUTHOR_NAME" description="FIELD_DEFAULT">
			<option value="author">JOOMEXT_YES</option>
			<option value="0">JOOMEXT_NO</option>
		</param>
		<param name="default_pict" type="radio" default="1" label="DISPLAY_PICTURES" description="FIELD_DEFAULT">
			<option value="1">JOOMEXT_YES</option>
			<option value="resized">RESIZED</option>
			<option value="0">JOOMEXT_NO</option>
		</param>
		<param name="maxwidth" type="text" size="10" default="150" label="Max picture width" description="FIELD_DEFAULT" />
		<param name="maxheight" type="text" size="10" default="150" label="Max picture height" description="FIELD_DEFAULT" />

	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagcontent"/>
				<field name="customtemplate" type="customtemplate" label="Custom template" description="Click on the Custom template button to create a custom layout that will override the default view" default="tagcontent"/>
				<field name="displayart" type="radio" default="all" label="Display articles" description="Select if you want to display all articles in the popup for article selection or only published articles">
					<option value="all">All articles</option>
					<option value="onlypub">Only published articles</option>
				</field>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="Using AcyMailing Enterprise, you can restrict the access to this tag system">
					<option value="all">Display all articles</option>
					<option value="author">Display only author's articles</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
				<field name="metaselect" type="radio" default="0" label="Select articles by meta tags" description="Do you want to display an interface on the content category insertion to filter articles by meta tags? Meta tags must be separated by a comma.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="integration" type="radio" default="0" label="Act for another component" description="Some Joomla components use the content table to store their articles. This option enables you to make sure Acy will act for this third part component and not for the default Joomla content system" >
					<option value="0">Joomla content</option>
					<option value="jreviews">jReviews</option>
					<option value="flexicontent">FlexiContent</option>
					<option value="jaggyblog">JaggyBlog</option>
				</field>
				<field name="@spacer" type="spacer" default="" label="" description="" />
				<field name="default_type" type="radio" default="intro" label="DISPLAY" description="FIELD_DEFAULT">
					<option value="title">TITLE_ONLY</option>
					<option value="intro">INTRO_ONLY</option>
					<option value="text">FIELD_TEXT</option>
					<option value="full">FULL_TEXT</option>
				</field>
				<field name="wordwrap" type="text" size="10" default="0" label="Intro Word Wrapping" description="If you insert only the introduction and you didn't insert the read more link, AcyMailing will only load the first XX characters of your content. If you specify 0, AcyMailing won't wrap your content" />
				<field name="default_titlelink" type="radio" default="link" label="CLICKABLE_TITLE" description="FIELD_DEFAULT">
					<option value="link">JOOMEXT_YES</option>
					<option value="0">JOOMEXT_NO</option>
				</field>
				<field name="default_author" type="radio" default="" label="AUTHOR_NAME" description="FIELD_DEFAULT">
					<option value="author">JOOMEXT_YES</option>
					<option value="">JOOMEXT_NO</option>
				</field>
				<field name="default_pict" type="radio" default="1" label="DISPLAY_PICTURES" description="FIELD_DEFAULT">
					<option value="1">JOOMEXT_YES</option>
					<option value="resized">RESIZED</option>
					<option value="0">JOOMEXT_NO</option>
				</field>
				<field name="maxwidth" type="text" size="10" default="150" label="Max picture width" description="FIELD_DEFAULT" />
				<field name="maxheight" type="text" size="10" default="150" label="Max picture height" description="FIELD_DEFAULT" />
			</fieldset>
		</fields>
	</config>
</extension>

tagcontent/tagcontent.php000060400000211076152455610250011601 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php defined('_JEXEC') or die('Restricted access'); ?>
<?php

class plgAcymailingTagcontent extends JPlugin{
	public function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tagcontent');
			$this->params = new acyParameter($plugin->params);
		}
		$this->acypluginsHelper = acymailing_get('helper.acyplugins');
		$tables = acymailing_getTableList();
		$this->newMulticats = in_array(acymailing_getPrefix().'content_multicats', $tables);
	}

	public function acymailing_getPluginType(){
		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;

		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('JOOMLA_CONTENT');
		$onePlugin->function = 'acymailingtagcontent_show';
		$onePlugin->help = 'plugin-tagcontent';

		return $onePlugin;
	}

	public function acymailingtagcontent_show(){

		$pageInfo = new stdClass();
		$pageInfo->filter = new stdClass();
		$pageInfo->filter->order = new stdClass();
		$pageInfo->limit = new stdClass();
		$pageInfo->elements = new stdClass();
		
		acymailing_loadLanguageFile('com_content', JPATH_SITE);

		$paramBase = ACYMAILING_COMPONENT.'.tagcontent';
		$pageInfo->filter->order->value = acymailing_getUserVar($paramBase.".filter_order", 'filter_order', 'a.id', 'cmd');
		$pageInfo->filter->order->dir = acymailing_getUserVar($paramBase.".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
		if(strtolower($pageInfo->filter->order->dir) !== 'desc') $pageInfo->filter->order->dir = 'asc';
		$pageInfo->search = acymailing_getUserVar($paramBase.".search", 'search', '', 'string');
		$pageInfo->search = strtolower(trim($pageInfo->search));
		$pageInfo->filter_cat = acymailing_getUserVar($paramBase.".filter_cat", 'filter_cat', '', 'int');
		$pageInfo->contenttype = acymailing_getUserVar($paramBase.".contenttype", 'contenttype', $this->params->get('default_type', 'intro'), 'string');
		$pageInfo->author = acymailing_getUserVar($paramBase.".author", 'author', $this->params->get('default_author', '0'), 'string');
		$pageInfo->titlelink = acymailing_getUserVar($paramBase.".titlelink", 'titlelink', $this->params->get('default_titlelink', 'link'), 'string');
		$pageInfo->lang = acymailing_getUserVar($paramBase.".lang", 'lang', '', 'string');
		$pageInfo->pict = acymailing_getUserVar($paramBase.".pict", 'pict', $this->params->get('default_pict', 1), 'string');
		$pageInfo->pictheight = acymailing_getUserVar($paramBase.".pictheight", 'pictheight', $this->params->get('maxheight', 150), 'string');
		$pageInfo->pictwidth = acymailing_getUserVar($paramBase.".pictwidth", 'pictwidth', $this->params->get('maxwidth', 150), 'string');


		$pageInfo->limit->value = acymailing_getUserVar($paramBase.'.list_limit', 'limit', acymailing_getCMSConfig('list_limit'), 'int');
		$pageInfo->limit->start = acymailing_getUserVar($paramBase.'.limitstart', 'limitstart', 0, 'int');

		$picts = array();
		$picts[] = acymailing_selectOption("1", acymailing_translation('JOOMEXT_YES'));
		$pictureHelper = acymailing_get('helper.acypict');
		if($pictureHelper->available()) $picts[] = acymailing_selectOption("resized", acymailing_translation('RESIZED'));
		$picts[] = acymailing_selectOption("0", acymailing_translation('JOOMEXT_NO'));

		$contenttype = array();
		$contenttype[] = acymailing_selectOption("title", acymailing_translation('TITLE_ONLY'));
		$contenttype[] = acymailing_selectOption("intro", acymailing_translation('INTRO_ONLY'));
		$contenttype[] = acymailing_selectOption("text", acymailing_translation('FIELD_TEXT'));
		$contenttype[] = acymailing_selectOption("full", acymailing_translation('FULL_TEXT'));

		$titlelink = array();
		$titlelink[] = acymailing_selectOption("link", acymailing_translation('JOOMEXT_YES'));
		$titlelink[] = acymailing_selectOption("0", acymailing_translation('JOOMEXT_NO'));

		$authorname = array();
		$authorname[] = acymailing_selectOption("author", acymailing_translation('JOOMEXT_YES'));
		$authorname[] = acymailing_selectOption("0", acymailing_translation('JOOMEXT_NO'));

		$searchFields = array('a.id', 'a.title', 'a.alias', 'a.created_by', 'b.name', 'b.username');
		if(!empty($pageInfo->search)){
			$searchVal = '\'%'.acymailing_getEscaped($pageInfo->search, true).'%\'';
			$filters[] = implode(" LIKE $searchVal OR ", $searchFields)." LIKE $searchVal";
		}

		if(!empty($pageInfo->filter_cat)){
			$filters[] = "a.catid = ".$pageInfo->filter_cat;
		}

		if($this->params->get('displayart', 'all') == 'onlypub'){
			$filters[] = "a.state = 1";
		}else{
			$filters[] = "a.state != -2";
		}

		if(!acymailing_isAdmin()){
			$my = JFactory::getUser();

			if(!ACYMAILING_J16){
				$filters[] = 'a.`access` <= '.(int)$my->get('aid');
			}else{
				$groups = implode(',', $my->getAuthorisedViewLevels());
				$filters[] = 'a.`access` IN ('.$groups.')';
			}
		}

		if($this->params->get('frontendaccess') == 'author' && !acymailing_isAdmin()){
			$filters[] = "a.created_by = ".intval(acymailing_currentUserId());
		}

		$whereQuery = '';
		if(!empty($filters)){
			$whereQuery = ' WHERE ('.implode(') AND (', $filters).')';
		}

		$query = 'SELECT SQL_CALC_FOUND_ROWS a.*,b.name,b.username,a.created_by FROM '.acymailing_table('content', false).' as a';
		$query .= ' LEFT JOIN `#__users` AS b ON b.id = a.created_by';
		if(!empty($whereQuery)) $query .= $whereQuery;
		if(!empty($pageInfo->filter->order->value)){
			$query .= ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir;
		}

		$rows = acymailing_loadObjectList($query, '', $pageInfo->limit->start, $pageInfo->limit->value);

		if(!empty($pageInfo->search)){
			$rows = acymailing_search($pageInfo->search, $rows);
		}

		$pageInfo->elements->total = acymailing_loadResult('SELECT FOUND_ROWS()');
		$pageInfo->elements->page = count($rows);

		if(!ACYMAILING_J16){
			$query = 'SELECT a.id, a.id as catid, a.title as category, b.title as section, b.id as secid from #__categories as a ';
			$query .= 'INNER JOIN #__sections as b on a.section = b.id ORDER BY b.ordering,a.ordering';

			$categories = acymailing_loadObjectList($query, 'id');
			$categoriesValues = array();
			$categoriesValues[] = acymailing_selectOption('', acymailing_translation('ACY_ALL'));
			$currentSec = '';
			foreach($categories as $catid => $oneCategorie){
				if($currentSec != $oneCategorie->section){
					if(!empty($currentSec)) $this->values[] = acymailing_selectOption('</OPTGROUP>');
					$categoriesValues[] = acymailing_selectOption('<OPTGROUP>', $oneCategorie->section);
					$currentSec = $oneCategorie->section;
				}
				$categoriesValues[] = acymailing_selectOption($catid, $oneCategorie->category);
			}
		}else{
			$query = "SELECT * from #__categories WHERE `extension` = 'com_content' ORDER BY lft ASC";

			$categories = acymailing_loadObjectList($query, 'id');
			$categoriesValues = array();
			$categoriesValues[] = acymailing_selectOption('', acymailing_translation('ACY_ALL'));
			foreach($categories as $catid => $oneCategorie){
				$categories[$catid]->title = str_repeat('- - ', $categories[$catid]->level).$categories[$catid]->title;
				$categoriesValues[] = acymailing_selectOption($catid, $categories[$catid]->title);
			}
		}

		$pagination = new acyPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);

		$tabs = acymailing_get('helper.acytabs');
		echo $tabs->startPane('joomlacontent_tab');
		echo $tabs->startPanel(acymailing_translation('JOOMLA_CONTENT'), 'joomlacontent_content');

		?>
		<script language="javascript" type="text/javascript">
			<!--
			var selectedContents = new Array();
			function applyContent(contentid, rowClass){
				var tmp = selectedContents.indexOf(contentid)
				if(tmp != -1){
					window.document.getElementById('content' + contentid).className = rowClass;
					delete selectedContents[tmp];
				}else{
					window.document.getElementById('content' + contentid).className = 'selectedrow';
					selectedContents.push(contentid);
				}
				updateTag();
			}

			function updateTag(){
				var tag = '';
				var otherinfo = '';
				for(var i = 0; i < document.adminForm.contenttype.length; i++){
					if(document.adminForm.contenttype[i].checked){
						selectedtype = document.adminForm.contenttype[i].value;
						otherinfo += '| type:' + document.adminForm.contenttype[i].value;
					}
				}

				if(document.adminForm.customfields){
					if(document.adminForm.customfields.length == undefined){
						if(document.adminForm.customfields.checked) otherinfo += "| custom:" + document.adminForm.customfields.value;
					}else{
						tmp = 0;
						for(i = 0; i < document.adminForm.customfields.length; i++){
							if(!document.adminForm.customfields[i].checked) continue;
							if(tmp == 0){
								tmp += 1;
								otherinfo += "| custom:" + document.adminForm.customfields[i].value;
							}else{
								otherinfo += "," + document.adminForm.customfields[i].value;
							}
						}
					}
				}

				for(var i = 0; i < document.adminForm.titlelink.length; i++){
					if(document.adminForm.titlelink[i].checked && document.adminForm.titlelink[i].value.length > 1){
						otherinfo += '| ' + document.adminForm.titlelink[i].value;
					}
				}

				var already = 0;
				if(document.adminForm.socialshare){
					for(var i = 0; i < document.adminForm.socialshare.length; i++){
						if(document.adminForm.socialshare[i].checked){
							if(already == 0){
								otherinfo += '| share:' + document.adminForm.socialshare[i].value;
								already++;
							}else{
								otherinfo += ',' + document.adminForm.socialshare[i].value;
							}
						}
					}
				}

				if(selectedtype != 'title'){
					for(var i = 0; i < document.adminForm.author.length; i++){
						if(document.adminForm.author[i].checked && document.adminForm.author[i].value.length > 1){
							otherinfo += '| ' + document.adminForm.author[i].value;
						}
					}
					for(var i = 0; i < document.adminForm.pict.length; i++){
						if(document.adminForm.pict[i].checked){
							otherinfo += '| pict:' + document.adminForm.pict[i].value;
							if(document.adminForm.pict[i].value == 'resized'){
								document.getElementById('pictsize').style.display = '';
								if(document.adminForm.pictwidth.value) otherinfo += '| maxwidth:' + document.adminForm.pictwidth.value;
								if(document.adminForm.pictheight.value) otherinfo += '| maxheight:' + document.adminForm.pictheight.value;
							}else{
								document.getElementById('pictsize').style.display = 'none';
							}
						}
					}
					document.getElementById('format').style.display = '';
				}else{
					document.getElementById('format').style.display = 'none';
				}

				if(document.adminForm.contentformat && document.adminForm.contentformat.value){
					otherinfo += '| format:' + document.adminForm.contentformat.value;
				}

				if(window.document.getElementById('jflang') && window.document.getElementById('jflang').value != ''){
					otherinfo += '|lang:';
					otherinfo += window.document.getElementById('jflang').value;
				}

				for(var i in selectedContents){
					if(selectedContents[i] && !isNaN(i)){
						tag = tag + '{joomlacontent:' + selectedContents[i] + otherinfo + '}<br />';
					}
				}
				setTag(tag);
			}
			//-->
		</script>
		<div class="onelineblockoptions">
			<table width="100%" class="acymailing_table">
				<tr>
					<td>
						<?php echo acymailing_translation('DISPLAY'); ?>
					</td>
					<td colspan="2">
						<?php echo acymailing_radio($contenttype, 'contenttype', 'size="1" onclick="updateTag();"', 'value', 'text', $pageInfo->contenttype); ?>
					</td>
					<td>
						<?php $jflanguages = acymailing_get('type.jflanguages');
						$jflanguages->onclick = 'onchange="updateTag();"';
						echo $jflanguages->display('lang', $pageInfo->lang); ?>
					</td>
				</tr>
				<tr id="format" class="acyplugformat">
					<td valign="top">
						<?php echo acymailing_translation('FORMAT'); ?>
					</td>
					<td valign="top">
						<?php echo $this->acypluginsHelper->getFormatOption('tagcontent'); ?>
					</td>
					<td valign="top"><?php echo acymailing_translation('DISPLAY_PICTURES'); ?></td>
					<td valign="top"><?php echo acymailing_radio($picts, 'pict', 'size="1" onclick="updateTag();"', 'value', 'text', $pageInfo->pict); ?>
						<span id="pictsize" <?php if($pageInfo->pict != 'resized') echo 'style="display:none;"'; ?>><br/><?php echo acymailing_translation('CAPTCHA_WIDTH') ?>
							<input name="pictwidth" type="text" onchange="updateTag();" value="<?php echo $pageInfo->pictwidth; ?>" style="width:30px;"/>
							x <?php echo acymailing_translation('CAPTCHA_HEIGHT') ?>
							<input name="pictheight" type="text" onchange="updateTag();" value="<?php echo $pageInfo->pictheight; ?>" style="width:30px;"/>
						</span>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo acymailing_translation('CLICKABLE_TITLE'); ?>
					</td>
					<td>
						<?php echo acymailing_radio($titlelink, 'titlelink', 'size="1" onclick="updateTag();"', 'value', 'text', $pageInfo->titlelink); ?>
					</td>
					<td>
						<?php echo acymailing_translation('AUTHOR_NAME'); ?>
					</td>
					<td>
						<?php echo acymailing_radio($authorname, 'author', 'size="1" onclick="updateTag();"', 'value', 'text', (string)$pageInfo->author); ?>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo acymailing_translation('SHARE'); ?>
					</td>
				<?php
				$socialMedias = array('facebook' => 'Facebook',
									'linkedin' => 'LinkedIn',
									'twitter' => 'Twitter',
									'google' => 'Google+');

				$cpt = 1;
				foreach($socialMedias as $key => $oneSocial){
					if($cpt == 4){
						$cpt = 1;
						echo '</tr><tr><td/>';
					}
					echo '<td><input value="'.$key.'" name="socialshare" id="'.$key.'" type="checkbox" onclick="updateTag();" /> ';
					echo '<label for="'.$key.'">'.$oneSocial.'</label></td>';
					$cpt++;
				}
				while($cpt != 4){
					$cpt++;
					echo '<td/>';
				}
				?>
				</tr>
			</table>
<?php
		$jversion = preg_replace('#[^0-9\.]#i', '', JVERSION);
		if(version_compare($jversion, '3.7.0', '>=')){
			$query = 'SELECT id, title, group_id FROM #__fields WHERE context = "com_content.article" AND state = 1 ORDER BY title ASC';
			$customFields = acymailing_loadObjectList($query);

			if(!empty($customFields)){
				$query = 'SELECT id, title FROM #__fields_groups WHERE context = "com_content.article" AND state = 1 ORDER BY title ASC';
				$groups = acymailing_loadObjectList($query);
				$defaultGroup = new stdClass();
				$defaultGroup->id = 0;
				$defaultGroup->title = acymailing_translation('ACY_NO_GROUP');
				array_unshift($groups, $defaultGroup);

				echo '<div class="onelineblockoptions">
						<span class="acyblocktitle">'.acymailing_translation('EXTRA_FIELDS').'</span>
						<table class="acymailing_table" cellpadding="1">';
				foreach($groups as $oneGroup){
					echo '<tr><td style="font-weight: bold;">'.$oneGroup->title.'</td>';
					$i = 1;
					foreach($customFields as $oneCF){
						if($oneCF->group_id != $oneGroup->id) continue;
						if($i == 4){
							$i = 1;
							echo '</tr><tr><td/>';
						}
						echo '<td><input value="'.$oneCF->id.'" name="customfields" id="cf_'.$oneCF->id.'" type="checkbox" onclick="updateTag();"/>';
						echo '<label style="margin-left:5px" for="cf_'.$oneCF->id.'">'.$oneCF->title.'</label></td>';
						$i++;
					}
					while($i != 4){
						$i++;
						echo '<td/>';
					}
					echo '</tr>';
				}
				echo '</table></div>';
			}
		}
?>
		</div>
		<div class="onelineblockoptions">
			<table class="acymailing_table_options">
				<tr>
					<td width="100%">
						<?php acymailing_listingsearch($pageInfo->search); ?>
					</td>
					<td nowrap="nowrap">
						<?php echo acymailing_select($categoriesValues, 'filter_cat', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', (int)$pageInfo->filter_cat); ?>
					</td>
				</tr>
			</table>

			<table class="acymailing_table" cellpadding="1" width="100%">
				<thead>
				<tr>
					<th class="title">
					</th>
					<th class="title">
						<?php echo acymailing_gridSort(acymailing_translation('FIELD_TITLE'), 'a.title', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?>
					</th>
					<th class="title">
						<?php echo acymailing_gridSort(acymailing_translation('ACY_AUTHOR'), 'b.name', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?>
					</th>
					<th class="title">
						<?php echo acymailing_gridSort(acymailing_translation(ACYMAILING_J16 ? 'COM_CONTENT_PUBLISHED_DATE' : 'START PUBLISHING'), 'a.publish_up', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?>
					</th>
					<th class="title">
						<?php echo acymailing_gridSort(acymailing_translation('ACY_CREATED'), 'a.created', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?>
					</th>
					<th class="title titleid">
						<?php echo acymailing_gridSort(acymailing_translation('ACY_ID'), 'a.id', $pageInfo->filter->order->dir, $pageInfo->filter->order->value); ?>
					</th>
				</tr>
				</thead>
				<tfoot>
				<tr>
					<td colspan="6">
						<?php echo $pagination->getListFooter(); ?>
						<?php echo $pagination->getResultsCounter(); ?>
					</td>
				</tr>
				</tfoot>
				<tbody>
				<?php
				$k = 0;
				for($i = 0, $a = count($rows); $i < $a; $i++){
					$row =& $rows[$i];
					?>
					<tr id="content<?php echo $row->id ?>" class="<?php echo "row$k"; ?>" onclick="applyContent(<?php echo $row->id.",'row$k'" ?>);" style="cursor:pointer;">
						<td class="acytdcheckbox"></td>
						<td>
							<?php
							$text = '<b>'.acymailing_translation('JOOMEXT_ALIAS').': </b>'.$row->alias;
							echo acymailing_tooltip($text, $row->title, '', $row->title);
							?>
						</td>
						<td>
							<?php
							if(!empty($row->name)){
								$text = '<b>'.acymailing_translation('JOOMEXT_NAME').' : </b>'.$row->name;
								$text .= '<br /><b>'.acymailing_translation('ACY_USERNAME').' : </b>'.$row->username;
								$text .= '<br /><b>'.acymailing_translation('ACY_ID').' : </b>'.$row->created_by;
								echo acymailing_tooltip($text, $row->name, '', $row->name);
							}
							?>
						</td>
						<td align="center">
							<?php echo acymailing_date(strip_tags($row->publish_up), acymailing_translation('DATE_FORMAT_LC4')); ?>
						</td>
						<td align="center">
							<?php echo acymailing_date(strip_tags($row->created), acymailing_translation('DATE_FORMAT_LC4')); ?>
						</td>
						<td align="center">
							<?php echo $row->id; ?>
						</td>
					</tr>
					<?php
					$k = 1 - $k;
				}
				?>
				</tbody>
			</table>
		</div>
		<input type="hidden" name="boxchecked" value="0"/>
		<input type="hidden" name="filter_order" value="<?php echo $pageInfo->filter->order->value; ?>"/>
		<input type="hidden" name="filter_order_Dir" value="<?php echo $pageInfo->filter->order->dir; ?>"/>
		<?php
		echo $tabs->endPanel();
		echo $tabs->startPanel(acymailing_translation('TAG_CATEGORIES'), 'joomlacontent_auto');

		$type = acymailing_getVar('string', 'type');

		?>
		<script language="javascript" type="text/javascript">
			<!--
			window.onload = function(){
				if(window.document.getElementById('tagsauto')){
					window.document.getElementById('tagsauto').onchange = updateAutoTag;
				}
			}
			var selectedCategories = new Array();
			<?php if(!ACYMAILING_J16){ ?>
			function applyAutoContent(secid, catid, rowClass){
				if(selectedCategories[secid] && selectedCategories[secid][catid]){
					window.document.getElementById('content_sec' + secid + '_cat' + catid).className = rowClass;
					delete selectedCategories[secid][catid];
				}else{
					if(!selectedCategories[secid]) selectedCategories[secid] = new Array();
					if(secid == 0){
						for(var isec in selectedCategories){
							for(var icat in selectedCategories[isec]){
								if(selectedCategories[isec][icat] == 'content'){
									window.document.getElementById('content_sec' + isec + '_cat' + icat).className = 'row0';
									delete selectedCategories[isec][icat];
								}
							}
						}
					}else{
						if(selectedCategories[0] && selectedCategories[0][0]){
							window.document.getElementById('content_sec0_cat0').className = 'row0';
							delete selectedCategories[0][0];
						}

						if(catid == 0){
							for(var icat in selectedCategories[secid]){
								if(selectedCategories[secid][icat] == 'content'){
									window.document.getElementById('content_sec' + secid + '_cat' + icat).className = 'row0';
									delete selectedCategories[secid][icat];
								}
							}
						}else{
							if(selectedCategories[secid][0]){
								window.document.getElementById('content_sec' + secid + '_cat0').className = 'row0';
								delete selectedCategories[secid][0];
							}
						}
					}

					window.document.getElementById('content_sec' + secid + '_cat' + catid).className = 'selectedrow';
					selectedCategories[secid][catid] = 'content';
				}

				updateAutoTag();
			}
			<?php }else{ ?>
			function applyAutoContent(catid, rowClass){
				if(selectedCategories[catid]){
					window.document.getElementById('content_cat' + catid).className = rowClass;
					delete selectedCategories[catid];
				}else{
					window.document.getElementById('content_cat' + catid).className = 'selectedrow';
					selectedCategories[catid] = 'content';
				}

				updateAutoTag();
			}
			<?php } ?>

			function updateAutoTag(){
				tag = '{autocontent:';
				<?php if(!ACYMAILING_J16){ ?>
				for(var isec in selectedCategories){
					for(var icat in selectedCategories[isec]){
						if(selectedCategories[isec][icat] == 'content'){
							if(icat != 0){
								tag += 'cat' + icat + '-';
							}else{
								tag += 'sec' + isec + '-';
							}
						}
					}
				}
				<?php }else{ ?>
				for(var icat in selectedCategories){
					if(selectedCategories[icat] == 'content'){
						tag += icat + '-';
					}
				}
				<?php } ?>

				var already = 0;
				if(document.adminForm.autosocialshare){
					for(var i = 0; i < document.adminForm.autosocialshare.length; i++){
						if(document.adminForm.autosocialshare[i].checked){
							if(already == 0){
								tag += '| share:' + document.adminForm.autosocialshare[i].value;
								already++;
							}else{
								tag += ',' + document.adminForm.autosocialshare[i].value;
							}
						}
					}
				}

				if(document.adminForm.min_article && document.adminForm.min_article.value && document.adminForm.min_article.value != 0){
					tag += '| min:' + document.adminForm.min_article.value;
				}
				if(document.adminForm.max_article.value && document.adminForm.max_article.value != 0){
					tag += '| max:' + document.adminForm.max_article.value;
				}
				if(document.adminForm.contentorder.value){
					tag += "| order:" + document.adminForm.contentorder.value + "," + document.adminForm.contentorderdir.value;
				}
				if(document.adminForm.contentfilter && document.adminForm.contentfilter.value){
					tag += document.adminForm.contentfilter.value;
				}
				if(document.adminForm.meta_article && document.adminForm.meta_article.value){
					tag += '| meta:' + document.adminForm.meta_article.value;
				}

				for(var i = 0; i < document.adminForm.contenttypeauto.length; i++){
					if(document.adminForm.contenttypeauto[i].checked){
						selectedtype = document.adminForm.contenttypeauto[i].value;
						tag += '| type:' + document.adminForm.contenttypeauto[i].value;
					}
				}

				if(document.adminForm.customfieldsauto){
					if(document.adminForm.customfieldsauto.length == undefined){
						if(document.adminForm.customfieldsauto.checked) tag += "| custom:" + document.adminForm.customfieldsauto.value;
					}else{
						tmp = 0;
						for(i = 0; i < document.adminForm.customfieldsauto.length; i++){
							if(!document.adminForm.customfieldsauto[i].checked) continue;
							if(tmp == 0){
								tmp += 1;
								tag += "| custom:" + document.adminForm.customfieldsauto[i].value;
							}else{
								tag += "," + document.adminForm.customfieldsauto[i].value;
							}
						}
					}
				}

				for(var i = 0; i < document.adminForm.titlelinkauto.length; i++){
					if(document.adminForm.titlelinkauto[i].checked && document.adminForm.titlelinkauto[i].value.length > 1){
						tag += '|' + document.adminForm.titlelinkauto[i].value;
					}
				}
				if(selectedtype != 'title'){
					for(var i = 0; i < document.adminForm.authorauto.length; i++){
						if(document.adminForm.authorauto[i].checked && document.adminForm.authorauto[i].value.length > 1){
							tag += '|' + document.adminForm.authorauto[i].value;
						}
					}
					for(var i = 0; i < document.adminForm.pictauto.length; i++){
						if(document.adminForm.pictauto[i].checked){
							tag += '| pict:' + document.adminForm.pictauto[i].value;
							if(document.adminForm.pictauto[i].value == 'resized'){
								document.getElementById('pictsizeauto').style.display = '';
								if(document.adminForm.pictwidthauto.value) tag += '| maxwidth:' + document.adminForm.pictwidthauto.value;
								if(document.adminForm.pictheightauto.value) tag += '| maxheight:' + document.adminForm.pictheightauto.value;
							}else{
								document.getElementById('pictsizeauto').style.display = 'none';
							}
						}
					}
					document.getElementById('formatauto').style.display = '';
				}else{
					document.getElementById('formatauto').style.display = 'none';
				}

				if(document.getElementById('contentformatautoinvert').value == 1) tag += '| invert';
				if(document.adminForm.contentformatauto && document.adminForm.contentformatauto.value){
					tag += '| format:' + document.adminForm.contentformatauto.value;
				}

				if(document.adminForm.cols && document.adminForm.cols.value > 1){
					tag += '| cols:' + document.adminForm.cols.value;
				}
				if(window.document.getElementById('jflangauto') && window.document.getElementById('jflangauto').value != ''){
					tag += '| lang:' + window.document.getElementById('jflangauto').value;
				}
				if(window.document.getElementById('jlang') && window.document.getElementById('jlang').value != ''){
					tag += '| language:' + window.document.getElementById('jlang').value;
				}

				if(window.document.getElementById('tagsauto')){
					var tmp = 0;
					for(var i = 0; i < window.document.getElementById('tagsauto').length; i++){
						if(window.document.getElementById('tagsauto')[i].selected){
							if(tmp == 0){
								tag += '| tags:' + window.document.getElementById('tagsauto')[i].value;
								tmp = 1;
							}else{
								tag += ',' + window.document.getElementById('tagsauto')[i].value;
							}
						}
					}
				}

				tag += '}';

				setTag(tag);
			}
			//-->
		</script>
		<div class="onelineblockoptions">
			<table width="100%" class="acymailing_table">
				<tr>
					<td>
						<?php echo acymailing_translation('DISPLAY'); ?>
					</td>
					<td colspan="2">
						<?php echo acymailing_radio($contenttype, 'contenttypeauto', 'size="1" onclick="updateAutoTag();"', 'value', 'text', $this->params->get('default_type', 'intro')); ?>
					</td>
					<td id="languagesauto">
						<?php $jflanguages = acymailing_get('type.jflanguages');
						$jflanguages->onclick = 'onchange="updateAutoTag();"';
						$jflanguages->id = 'jflangauto';
						echo $jflanguages->display('langauto');
						if(empty($jflanguages->found)){
							echo $jflanguages->displayJLanguages('jlangauto');
						}
						?>
					</td>
				</tr>
				<tr id="formatauto" class="acyplugformat">
					<td valign="top">
						<?php echo acymailing_translation('FORMAT'); ?>
					</td>
					<td valign="top">
						<?php echo $this->acypluginsHelper->getFormatOption('tagcontent', 'TOP_LEFT', false, 'updateAutoTag'); ?>
					</td>
					<td valign="top"><?php echo acymailing_translation('DISPLAY_PICTURES'); ?></td>
					<td valign="top"><?php echo acymailing_radio($picts, 'pictauto', 'size="1" onclick="updateAutoTag();"', 'value', 'text', $this->params->get('default_pict', '1')); ?>
						<span id="pictsizeauto" <?php if($this->params->get('default_pict', '1') != 'resized') echo 'style="display:none;"'; ?> ><br/><?php echo acymailing_translation('CAPTCHA_WIDTH') ?>
							<input name="pictwidthauto" type="text" onchange="updateAutoTag();" value="<?php echo $this->params->get('maxwidth', '150'); ?>" style="width:30px;"/>
							x <?php echo acymailing_translation('CAPTCHA_HEIGHT') ?>
							<input name="pictheightauto" type="text" onchange="updateAutoTag();" value="<?php echo $this->params->get('maxheight', '150'); ?>" style="width:30px;"/>
						</span>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo acymailing_translation('CLICKABLE_TITLE'); ?>
					</td>
					<td>
						<?php echo acymailing_radio($titlelink, 'titlelinkauto', 'size="1" onclick="updateAutoTag();"', 'value', 'text', $this->params->get('default_titlelink', 'link')); ?>
					</td>
					<td>
						<?php echo acymailing_translation('AUTHOR_NAME'); ?>
					</td>
					<td>
						<?php echo acymailing_radio($authorname, 'authorauto', 'size="1" onclick="updateAutoTag();"', 'value', 'text', (string)$this->params->get('default_author', '0')); ?>
					</td>
				</tr>
				<tr>
					<?php if(version_compare(JVERSION, '3.1.0', '>=')){ ?>
						<td valign="top">
							<?php echo acymailing_translation('TAGS'); ?>
						</td>
						<td>
							<?php
							$form = JForm::getInstance('acytagcontenttags', JPATH_SITE.DS.'components'.DS.'com_acymailing'.DS.'params'.DS.'tagcontenttags.xml');
							foreach($form->getFieldset('tagcontenttagfield') as $field){
								echo $field->input;
							}
							?>
						</td>
					<?php }else{ ?>
						<td colspan="2"></td>
					<?php } ?>
					<td valign="top"><?php echo acymailing_translation('FIELD_COLUMNS'); ?></td>
					<td valign="top">
						<select name="cols" style="width:150px" onchange="updateAutoTag();" size="1">
							<?php for($o = 1; $o < 11; $o++) echo '<option value="'.$o.'">'.$o.'</option>'; ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo acymailing_translation('MAX_ARTICLE'); ?>
					</td>
					<td>
						<input type="text" name="max_article" style="width:50px" value="20" onchange="updateAutoTag();"/>
					</td>
					<td>
						<?php echo acymailing_translation('ACY_ORDER'); ?>
					</td>
					<td>
						<?php
						$values = array('id' => 'ACY_ID', 'ordering' => 'ACY_ORDERING', 'created' => 'CREATED_DATE', 'modified' => 'MODIFIED_DATE', 'title' => 'FIELD_TITLE', 'hits' => 'ACY_HITS');
						if(ACYMAILING_J16) $values['publish_up'] = 'COM_CONTENT_PUBLISHED_DATE';
						echo $this->acypluginsHelper->getOrderingField($values, 'id', 'DESC', 'updateAutoTag');
						?>
					</td>
				</tr>
				<?php if($this->params->get('metaselect')){ ?>
					<tr>
						<td>
							<?php echo acymailing_translation('META_KEYWORDS'); ?>
						</td>
						<td colspan="3">
							<input type="text" name="meta_article" style="width:200px" value="" onchange="updateAutoTag();"/>
						</td>
					</tr>
				<?php } ?>
				<?php if($type == 'autonews'){ ?>
					<tr>
						<td>
							<?php echo acymailing_translation('MIN_ARTICLE'); ?>
						</td>
						<td>
							<input type="text" name="min_article" style="width:50px" value="1" onchange="updateAutoTag();"/>
						</td>
						<td>
							<?php echo acymailing_translation('JOOMEXT_FILTER'); ?>
						</td>
						<td>
							<?php $filter = acymailing_get('type.contentfilter');
							$filter->onclick = "updateAutoTag();";
							echo $filter->display('contentfilter', '|filter:created'); ?>
						</td>
					</tr>
				<?php } ?>
				<tr>
					<td>
						<?php echo acymailing_translation('SHARE'); ?>
					</td>
					<?php
					$cpt = 1;
					foreach($socialMedias as $key => $oneSocial){
						if($cpt == 4){
							$cpt = 1;
							echo '</tr><tr><td/>';
						}
						echo '<td><input value="'.$key.'" name="autosocialshare" id="auto'.$key.'" type="checkbox" onclick="updateAutoTag();" /> ';
						echo '<label for="auto'.$key.'">'.$oneSocial.'</label></td>';
						$cpt++;
					}
					while($cpt != 4){
						$cpt++;
						echo '<td/>';
					}
					?>
				</tr>
			</table>
<?php
		if(version_compare($jversion, '3.7.0', '>=') && !empty($customFields)){
			echo '<div class="onelineblockoptions">
					<span class="acyblocktitle">'.acymailing_translation('EXTRA_FIELDS').'</span>
					<table class="acymailing_table" cellpadding="1">';
			foreach($groups as $oneGroup){
				echo '<tr><td style="font-weight: bold;">'.$oneGroup->title.'</td>';
				$i = 1;
				foreach($customFields as $oneCF){
					if($oneCF->group_id != $oneGroup->id) continue;
					if($i == 4){
						$i = 1;
						echo '</tr><tr><td/>';
					}
					echo '<td><input value="'.$oneCF->id.'" name="customfieldsauto" id="autocf_'.$oneCF->id.'" type="checkbox" onclick="updateAutoTag();"/>';
					echo '<label style="margin-left:5px" for="autocf_'.$oneCF->id.'">'.$oneCF->title.'</label></td>';
					$i++;
				}
				while($i != 4){
					$i++;
					echo '<td/>';
				}
				echo '</tr>';
			}
			echo '</table></div>';
		}
?>
		</div>

		<div class="onelineblockoptions">
			<table class="acymailing_table" cellpadding="1" width="100%">
				<thead>
				<tr>
					<th class="title"></th>
					<?php if(!ACYMAILING_J16){ ?>
						<th class="title">
							<?php echo acymailing_translation('SECTION'); ?>
						</th>
					<?php } ?>
					<th class="title">
						<?php echo acymailing_translation('TAG_CATEGORIES'); ?>
					</th>
				</tr>
				</thead>
				<tbody>
				<?php
				$k = 0;
				if(!ACYMAILING_J16){
					?>
					<tr id="content_sec0_cat0" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(0,0,'<?php echo "row$k" ?>');" style="cursor:pointer;">
						<td class="acytdcheckbox"></td>
						<td style="font-weight: bold;">
							<?php
							echo acymailing_translation('ACY_ALL');
							?>
						</td>
						<td style="text-align:center;font-weight: bold;">
							<?php
							echo acymailing_translation('ACY_ALL');
							?>
						</td>
					</tr>

					<?php
				}

				$k = 1 - $k;
				$currentSection = '';
				foreach($categories as $row){

					if(!ACYMAILING_J16 && $currentSection != $row->section){
						?>
						<tr id="content_sec<?php echo $row->secid ?>_cat0" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->secid ?>,0,'<?php echo "row$k" ?>');" style="cursor:pointer;">
							<td class="acytdcheckbox"></td>
							<td style="font-weight: bold;">
								<?php
								echo $row->section;
								?>
							</td>
							<td style="text-align:center;font-weight: bold;">
								<?php
								echo acymailing_translation('ACY_ALL');
								?>
							</td>
						</tr>
						<?php
						$k = 1 - $k;
						$currentSection = $row->section;
					}
					if(!ACYMAILING_J16){
						?>
						<tr id="content_sec<?php echo $row->secid ?>_cat<?php echo $row->catid ?>" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->secid ?>,<?php echo $row->catid ?>,'<?php echo "row$k" ?>');" style="cursor:pointer;">
							<td class="acytdcheckbox"></td>
							<td>
							</td>
							<td>
								<?php
								echo $row->category;
								?>
							</td>
						</tr>
						<?php
					}else{ ?>
						<tr id="content_cat<?php echo $row->id ?>" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->id ?>,'<?php echo "row$k" ?>');" style="cursor:pointer;">
							<td class="acytdcheckbox"></td>
							<td>
								<?php
								echo $row->title;
								?>
							</td>
						</tr>
					<?php }
					$k = 1 - $k;
				}
				?>
				</tbody>
			</table>
		</div>
		<?php

		echo $tabs->endPanel();
		echo $tabs->endPane();
	}

	public function acymailing_replacetags(&$email, $send = true){
		$this->_replaceAuto($email);
		$this->_replaceArticles($email);
	}

	private function _replaceArticles(&$email){
		$tags = $this->acypluginsHelper->extractTags($email, 'joomlacontent');
		if(empty($tags)) return;

		$this->newslanguage = new stdClass();
		if(!empty($email->language)){
			$this->newslanguage = acymailing_loadObject('SELECT lang_id, lang_code FROM #__languages WHERE sef = '.acymailing_escapeDB($email->language).' LIMIT 1');
		}

		$this->currentcatid = -1;
		$this->readmore = empty($email->template->readmore) ? acymailing_translation('JOOMEXT_READ_MORE') : '<img class="readmorepict" src="'.ACYMAILING_LIVE.$email->template->readmore.'" alt="'.acymailing_translation('JOOMEXT_READ_MORE', true).'" />';

		require_once JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php';

		if($this->params->get('integration') == 'flexicontent' && file_exists(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php')){
			require_once JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php';
		}

		$tagsReplaced = array();
		foreach($tags as $i => $oneTag){
			if(isset($tagsReplaced[$i])) continue;
			$tagsReplaced[$i] = $this->_replaceContent($oneTag);
		}

		$this->acypluginsHelper->replaceTags($email, $tagsReplaced, true);
	}

	private function _replaceContent(&$tag){
		$oldFormat = empty($tag->format);

		if($tag->id == 'current'){
			$article_id = acymailing_getVar('int', 'articleId');
			if(empty($article_id)) return;
			$tag->id = $article_id;
		}
		if(!ACYMAILING_J16){
			$query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle, c.image AS catpict, s.alias as secalias, s.title as sectitle FROM '.acymailing_table('content', false).' as a ';
			$query .= 'LEFT JOIN '.acymailing_table('users', false).' as b ON a.created_by = b.id ';
			$query .= ' LEFT JOIN '.acymailing_table('categories', false).' AS c ON c.id = a.catid ';
			$query .= ' LEFT JOIN '.acymailing_table('sections', false).' AS s ON s.id = a.sectionid ';
			$query .= 'WHERE a.id = '.$tag->id.' LIMIT 1';
		}else{
			$query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle, c.params AS catparams FROM '.acymailing_table('content', false).' as a ';
			$query .= 'LEFT JOIN '.acymailing_table('users', false).' as b ON a.created_by = b.id ';
			$query .= ' LEFT JOIN '.acymailing_table('categories', false).' AS c ON c.id = a.catid ';
			$query .= 'WHERE a.id = '.$tag->id.' LIMIT 1';
		}

		$article = acymailing_loadObject($query);

		if(empty($article)){
			if(acymailing_isAdmin()) acymailing_enqueueMessage('The article "'.$tag->id.'" could not be loaded', 'notice');
			return '';
		}

		if(empty($tag->lang) && !empty($this->newslanguage) && !empty($this->newslanguage->lang_code)) $tag->lang = $this->newslanguage->lang_code.','.$this->newslanguage->lang_id;

		$this->acypluginsHelper->translateItem($article, $tag, 'content');

		$varFields = array();
		foreach($article as $fieldName => $oneField){
			$varFields['{'.$fieldName.'}'] = $oneField;
		}

		$this->acypluginsHelper->cleanHtml($article->introtext);
		$this->acypluginsHelper->cleanHtml($article->fulltext);


		if($this->params->get('integration') == 'jreviews' && !empty($article->images)){
			$firstpict = explode('|', trim(reset(explode("\n", $article->images))).'|||||||');
			if(!empty($firstpict[0])){
				$picturePath = file_exists(ACYMAILING_ROOT.'images'.DS.'stories'.DS.str_replace('/', DS, $firstpict[0])) ? ACYMAILING_LIVE.'images/stories/'.$firstpict[0] : ACYMAILING_LIVE.'images/'.$firstpict[0];
				$myPict = '<img src="'.$picturePath.'" alt="" hspace="5" style="margin:5px" align="left" border="'.intval($firstpict[5]).'" />';
				$article->introtext = $myPict.$article->introtext;
			}
		}
		$completeId = $article->id;
		$completeCat = $article->catid;

		if(!empty($article->alias)) $completeId .= ':'.$article->alias;
		if(!empty($article->catalias)) $completeCat .= ':'.$article->catalias;

		if(empty($tag->itemid)){
			if(!ACYMAILING_J16){
				$completeSec = $article->sectionid;
				if(!empty($article->secalias)) $completeSec .= ':'.$article->secalias;
				if($this->params->get('integration') == 'flexicontent' && class_exists('FlexicontentHelperRoute')){
					$link = FlexicontentHelperRoute::getItemRoute($completeId, $completeCat, $completeSec);
				}else{
					$link = ContentHelperRoute::getArticleRoute($completeId, $completeCat, $completeSec);
				}
			}else{
				if($this->params->get('integration') == 'flexicontent' && class_exists('FlexicontentHelperRoute')){
					$link = FlexicontentHelperRoute::getItemRoute($completeId, $completeCat);
				}else{
					$link = ContentHelperRoute::getArticleRoute($completeId, $completeCat);
				}
			}
		}else{
			$link = 'index.php?option=com_content&view=article&id='.$completeId.'&catid='.$completeCat;
		}


		if($this->params->get('integration') == 'flexicontent' && !class_exists('FlexicontentHelperRoute')){
			$link = 'index.php?option=com_flexicontent&view=items&id='.$completeId;
		}elseif($this->params->get('integration') == 'jaggyblog'){
			$link = 'index.php?option=com_jaggyblog&task=viewpost&id='.$completeId;
		}

		if(!empty($tag->itemid)) $link .= '&Itemid='.$tag->itemid;
		if(!empty($tag->lang)) $link .= (strpos($link, '?') ? '&' : '?').'lang='.substr($tag->lang, 0, strpos($tag->lang, ACYMAILING_J16 ? '-' : ','));
		if(!empty($tag->autologin)) $link .= (strpos($link, '?') ? '&' : '?').'user={usertag:username|urlencode}&passw={usertag:password|urlencode}';

		if(empty($tag->lang) && !empty($article->language) && $article->language != '*'){
			if(!isset($this->langcodes[$article->language])){
				$this->langcodes[$article->language] = acymailing_loadResult('SELECT sef FROM #__languages WHERE lang_code = '.acymailing_escapeDB($article->language).' ORDER BY `published` DESC LIMIT 1');
				if(empty($this->langcodes[$article->language])) $this->langcodes[$article->language] = $article->language;
			}
			$link .= (strpos($link, '?') ? '&' : '?').'lang='.$this->langcodes[$article->language];
		}

		$nonsefLink = $link;
		$mainurl = acymailing_mainURL($nonsefLink);
		$nonsefLink = $mainurl.$nonsefLink;

		$link = acymailing_frontendLink($link);
		$varFields['{link}'] = $link;

		$afterTitle = '';
		$afterArticle = '';
		$contentText = '';
		$pictPath = '';

		if(!empty($tag->author)){
			$authorName = empty($article->created_by_alias) ? $article->authorname : $article->created_by_alias;
			if($tag->type == 'title') $afterTitle .= '<br />';
			$afterTitle .= '<span class="authorname">'.$authorName.'</span><br />';
		}

		$dateFormat = empty($tag->dateformat) ? acymailing_translation('DATE_FORMAT_LC2') : $tag->dateformat;
		if(!empty($tag->created)){
			if($tag->type == 'title') $afterTitle .= '<br />';
			$varFields['{createddate}'] = acymailing_date($article->created, $dateFormat);
			$afterTitle .= '<span class="createddate">'.$varFields['{createddate}'].'</span><br />';
		}

		if(!empty($tag->modified)){
			if($tag->type == 'title') $afterTitle .= '<br />';
			$varFields['{modifieddate}'] = acymailing_date($article->modified, $dateFormat);
			$afterTitle .= '<span class="modifieddate">'.$varFields['{modifieddate}'].'</span><br />';
		}

		if(!isset($tag->pict) && $tag->type != 'title'){
			if($this->params->get('removepictures', 'never') == 'always' || ($this->params->get('removepictures', 'never') == 'intro' && $tag->type == "intro")){
				$tag->pict = 0;
			}else{
				$tag->pict = 1;
			}
		}

		if(strpos($article->introtext, 'jseblod') !== false && file_exists(ACYMAILING_ROOT.'plugins'.DS.'content'.DS.'cckjseblod.php')){
			global $mainframe;
			include_once(ACYMAILING_ROOT.'plugins'.DS.'content'.DS.'cckjseblod.php');
			if(function_exists('plgContentCCKjSeblod')){
				$paramsContent = JComponentHelper::getParams('com_content');
				$article->text = $article->introtext.$article->fulltext;
				plgContentCCKjSeblod($article, $paramsContent);
				$article->introtext = $article->text;
				$article->fulltext = '';
			}
		}

		if($tag->type != "title"){
			if($tag->type == "intro"){
				$forceReadMore = false;
				$mytag = new stdClass();
				$mytag->wrap = $this->params->get('wordwrap', 0);
				if(empty($article->fulltext)){
					$article->introtext = $this->acypluginsHelper->wrapText($article->introtext, $mytag);
					if(!empty($this->acypluginsHelper->wraped)) $forceReadMore = true;
				}
			}

			if(empty($article->fulltext) || $tag->type != "text"){
				$contentText .= $article->introtext;
			}

			if($tag->type != "intro" && !empty($article->fulltext)){
				if($tag->type != "text" && !empty($article->introtext) && !preg_match('#^<[div|p]#i', trim($article->fulltext))){
					$contentText .= '<br />';
				}
				$contentText .= $article->fulltext;
			}

			$contentText = $this->acypluginsHelper->wrapText($contentText, $tag);
			if(!empty($this->acypluginsHelper->wraped)) $forceReadMore = true;

			if(!empty($tag->clean)){
				$contentText = strip_tags($contentText, '<p><br><span><ul><li><h1><h2><h3><h4><a>');
			}

			$varFields['{picthtml}'] = '';
			if(ACYMAILING_J16 && !empty($article->images) && !empty($tag->pict) && empty($tag->nomainimage)){
				$picthtml = '';
				$images = json_decode($article->images);
				$pictVar = ($tag->type == 'intro') ? 'image_intro' : 'image_fulltext';
				$floatVar = ($tag->type == 'intro') ? 'float_intro' : 'float_fulltext';
				if(!empty($images->$pictVar)){
					if($images->$floatVar != 'right'){
						if(empty($tag->format)) $tag->format = 'TOP_LEFT';
						$images->$floatVar = 'left';
					}elseif(empty($tag->format)) $tag->format = 'TOP_RIGHT';
					$style = 'float:'.$images->$floatVar.';padding-'.(($images->$floatVar == 'right') ? 'left' : 'right').':10px;padding-bottom:10px;';
					if(!empty($tag->link) && empty($tag->nopictlink)) $picthtml .= '<a target="_blank" href="'.$link.'" style="text-decoration:none" >';
					$alt = '';
					$altVar = $pictVar.'_alt';
					if(!empty($images->$altVar)) $alt = $images->$altVar;
					$picthtml .= '<img'.(empty($tag->nopictstyle) ? ' style="'.$style.'"' : '').' alt="'.$alt.'" border="0" src="'.acymailing_rootURI().$images->$pictVar.'" />';
					$pictPath = acymailing_rootURI().$images->$pictVar;
					if(!empty($tag->link) && empty($tag->nopictlink)) $picthtml .= '</a>';
					$varFields['{picthtml}'] = $picthtml;
				}
			}

			$contentText = preg_replace('/^\s*(<img[^>]*>)\s*(?:<br[^>]*>\s*)*/i', '$1', $contentText);

			if(!empty($tag->custom)){
				$tag->custom = explode(',', $tag->custom);
				acymailing_arrayToInteger($tag->custom);

				$articleCFValues = acymailing_loadObjectList('SELECT fv.value, f.id, f.fieldparams, f.params, f.type, f.label, f.default_value 
																FROM #__fields AS f 
																LEFT JOIN #__fields_values AS fv ON fv.field_id = f.id AND fv.item_id = '.intval($tag->id).' 
																WHERE  f.id IN ('.implode(',', $tag->custom).')');

				$fields = array();
				foreach($articleCFValues as $oneVal){
					$fields[$oneVal->id]['values'][] = $oneVal->value;
					$fields[$oneVal->id]['field'] = $oneVal;
				}

				foreach($fields as $oneField){
					if(!empty($oneField['field']->fieldparams)) $oneField['field']->fieldparams = json_decode($oneField['field']->fieldparams, true);
					$oneField['field']->params = json_decode($oneField['field']->params, true);

					if($oneField['values'][0] === NULL){
						if(($oneField['field']->type == 'user' && empty($oneField['field']->default_value)) || ($oneField['field']->type != 'user' && strlen($oneField['field']->default_value) == 0)) continue;
						$oneField['values'] = array($oneField['field']->default_value);
					}

					foreach($oneField['values'] as &$oneFieldVal){
						switch($oneField['field']->type){
							case 'radio':
							case 'list':
							case 'checkboxes':
								foreach($oneField['field']->fieldparams['options'] as $oneOPT){
									if($oneOPT['value'] == $oneFieldVal){
										$oneFieldVal = $oneOPT['name'];
										break;
									}
								}
								break;

							case 'usergrouplist':
								if(empty($this->usergroups)) $this->usergroups = acymailing_loadObjectList('SELECT id, title FROM #__usergroups', 'id');

								$oneFieldVal = $this->usergroups[$oneFieldVal]->title;
								break;

							case 'imagelist':
								if($oneFieldVal == -1){
									$oneFieldVal = NULL;
									continue;
								}

								if(strlen($oneField['field']->fieldparams['directory']) > 1) $oneFieldVal = '/'.$oneFieldVal;
								else $oneField['field']->fieldparams['directory'] = '';
								$oneFieldVal = '<img src="images/'.$oneField['field']->fieldparams['directory'].$oneFieldVal.'" />';
								break;

							case 'url':
								$oneFieldVal = '<a target="_blank" href="'.$oneFieldVal.'">'.$oneFieldVal.'</a>';
								break;

							case 'sql':
								if(empty($oneField['field']->options)){
									$oneField['field']->options = acymailing_loadObjectList($oneField['field']->fieldparams['query'], 'value');
								}

								$oneFieldVal = $oneField['field']->options[$oneFieldVal]->text;
								break;

							case 'user':
								$oneFieldVal = acymailing_currentUserName($oneFieldVal);
								break;

							case 'media':
								$oneFieldVal = '<img src="'.$oneFieldVal.'" />';
								break;

							case 'calendar':
								$format = $oneField['field']->fieldparams['showtime'] == '1' ? 'Y-m-d H:i' : 'Y-m-d';
								$oneFieldVal = acymailing_date(strtotime($oneFieldVal), $format);
								break;
						}
					}

					$replaceme = trim(implode(', ', $oneField['values']), ', ');
					if(empty($replaceme)) continue;

					if($oneField['field']->params['showlabel'] == '1'){
						$label = $oneField['field']->label.': ';
						if($oneField['field']->type == 'imagelist') $label .= '<br/>';
						$replaceme = $label.$replaceme;
					}
					$afterArticle .= '<br />'.$replaceme;
				}
			}
			
			if(file_exists(JPATH_SITE.DS.'plugins'.DS.'attachments') && empty($tag->noattach)){
				try{
					$query = 'SELECT display_name, url, filename '.'FROM #__attachments '.'WHERE (parent_entity = "article" '.'AND parent_id = '.intval($tag->id).')';
					if(ACYMAILING_J16){
						$query .= ' OR (parent_entity = "category" '.'AND parent_id = '.intval($article->catid).')';
					}
					$attachments = acymailing_loadObjectList($query);
				}catch(Exception $e){
					$attachments = array();
				}

				if(!empty($attachments)){
					$afterArticle .= '<br />'.acymailing_translation('ATTACHED_FILES').' :';
					foreach($attachments as $oneAttachment){
						$afterArticle .= '<br /><a target="_blank" href="'.$oneAttachment->url.'">'.(empty($oneAttachment->display_name) ? $oneAttachment->filename : $oneAttachment->display_name).'</a>';
					}
				}
			}

			if(!empty($tag->share)){
				$links = array();
				$shareOpt = explode(',', $tag->share);
				foreach($shareOpt as $socialNetwork){
					$knownNetwork = true;
					$socialNetwork = strtolower(trim($socialNetwork));
					if($socialNetwork == 'facebook'){
						$linkShare = 'http://www.facebook.com/sharer.php?u='.urlencode($nonsefLink).'&t='.urlencode($article->title);
						$picSrc = (file_exists(ACYMAILING_MEDIA.'plugins'.DS.'facebook.png') ? 'media/com_acymailing/plugins/facebook.png' : 'media/com_acymailing/images/facebookshare.png');
						$altText = 'Facebook';
					}elseif($socialNetwork == 'twitter'){
						$text = acymailing_translation_sprintf('SHARE_TEXT', $nonsefLink);
						$linkShare = 'http://twitter.com/home?status='.urlencode($text);
						$picSrc = (file_exists(ACYMAILING_MEDIA.'plugins'.DS.'twitter.png') ? 'media/com_acymailing/plugins/twitter.png' : 'media/com_acymailing/images/twittershare.png');
						$altText = 'Twitter';
					}elseif($socialNetwork == 'linkedin'){
						$linkShare = 'http://www.linkedin.com/shareArticle?mini=true&url='.urlencode($nonsefLink).'&title='.urlencode($article->title);
						$picSrc = (file_exists(ACYMAILING_MEDIA.'plugins'.DS.'linkedin.png') ? 'media/com_acymailing/plugins/linkedin.png' : 'media/com_acymailing/images/linkedin.png');
						$altText = 'LinkedIn';
					}elseif($socialNetwork == 'google'){
						$linkShare = 'https://plus.google.com/share?url='.urlencode($nonsefLink);
						$picSrc = (file_exists(ACYMAILING_MEDIA.'plugins'.DS.'google.png') ? 'media/com_acymailing/plugins/google.png' : 'media/com_acymailing/images/google_plusshare.png');
						$altText = 'Google+';
					}elseif($socialNetwork == 'mailto'){
						$linkShare = 'mailto:?subject='.urlencode($article->title).'&body='.urlencode($article->title.' ('.$nonsefLink.')');
						$picSrc = (file_exists(ACYMAILING_MEDIA.'plugins'.DS.'mailto.png') ? 'media/com_acymailing/plugins/mailto.png' : 'media/com_acymailing/images/mailto.png');
						$altText = 'MailTo';
					}else{
						$knownNetwork = false;
						acymailing_display('Network not found: '.$socialNetwork.'. Availables networks are facebook, twitter, linkedin, google and mailto.', 'warning');
					}
					if($knownNetwork){
						array_push($links, '<a target="_blank" href="'.$linkShare.'" title="'.acymailing_translation_sprintf('SOCIAL_SHARE', $altText).'"><img alt="'.$altText.'" src="'.$picSrc.'" /></a>');
					}
				}
				$afterArticle .= '<br />'.(!empty($tag->sharetxt) ? $tag->sharetxt.' ' : '').implode(' ', $links);
			}
		}

		if(!empty($tag->jtags) && version_compare(JVERSION, '3.1.0', '>=')){
			$tags = acymailing_loadObjectList('SELECT t.id, t.alias, t.title FROM #__tags AS t JOIN #__contentitem_tag_map AS m ON t.id = m.tag_id WHERE t.published = 1 AND m.type_alias = "com_content.article" AND m.content_item_id = '.intval($tag->id));
			if(!empty($tags)){
				$afterArticle .= '<br />';
				foreach($tags as $oneTag){
					$afterArticle .= ' <a target="_blank" href="index.php?option=com_tags&view=tag&id='.$oneTag->id.'-'.$oneTag->alias.'">'.$oneTag->title.'</a> ';
				}
			}
		}

		$readMoreText = empty($tag->readmore) ? $this->readmore : $tag->readmore;
		$varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.$readMoreText.'</span></a>';

		if($tag->type == "intro" && empty($tag->noreadmore) && (!empty($article->fulltext) || $forceReadMore)){
			if(!empty($afterArticle)) $afterArticle .= '<br />';
			$afterArticle .= $varFields['{readmore}'];
		}

		$format = new stdClass();
		$format->tag = $tag;
		$format->title = empty($tag->notitle) ? $article->title : '';
		$format->afterTitle = $afterTitle;
		$format->afterArticle = $afterArticle;
		$format->imagePath = $pictPath;
		$format->description = $contentText;
		$format->link = empty($tag->link) ? '' : $link;
		$format->cols = 2;
		$result = $this->acypluginsHelper->getStandardDisplay($format);

		if(!empty($tag->theme)){
			if(preg_match('#<img[^>]*>#Uis', $article->introtext.$article->fulltext, $pregresult)){
				$cleanContent = strip_tags($result, '<p><br><span><ul><li><h1><h2><h3><h4><a>');
				$tdwidth = (empty($tag->maxwidth) ? $this->params->get('maxwidth', 150) : $tag->maxwidth) + 20;
				$result = '<table cellspacing="0" width="500" cellpadding="0" border="0" ><tr><td class="contentpicture" width="'.$tdwidth.'" valign="top" align="center"><a href="'.$link.'" target="_blank" style="border:0px;text-decoration:none">'.$pregresult[0].'</a></td><td class="contenttext">'.$cleanContent.'</td></tr></table>';
			}
		}

		if($tag->type != 'title') $result = '<div class="acymailing_content">'.$result.'</div>';

		if(!(empty($tag->cattitle) && empty($tag->catpict)) && ((!strpos($article->catid, ',') && $this->currentcatid != $article->catid) || (strpos($article->catid, ',') && !in_array($this->currentcatid, explode(',', $article->catid))))){
			if(strpos($article->catid, ',')){
				$catids = explode(',', $article->catid);
				$this->currentcatid = $catids[0];
			}else{
				$this->currentcatid = $article->catid;
			}

			if(ACYMAILING_J16){
				$params = json_decode($article->catparams);
				$article->catpict = $params->image;
			}

			$resultTitle = $article->cattitle;

			if(!empty($tag->catpict) && !empty($article->catpict)){
				$style = '';
				if(!empty($tag->catmaxwidth)) $style .= 'max-width:'.intval($tag->catmaxwidth).'px;';
				if(!empty($tag->catmaxheight)) $style .= 'max-height:'.intval($tag->catmaxheight).'px;';
				$resultTitle = '<img'.(empty($style) ? '' : ' style="'.$style.'"').' alt="" src="'.$article->catpict.'" />';
				if(!empty($tag->cattitlelink)) $resultTitle = '<a target="_blank" href="index.php?option=com_content&view=category&id='.$this->currentcatid.'">'.$resultTitle.'</a>';
			}else{
				if(!empty($tag->cattitlelink)) $resultTitle = '<a target="_blank" href="index.php?option=com_content&view=category&id='.$this->currentcatid.'">'.$resultTitle.'</a>';
				$resultTitle = '<h3 class="cattitle">'.$resultTitle.'</h3>';
			}

			$result = $resultTitle.$result;
		}

		if($oldFormat){
			if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent_html.php')){
				ob_start();
				require(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent_html.php');
				$result = ob_get_clean();
			}elseif(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent.php')){
				ob_start();
				require(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent.php');
				$result = ob_get_clean();
			}
		}elseif(!empty($tag->template) && file_exists(ACYMAILING_MEDIA.'plugins'.DS.$tag->template)){
			ob_start();
			require(ACYMAILING_MEDIA.'plugins'.DS.$tag->template);
			$result = ob_get_clean();
		}
		$result = str_replace(array_keys($varFields), $varFields, $result);

		$result = $this->acypluginsHelper->removeJS($result);

		$tag->maxheight = empty($tag->maxheight) ? $this->params->get('maxheight', 150) : $tag->maxheight;
		$tag->maxwidth = empty($tag->maxwidth) ? $this->params->get('maxwidth', 150) : $tag->maxwidth;
		$result = $this->acypluginsHelper->managePicts($tag, $result);

		if(!empty($tag->maxchar) && strlen(strip_tags($result)) > $tag->maxchar){
			$result = strip_tags($result);
			for($i = $tag->maxchar; $i > 0; $i--){
				if($result[$i] == ' ') break;
			}
			if(!empty($i)) $result = substr($result, 0, $i).@$tag->textafter;
		}

		return $result;
	}

	private function _replaceAuto(&$email){
		$this->acymailing_generateautonews($email);
		if(empty($this->tags)) return;
		$this->acypluginsHelper->replaceTags($email, $this->tags, true);
	}

	public function acymailing_generateautonews(&$email){
		$time = time();

		$tags = $this->acypluginsHelper->extractTags($email, 'autocontent');
		$return = new stdClass();
		$return->status = true;
		$return->message = '';
		$this->tags = array();

		if(empty($tags)) return $return;

		foreach($tags as $oneTag => $parameter){
			if(isset($this->tags[$oneTag])) continue;
			$allcats = explode('-', $parameter->id);
			$selectedArea = array();
			foreach($allcats as $oneCat){
				if(!ACYMAILING_J16){
					$sectype = substr($oneCat, 0, 3);
					$num = substr($oneCat, 3);
					if(empty($num)) continue;
					if($sectype == 'cat'){
						$selectedArea[] = 'catid = '.(int)$num;
					}elseif($sectype == 'sec'){
						$selectedArea[] = 'sectionid = '.(int)$num;
					}
				}else{
					if(empty($oneCat)) continue;
					$selectedArea[] = intval($oneCat);
				}
			}

			$query = 'SELECT DISTINCT a.id FROM `#__content` as a ';
			$where = array();

			if(!empty($parameter->tags) && version_compare(JVERSION, '3.1.0', '>=')){
				$tagsArray = explode(',', $parameter->tags);
				acymailing_arrayToInteger($tagsArray);
				if(!empty($tagsArray)){
					foreach($tagsArray as $oneTagId){
						$query .= 'JOIN #__contentitem_tag_map AS tagsmap'.$oneTagId.' ON (a.id = tagsmap'.$oneTagId.'.content_item_id AND tagsmap'.$oneTagId.'.type_alias LIKE "com_content.article" AND tagsmap'.$oneTagId.'.tag_id = '.$oneTagId.') ';
					}
				}
			}

			if(!empty($parameter->featured)){
				if(ACYMAILING_J16){
					$where[] = 'a.featured = 1';
				}else{
					$query .= 'JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
					$where[] = 'b.content_id IS NOT NULL';
				}
			}

			if(!empty($parameter->nofeatured)){
				if(ACYMAILING_J16){
					$where[] = 'a.featured = 0';
				}else{
					$query .= 'LEFT JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
					$where[] = 'b.content_id IS NULL';
				}
			}

			if(ACYMAILING_J16 && !empty($parameter->subcats) && !empty($selectedArea)){
				$catinfos = acymailing_loadObjectList('SELECT lft,rgt FROM #__categories WHERE id IN ('.implode(',', $selectedArea).')');
				if(!empty($catinfos)){
					$whereCats = array();
					foreach($catinfos as $onecat){
						$whereCats[] = 'lft > '.$onecat->lft.' AND rgt < '.$onecat->rgt;
					}
					$othercats = acymailing_loadResultArray('SELECT id FROM #__categories WHERE ('.implode(') OR (', $whereCats).')');
					$selectedArea = array_merge($selectedArea, $othercats);
				}
			}

			if($this->newMulticats && (!empty($selectedArea) || !empty($parameter->excludedcats))) $query .= ' JOIN `#__multicats_content_catid` as mcc ON a.id = mcc.item_id ';

			if(!empty($selectedArea)){
				if(!ACYMAILING_J16){
					$where[] = implode(' OR ', $selectedArea);
				}else{
					$filter_cat = '`catid` IN ('.implode(',', $selectedArea).')';
					if(file_exists(JPATH_SITE.DS.'components'.DS.'com_multicats')){
						if($this->newMulticats){
							$filter_cat = 'mcc.`catid` REGEXP "^([0-9]+,)*'.implode('(,[0-9]+)*$" OR mcc.`catid` REGEXP "^([0-9]+,)*', $selectedArea).'(,[0-9]+)*$"';
						}else{
							$filter_cat = '`catid` REGEXP "^([0-9]+,)*'.implode('(,[0-9]+)*$" OR `catid` REGEXP "^([0-9]+,)*', $selectedArea).'(,[0-9]+)*$"';
						}
					}
					$where[] = $filter_cat;
				}
			}

			if(!empty($parameter->excludedcats)){
				$excludedCats = explode('-', $parameter->excludedcats);
				acymailing_arrayToInteger($excludedCats);
				$filter_cat = '`catid` NOT IN ("'.implode('","', $excludedCats).'")';
				if(file_exists(JPATH_SITE.DS.'components'.DS.'com_multicats')){
					if($this->newMulticats){
						$filter_cat = 'mcc.`catid` NOT REGEXP "^([0-9]+,)*'.implode('(,[0-9]+)*$" AND mcc.`catid` NOT REGEXP "^([0-9]+,)*', $excludedCats).'(,[0-9]+)*$"';
					}else{
						$filter_cat = '`catid` NOT REGEXP "^([0-9]+,)*'.implode('(,[0-9]+)*$" AND `catid` NOT REGEXP "^([0-9]+,)*', $excludedCats).'(,[0-9]+)*$"';
					}
				}
				$where[] = $filter_cat;
			}

			if(!empty($parameter->filter) && !empty($email->params['lastgenerateddate'])){
				$condition = '(`publish_up` > \''.date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')).'\' AND `publish_up` < \''.date('Y-m-d H:i:s', $time - date('Z')).'\')';
				$condition .= ' OR (`created` > \''.date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')).'\' AND `created` < \''.date('Y-m-d H:i:s', $time - date('Z')).'\')';
				if($parameter->filter == 'modify'){
					$modify = '(`modified` > \''.date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')).'\' AND `modified` < \''.date('Y-m-d H:i:s', $time - date('Z')).'\')';
					if(!empty($parameter->maxpublished)) $modify = '('.$modify.' AND `publish_up` > \''.date('Y-m-d H:i:s', time() - date('Z') - ((int)$parameter->maxpublished * 60 * 60 * 24)).'\')';
					$condition .= ' OR '.$modify;
				}

				$where[] = $condition;
			}

			if(!empty($parameter->maxcreated)){
				$date = $parameter->maxcreated;
				if(strpos($parameter->maxcreated, '[time]') !== false) $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->maxcreated));
				if(!is_numeric($date)) $date = strtotime($parameter->maxcreated);
				if(empty($date)){
					acymailing_display('Wrong date format ('.$parameter->maxcreated.' in '.$oneTag.'), please use YYYY-MM-DD', 'warning');
				}
				$where[] = '`created` < '.acymailing_escapeDB(date('Y-m-d H:i:s', $date)).' OR `publish_up` < '.acymailing_escapeDB(date('Y-m-d H:i:s', $date));
			}else{
				$where[] = '`publish_up` < \''.date('Y-m-d H:i:s', $time - date('Z')).'\'';
			}

			if(!empty($parameter->mincreated)){
				$date = $parameter->mincreated;
				if(strpos($parameter->mincreated, '[time]') !== false) $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->mincreated));
				if(!is_numeric($date)) $date = strtotime($parameter->mincreated);
				if(empty($date)){
					acymailing_display('Wrong date format ('.$parameter->mincreated.' in '.$oneTag.'), please use YYYY-MM-DD', 'warning');
				}
				$where[] = '`created` > '.acymailing_escapeDB(date('Y-m-d H:i:s', $date)).' OR `publish_up` > '.acymailing_escapeDB(date('Y-m-d H:i:s', $date));
			}


			if(!empty($parameter->meta)){
				$allMetaTags = explode(',', $parameter->meta);
				$metaWhere = array();
				foreach($allMetaTags as $oneMeta){
					if(empty($oneMeta)) continue;
					$metaWhere[] = "`metakey` LIKE '%".acymailing_getEscaped($oneMeta, true)."%'";
				}
				if(!empty($metaWhere)) $where[] = implode(' OR ', $metaWhere);
			}

			$where[] = '`publish_down` > \''.date('Y-m-d H:i:s', $time - date('Z')).'\' OR `publish_down` = 0';
			if(empty($parameter->unpublished)){
				$where[] = 'state = 1';
			}else{
				$where[] = 'state = 0';
			}

			if(!ACYMAILING_J16){
				if(isset($parameter->access)){
					$where[] = 'access <= '.intval($parameter->access);
				}else{
					if($this->params->get('contentaccess', 'registered') == 'registered'){
						$where[] = 'access <= 1';
					}elseif($this->params->get('contentaccess', 'registered') == 'public') $where[] = 'access = 0';
				}
			}elseif(isset($parameter->access)){
				if(strpos($parameter->access, ',')){
					$allAccess = explode(',', $parameter->access);
					acymailing_arrayToInteger($allAccess);
					$where[] = 'access IN ('.implode(',', $allAccess).')';
				}else{
					$where[] = 'access = '.intval($parameter->access);
				}
			}

			if(ACYMAILING_J16 && !empty($parameter->language)){
				$allLanguages = explode(',', $parameter->language);
				$langWhere = 'language IN (';
				foreach($allLanguages as $oneLanguage){
					$langWhere .= acymailing_escapeDB(trim($oneLanguage)).',';
				}
				$where[] = trim($langWhere, ',').')';
			}

			$query .= ' WHERE ('.implode(') AND (', $where).')';
			if(!empty($parameter->order)){
				$ordering = explode(',', $parameter->order);
				if($ordering[0] == 'rand'){
					$query .= ' ORDER BY rand()';
				}else{
					$query .= ' ORDER BY `'.acymailing_secureField($ordering[0]).'` '.acymailing_secureField($ordering[1]).' , a.`id` DESC';
				}
			}

			$start = '';
			if(!empty($parameter->start)) $start = intval($parameter->start).',';

			if(empty($parameter->max)) $parameter->max = 100;

			$query .= ' LIMIT '.$start.(int)$parameter->max;

			$allArticles = acymailing_loadResultArray($query);

			if(!empty($parameter->min) && count($allArticles) < $parameter->min){
				$return->status = false;
				$return->message = 'Not enough articles for the tag '.$oneTag.' : '.count($allArticles).' / '.$parameter->min.' between '.acymailing_getDate($email->params['lastgenerateddate']).' and '.acymailing_getDate($time);
			}

			$stringTag = empty($parameter->noentrytext) ? '' : $parameter->noentrytext;
			if(!empty($allArticles)){
				if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'autocontent.php')){
					ob_start();
					require(ACYMAILING_MEDIA.'plugins'.DS.'autocontent.php');
					$stringTag = ob_get_clean();
				}else{
					$arrayElements = array();
					$numArticle = 1;
					foreach($allArticles as $oneArticleId){
						$args = array();
						$args[] = 'joomlacontent:'.$oneArticleId;
						$args[] = 'num:'.$numArticle++;
						if(!empty($parameter->invert) && $numArticle % 2 == 1) $args[] = 'invert';
						if(!empty($parameter->type)) $args[] = 'type:'.$parameter->type;
						if(!empty($parameter->custom)) $args[] = 'custom:'.$parameter->custom;
						if(!empty($parameter->format)) $args[] = 'format:'.$parameter->format;
						if(!empty($parameter->template)) $args[] = 'template:'.$parameter->template;
						if(!empty($parameter->jtags)) $args[] = 'jtags';
						if(!empty($parameter->link)) $args[] = 'link';
						if(!empty($parameter->author)) $args[] = 'author';
						if(!empty($parameter->autologin)) $args[] = 'autologin';
						if(!empty($parameter->cattitle)) $args[] = 'cattitle';
						if(!empty($parameter->cattitlelink)) $args[] = 'cattitlelink';
						if(!empty($parameter->lang)) $args[] = 'lang:'.$parameter->lang;
						if(!empty($parameter->theme)) $args[] = 'theme';
						if(!empty($parameter->clean)) $args[] = 'clean';
						if(!empty($parameter->notitle)) $args[] = 'notitle';
						if(!empty($parameter->nopictstyle)) $args[] = 'nopictstyle';
						if(!empty($parameter->nopictlink)) $args[] = 'nopictlink';
						if(!empty($parameter->created)) $args[] = 'created';
						if(!empty($parameter->noattach)) $args[] = 'noattach';
						if(!empty($parameter->itemid)) $args[] = 'itemid:'.$parameter->itemid;
						if(!empty($parameter->noreadmore)) $args[] = 'noreadmore';
						if(isset($parameter->pict)) $args[] = 'pict:'.$parameter->pict;
						if(!empty($parameter->wrap)) $args[] = 'wrap:'.$parameter->wrap;
						if(!empty($parameter->maxwidth)) $args[] = 'maxwidth:'.$parameter->maxwidth;
						if(!empty($parameter->maxheight)) $args[] = 'maxheight:'.$parameter->maxheight;
						if(!empty($parameter->readmore)) $args[] = 'readmore:'.$parameter->readmore;
						if(!empty($parameter->dateformat)) $args[] = 'dateformat:'.$parameter->dateformat;
						if(!empty($parameter->textafter)) $args[] = 'textafter:'.$parameter->textafter;
						if(!empty($parameter->maxchar)) $args[] = 'maxchar:'.$parameter->maxchar;
						if(!empty($parameter->share)) $args[] = 'share:'.$parameter->share;
						if(!empty($parameter->sharetxt)) $args[] = 'sharetxt:'.$parameter->sharetxt;
						if(!empty($parameter->catpict)) $args[] = 'catpict';
						if(!empty($parameter->catmaxwidth)) $args[] = 'catmaxwidth:'.$parameter->catmaxwidth;
						if(!empty($parameter->catmaxheight)) $args[] = 'catmaxheight:'.$parameter->catmaxheight;
						if(!empty($parameter->nomainimage)) $args[] = 'nomainimage';
						$arrayElements[] = '{'.implode('|', $args).'}';
					}
					$stringTag = $this->acypluginsHelper->getFormattedResult($arrayElements, $parameter);
				}
			}
			$this->tags[$oneTag] = $stringTag;
		}

		return $return;
	}
}//endclass
tagcontent/index.html000060400000000054152455610250010707 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tagcbuser/tagcbuser.xml000060400000003607152455610250011233 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag and filter : Community Builder</name>
	<creationDate>September 2009</creationDate>
	<version>3.7.2</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2016 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add information from the CB Profile of the user in your newsletters. It also allows you to filter the users based on CB fields and modify these field values</description>
	<files>
		<filename plugin="tagcbuser">tagcbuser.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagcbuser"/>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagcbuser"/>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
tagcbuser/tagcbuser.php000060400000031570152455610250011222 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.6.1
 * @author	acyba.com
 * @copyright	(C) 2009-2017 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTagcbuser extends JPlugin{
	var $sendervalues = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tagcbuser');
			$this->params = new JParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){

		$app = JFactory::getApplication();
		if(!file_exists(ACYMAILING_ROOT.'components'.DS.'com_comprofiler'.DS.'comprofiler.php')) return;
		if($this->params->get('frontendaccess') == 'none' && !$app->isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = JText::_('CB User');
		$onePlugin->function = 'acymailingtagcb_show';
		$onePlugin->help = 'plugin-tagcbuser';

		return $onePlugin;
	}

	function onAcyDisplayFilters(&$type, $context = "massactions"){

		if($this->params->get('displayfilter_'.$context, true) == false) return;
		if(!file_exists(ACYMAILING_ROOT.'components'.DS.'com_comprofiler'.DS.'comprofiler.php')) return;

		$db = JFactory::getDBO();
		$fields = acymailing_getColumns('#__comprofiler');
		if(empty($fields)) return;

		$db->setQuery('SELECT name,title FROM #__comprofiler_fields WHERE `table` LIKE '.$db->Quote('#__comprofiler'));
		$fieldTitles = $db->loadObjectList('name');

		$languages = array();
		if(file_exists(JPATH_SITE.DS.'components'.DS.'com_comprofiler'.DS.'plugin'.DS.'language'.DS.'default_language'.DS.'language.php')){
			if(!defined('CBLIB')) include_once(JPATH_SITE.DS.'libraries/CBLib/CB/Application/CBApplication.php');
			$languages = include_once JPATH_SITE.DS.'components'.DS.'com_comprofiler'.DS.'plugin'.DS.'language'.DS.'default_language'.DS.'language.php';
		}elseif(file_exists(JPATH_SITE.DS.'components'.DS.'com_comprofiler'.DS.'plugin'.DS.'language'.DS.'default_language'.DS.'default_language.php')){
			include_once JPATH_SITE.DS.'components'.DS.'com_comprofiler'.DS.'plugin'.DS.'language'.DS.'default_language'.DS.'default_language.php';
		}

		ksort($fields);
		$cbfield = array();
		foreach($fields as $oneField => $fieldType){
			$text = $oneField;
			if(!empty($fieldTitles[$oneField])){
				if(!empty($languages[$fieldTitles[$oneField]->title])){
					$text .= ' ('.$languages[$fieldTitles[$oneField]->title].')';
				}else{
					if(defined($fieldTitles[$oneField]->title)){
						$text .= ' ('.constant($fieldTitles[$oneField]->title).')';
					}else $text .= ' ('.$fieldTitles[$oneField]->title.')';
				}
			}
			$cbfield[] = JHTML::_('select.option', $oneField, $text);
		}
		$type['cbfield'] = JText::_('CB_FIELD');

		$operators = acymailing_get('type.operators');
		$operators->extra = 'onchange="countresults(__num__)"';

		$return = '<div id="filter__num__cbfield">'.JHTML::_('select.genericlist', $cbfield, "filter[__num__][cbfield][map]", 'class="inputbox" size="1" onchange="countresults(__num__)"', 'value', 'text');
		$return .= ' '.$operators->display("filter[__num__][cbfield][operator]").' <input onchange="countresults(__num__)" class="inputbox" type="text" name="filter[__num__][cbfield][value]" style="width:200px" value="" /></div>';

		return $return;
	}

	function onAcyProcessFilter_cbfield(&$query, $filter, $num){
		$query->leftjoin['cbfield'] = '#__comprofiler AS cbfield ON cbfield.id = sub.userid';
		$query->where[] = $query->convertQuery('cbfield', $filter['map'], $filter['operator'], $filter['value']);
	}

	function onAcyProcessFilterCount_cbfield(&$query, $filter, $num){
		$this->onAcyProcessFilter_cbfield($query, $filter, $num);
		return JText::sprintf('SELECTED_USERS', $query->count());
	}

	function acymailingtagcb_show(){
		?>

		<script language="javascript" type="text/javascript">
			function applyTag(tagname){
				var string = '{cbtag:' + tagname;
				for(var i = 0; i < document.adminForm.typeinfo.length; i++){
					if(document.adminForm.typeinfo[i].checked){
						string += '|info:' + document.adminForm.typeinfo[i].value;
					}
				}
				string += '}';
				setTag(string);
				insertTag();
			}
		</script>
		<?php
		$typeinfo = array();
		$typeinfo[] = JHTML::_('select.option', "receiver", JText::_('RECEIVER_INFORMATION'));
		$typeinfo[] = JHTML::_('select.option', "sender", JText::_('SENDER_INFORMATIONS'));
		echo JHTML::_('acyselect.radiolist', $typeinfo, 'typeinfo', '', 'value', 'text', 'receiver');

		$text = '<table class="acymailing_table" cellpadding="1">';
		$db = JFactory::getDBO();
		$fields = acymailing_getColumns('#__comprofiler');

		$db->setQuery('SELECT name,type FROM #__comprofiler_fields');
		$fieldType = $db->loadObjectList('name');

		$k = 0;

		$text .= '<tr style="cursor:pointer" class="row1" onclick="applyTag(\'thumb\');" ><td class="acytdcheckbox"></td><td>Thumb Avatar</td></tr>';
		foreach($fields as $fieldname => $oneField){
			$type = '';
			if(strpos(strtolower($oneField), 'date') !== false) $type = '|type:date';
			if(!empty($fieldType[$fieldname]) AND $fieldType[$fieldname]->type == 'image') $type = '|type:image';
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="applyTag(\''.$fieldname.$type.'\');" ><td class="acytdcheckbox"></td><td>'.$fieldname.'</td></tr>';
			$k = 1 - $k;
		}


		$db->setQuery("SELECT * FROM #__comprofiler_fields WHERE tablecolumns = '' AND published = 1");
		$otherFields = $db->loadObjectList();
		foreach($otherFields as $oneField){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="applyTag(\'cbapi_'.$oneField->name.'\');" ><td class="acytdcheckbox"></td><td>'.$oneField->name.'</td></tr>';
			$k = 1 - $k;
		}

		$text .= '</table>';

		echo $text;
	}

	function acymailing_replaceusertags(&$email, &$user, $send = true){
		$match = '#(?:{|%7B)cbtag:(.*)(?:}|%7D)#Ui';
		$variables = array('subject', 'body', 'altbody');
		$found = false;
		foreach($variables as $var){
			if(empty($email->$var)) continue;
			$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
			if(empty($results[$var][0])) unset($results[$var]);
		}

		if(!$found) return;

		$uservalues = null;
		$db = JFactory::getDBO();
		if(!empty($user->userid)){
			$db->setQuery('SELECT * FROM '.acymailing_table('comprofiler', false).' WHERE user_id = '.$user->userid.' LIMIT 1');
			$uservalues = $db->loadObject();
		}

		$db->setQuery('SELECT fieldid, `table`, name, type, params FROM #__comprofiler_fields');
		$fieldObjects = $db->loadObjectList('name');

		include_once(ACYMAILING_ROOT.'administrator'.DS.'components'.DS.'com_comprofiler'.DS.'plugin.foundation.php');
		cbimport('cb.database');
		$pluginsHelper = acymailing_get('helper.acyplugins');
		$currentCBUser = null;

		$tags = array();
		foreach($results as $var => $allresults){
			foreach($allresults[0] as $i => $oneTag){
				if(isset($tags[$oneTag])) continue;

				$arguments = explode('|', $allresults[1][$i]);
				$field = $arguments[0];
				unset($arguments[0]);
				$mytag = new stdClass();
				$mytag->default = $this->params->get('default_'.$field, '');
				if(!empty($arguments)){
					foreach($arguments as $onearg){
						$args = explode(':', $onearg);
						if(isset($args[1])){
							$mytag->{$args[0]} = $args[1];
						}else{
							$mytag->{$args[0]} = 1;
						}
					}
				}

				$values = new stdClass();

				if(!empty($mytag->info) AND $mytag->info == 'sender'){
					if(empty($this->sendervalues[$email->mailid]) AND !empty($email->userid)){
						$db->setQuery('SELECT * FROM #__comprofiler WHERE user_id = '.$email->userid.' LIMIT 1');
						$this->sendervalues[$email->mailid] = $db->loadObject();
					}
					if(!empty($this->sendervalues[$email->mailid])) $values = $this->sendervalues[$email->mailid];
				}else{
					$values = $uservalues;
				}

				if(substr($field, 0, 6) == 'cbapi_'){
					if(!empty($mytag->info) AND $mytag->info == 'sender'){
						if(empty($this->sendervalues[$email->mailid]->$field) AND !empty($email->userid)){
							$currentSender = CBuser::getInstance($email->userid);
							$values->$field = $currentSender->getField(substr($field, 6), $mytag->default, 'html', 'none', 'profile', 0, true);
							$this->sendervalues[$email->mailid]->$field = $values->$field;
						}elseif(!empty($this->sendervalues[$email->mailid]->$field)){
							$values->$field = @$this->sendervalues[$email->mailid]->$field;
						}
					}elseif(!empty($user->userid)){
						if(empty($currentCBUser)) $currentCBUser = CBuser::getInstance($user->userid);
						if(!empty($currentCBUser)) $values->$field = $currentCBUser->getField(substr($field, 6), $mytag->default, 'html', 'none', 'profile', 0, true);
						if(empty($values->$field) && !empty($fieldObjects[substr($field, 6)]) && $fieldObjects[substr($field, 6)]->type == 'progress'){
							$fieldObjects[substr($field, 6)]->decodedParams = json_decode($fieldObjects[substr($field, 6)]->params);
							if(!empty($fieldObjects[substr($field, 6)]->decodedParams->prg_fields)){
								$requiredFields = explode('|*|', $fieldObjects[substr($field, 6)]->decodedParams->prg_fields);
								$filled_in = 0;
								foreach($fieldObjects as $oneField){
									if(!in_array($oneField->fieldid, $requiredFields) || !in_array($oneField->table, array('#__comprofiler', '#__users'))) continue;
									$fieldName = $oneField->name;
									if(!empty($currentCBUser->_cbuser->$fieldName)) $filled_in++;
								}
								$values->$field = intval(($filled_in * 100) / count($requiredFields)).'%';
							}
						}
					}
				}

				$replaceme = isset($values->$field) ? $values->$field : $mytag->default;
				if(!empty($mytag->type)){
					if($mytag->type == 'image' AND !empty($replaceme)){
						$replaceme = '<img src="'.ACYMAILING_LIVE.'images/comprofiler/'.$replaceme.'" alt="'.htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8').'" />';
					}
				}

				if($field == 'thumb'){
					$replaceme = '<img src="'.ACYMAILING_LIVE.'images/comprofiler/tn'.$values->avatar.'" alt="'.htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8').'" />';
				}elseif($field == 'avatar'){
					$replaceme = '<img src="'.ACYMAILING_LIVE.'images/comprofiler/'.$values->avatar.'" alt="'.htmlspecialchars(@$user->name, ENT_COMPAT, 'UTF-8').'" />';
				}

				$tags[$oneTag] = $replaceme;
				$pluginsHelper->formatString($tags[$oneTag], $mytag);
			}
		}

		foreach($results as $var => $allresults){
			$email->$var = str_replace(array_keys($tags), $tags, $email->$var);
		}
	}

	function onAcyDisplayActions(&$type){
		$fields = acymailing_getColumns('#__comprofiler');

		$field = array();
		$field[] = JHTML::_('select.option', 0, '- - -');
		foreach($fields as $oneField => $fieldType){
			if(in_array($oneField, array('id', 'user_id', 'hits', 'message_last_sent', 'message_number_sent', 'canvas', 'cbactivation'))) continue;
			$field[] = JHTML::_('select.option', $oneField, $oneField);
		}

		$content = '<div id="action__num__cbfieldval">'.JHTML::_('select.genericlist', $field, "action[__num__][cbfieldval][map]", 'class="inputbox" size="1"', 'value', 'text');
		$content .= ' = <input class="inputbox" type="text" id="action__num__cbfieldvalvalue" name="action[__num__][cbfieldval][value]" style="width:200px" value=""></div>';

		$type['cbfieldval'] = 'Community Builder: '.jtext::_('FIELD');

		return $content;
	}

	function onAcyProcessAction_cbfieldval($cquery, $action, $num){

		$replace = array('{year}', '{month}', '{weekday}', '{day}', '{hour}', '{minute}');
		$replaceBy = array(date('Y'), date('m'), date('N'), date('d'), date('H'), date('i'));
		$newValue = str_replace($replace, $replaceBy, acymailing_replaceDate($action['value']));

		if(preg_match_all('#{(year|month|weekday|day)\|(add|remove):([^}]*)}#Uis', $newValue, $results)){
			foreach($results[0] as $i => $oneMatch){
				$format = str_replace(array('year', 'month', 'weekday', 'day'), array('Y','m','N','d'), $results[1][$i]);
				$delay = str_replace(array('add', 'remove'), array('+', '-'), $results[2][$i]).intval($results[3][$i]).' '.str_replace('weekday', 'day', $results[1][$i]);
				$newValue = str_replace($oneMatch, date($format, strtotime($delay)), $newValue);
			}
		}

		if(empty($action['operator'])) $action['operator'] = '=';

		$fields = array_keys(acymailing_getColumns('#__comprofiler'));
		if(!in_array($action['map'], $fields)) return 'Unexisting field: '.$action['map'].' | The available fields are: '.implode(', ', $fields);

		$query = 'UPDATE #__comprofiler AS cb JOIN #__acymailing_subscriber AS sub ON cb.user_id = sub.userid';
		if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
		if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);

		$query .= " SET cb.`".acymailing_secureField($action['map'])."` = ".$cquery->db->Quote($newValue);
		if(!empty($cquery->where)) $query .= ' WHERE ('.implode(') AND (', $cquery->where).')';

		$cquery->db->setQuery($query);
		$cquery->db->query();
		$nbAffected = $cquery->db->getAffectedRows();
		return JText::sprintf('NB_MODIFIED', $nbAffected);
	}
}//endclass
tagcbuser/index.html000060400000000054152455610250010520 0ustar00<html><body bgcolor="#FFFFFF"></body></html>tagcbuser/tagcbuser_j30.xml000060400000001561152455610250011704 0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.0" method="upgrade" group="acymailing">
	<name>AcyMailing Tag and filter : Community Builder</name>
	<creationDate>September 2009</creationDate>
	<version>3.7.2</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2016 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add information from the CB Profile of the user in your newsletters. It also allows you to filter the users based on CB fields and modify these field values</description>
	<files>
		<filename plugin="tagcbuser">tagcbuser.php</filename>
		<filename>tagcbuser.xml</filename>
		<filename>index.html</filename>
	</files>
</extension>
taguser/index.html000060400000000054152455610250010213 0ustar00<html><body bgcolor="#FFFFFF"></body></html>taguser/taguser.php000060400000047114152455610250010411 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTaguser extends JPlugin{

	var $sendervalues = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'taguser');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){
		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('TAGUSER_TAGUSER');
		$onePlugin->function = 'acymailingtaguser_show';
		$onePlugin->help = 'plugin-taguser';

		return $onePlugin;
	}

	function acymailingtaguser_show(){
		?>

		<script language="javascript" type="text/javascript">
			function applyTag(tagname){
				var string = '{usertag:' + tagname;
				for(var i = 0; i < document.adminForm.typeinfo.length; i++){
					if(document.adminForm.typeinfo[i].checked){
						string += '|info:' + document.adminForm.typeinfo[i].value;
					}
				}
				string += '}';
				setTag(string);
				insertTag();
			}
		</script>
		<?php
		$typeinfo = array();
		$typeinfo[] = acymailing_selectOption("receiver", acymailing_translation('RECEIVER_INFORMATION'));
		$typeinfo[] = acymailing_selectOption("sender", acymailing_translation('SENDER_INFORMATIONS'));
		echo acymailing_radio($typeinfo, 'typeinfo', '', 'value', 'text', 'receiver');


		$notallowed = array('password', 'params', 'sendemail', 'gid', 'block', 'email', 'name', 'id');
		$text = '<div class="onelineblockoptions"><table class="acymailing_table" cellpadding="1">';
		$fields = acymailing_getColumns('#__users');
		if(ACYMAILING_J30) $fields = array_merge($fields, array('usertype' => 'usertype'));

		$descriptions['username'] = acymailing_translation('TAGUSER_USERNAME');
		$descriptions['usertype'] = acymailing_translation('TAGUSER_GROUP');
		$descriptions['lastvisitdate'] = acymailing_translation('TAGUSER_LASTVISIT');
		$descriptions['registerdate'] = acymailing_translation('TAGUSER_REGISTRATION');

		$k = 0;
		foreach($fields as $fieldname => $oneField){
			if(in_array(strtolower($fieldname), $notallowed)) continue;
			$type = '';
			if(strpos(strtolower($oneField), 'date') !== false) $type = '|type:date';
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="applyTag(\''.$fieldname.$type.'\');" ><td class="acytdcheckbox"></td><td>'.$fieldname.'</td><td>'.@$descriptions[strtolower($fieldname)].'</td></tr>';
			$k = 1 - $k;
		}

		if(ACYMAILING_J16){
			$extraFields = acymailing_loadObjectList('SELECT DISTINCT `profile_key` FROM `#__user_profiles`');
			if(!empty($extraFields)){
				foreach($extraFields as $oneField){
					$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="applyTag(\''.$oneField->profile_key.'|type:extra\');" ><td class="acytdcheckbox"></td><td>'.$oneField->profile_key.'</td><td></td></tr>';
					$k = 1 - $k;
				}
			}
		}
		if(ACYMAILING_J30){
			$link = 'index.php/component/users/?task=registration.activate&token={usertag:activation|info:receiver}';
		}elseif(ACYMAILING_J16){
			$link = 'index.php?option=com_users&task=registration.activate&token={usertag:activation|info:receiver}';
		}else{
			$link = 'index.php?option=com_user&task=activate&activation={usertag:activation|info:receiver}';
		}
		$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\''.htmlentities('<a target="_blank" href="'.$link.'">'.acymailing_translation('JOOMLA_CONFIRM_ACCOUNT').'</a>').'\'); insertTag();" ><td class="acytdcheckbox"></td><td>confirmJoomla</td><td>'.acymailing_translation('JOOMLA_CONFIRM_LINK').'</td></tr>';
		$text .= '</table></div>';

		$jversion = preg_replace('#[^0-9\.]#i', '', JVERSION);
		if(version_compare($jversion, '3.7.0', '>=')){
			$query = 'SELECT id, title FROM #__fields_groups WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC';
			$groups = acymailing_loadObjectList($query);
			$defaultGroup = new stdClass();
			$defaultGroup->id = 0;
			$defaultGroup->title = acymailing_translation('ACY_NO_GROUP');
			array_unshift($groups, $defaultGroup);

			$query = 'SELECT id, title, group_id FROM #__fields WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC';
			$customFields = acymailing_loadObjectList($query);

			if(!empty($customFields)){
				$text .= '<div class="onelineblockoptions">
							<span class="acyblocktitle">'.acymailing_translation('EXTRA_FIELDS').'</span>
							<table class="acymailing_table" cellpadding="1">';
				foreach($groups as $oneGroup){
					$openedGroup = false;
					foreach($customFields as $oneCF){
						if($oneCF->group_id != $oneGroup->id) continue;
						if(!$openedGroup){
							$text .= '<tr><td></td><td style="font-weight: bold;">'.$oneGroup->title.'</td><td></td></tr>';
							$openedGroup = true;
						}
						$text .= '<tr style="cursor:pointer" onclick="applyTag(\''.$oneCF->id.'|type:custom\');" ><td class="acytdcheckbox"></td><td>'.$oneCF->title.'</td><td></td></tr>';
					}
				}
				$text .= '</table></div>';
			}
		}


		echo $text;
	}

	function acymailing_replaceusertags(&$email, &$user, $send = true){
		$pluginsHelper = acymailing_get('helper.acyplugins');
		$extractedTags = $pluginsHelper->extractTags($email, 'usertag');
		if(empty($extractedTags)) return;

		$jversion = preg_replace('#[^0-9\.]#i', '', JVERSION);
		if(empty($this->customFields) && version_compare($jversion, '3.7.0', '>=')){
			$this->customFields = acymailing_loadObjectList('SELECT * FROM #__fields WHERE context = "com_users.user"', 'id');
			foreach($this->customFields as &$oneCF){
				if(!empty($oneCF->fieldparams)) $oneCF->fieldparams = json_decode($oneCF->fieldparams, true);
			}
		}

		$tags = array();
		$receivervalues = array();
		foreach($extractedTags as $i => $mytag){
			if(isset($tags[$i])) continue;
			$mytag->default = $this->params->get('default_'.$mytag->id, '');

			$values = new stdClass();
			$idused = 0;
			$save = false;

			if(!empty($mytag->info) && $mytag->info == 'sender' && !empty($email->userid)){
				$idused = $email->userid;
				$save = true;
			}
			if(!empty($mytag->info) && $mytag->info == 'current'){   
				$currentUserid = acymailing_currentUserId();
				if(!empty($currentUserid)) $idused = $currentUserid;
			}
			if((empty($mytag->info) || $mytag->info == 'receiver') && !empty($user->userid)){
				$idused = $user->userid;
			}

			if(!empty($idused) && empty($this->sendervalues[$idused]) && empty($receivervalues[$idused])){
				$receivervalues[$idused] = acymailing_loadObject('SELECT * FROM '.acymailing_table('users', false).' WHERE id = '.intval($idused).' LIMIT 1');

				if(ACYMAILING_J16){
					$receivervalues[$idused]->extraFields = acymailing_loadObjectList('SELECT * FROM #__user_profiles WHERE user_id = '.intval($idused), 'profile_key');
				}

				if($save) $this->sendervalues[$idused] = $receivervalues[$idused];
			}

			if(!empty($this->sendervalues[$idused])){
				$values = $this->sendervalues[$idused];
			}elseif(!empty($receivervalues[$idused])) $values = $receivervalues[$idused];

			if($mytag->id == 'usertype' && ACYMAILING_J16){
				if(empty($this->acyuserHelper)) $this->acyuserHelper = acymailing_get('helper.acyuser');
				$groups = $this->acyuserHelper->getUserGroups($idused);
				$allGroups = array();
				foreach($groups as $oneGroup) $allGroups[] = $oneGroup->title;
				$values->usertype = implode(', ', $allGroups);
			}

			if(empty($mytag->type)) $mytag->type = '';
			if($mytag->type == 'extra'){
				$replaceme = isset($values->extraFields[$mytag->id]) ? trim(json_decode($values->extraFields[$mytag->id]->profile_value), '"') : $mytag->default;
			}elseif($mytag->type == 'custom'){
				$mytag->id = intval($mytag->id);
				if(empty($mytag->id)){
					$replaceme = '';
				}else{
					$userFieldVals = acymailing_loadResultArray('SELECT value FROM #__fields_values WHERE item_id = '.intval($idused).' AND field_id = '.intval($mytag->id));

					$fieldValues = trim(implode(', ', $userFieldVals), ', ');
					if(empty($fieldValues)){
						$defaultValue = acymailing_loadObject('SELECT default_value, type FROM #__fields WHERE id = '.intval($mytag->id));
						if(($defaultValue->type == 'user' && !empty($defaultValue->default_value)) || ($defaultValue->type != 'user' && strlen($defaultValue->default_value) > 0)){
							$userFieldVals = array($defaultValue->default_value);
						}
					}

					foreach($userFieldVals as &$oneFieldVal){
						switch($this->customFields[$mytag->id]->type){
							case 'radio':
							case 'list':
							case 'checkboxes':
								foreach($this->customFields[$mytag->id]->fieldparams['options'] as $oneOPT){
									if($oneOPT['value'] == $oneFieldVal){
										$oneFieldVal = $oneOPT['name'];
										break;
									}
								}
								break;

							case 'usergrouplist':
								if(empty($this->usergroups)) $this->usergroups = acymailing_loadObjectList('SELECT id, title FROM #__usergroups', 'id');

								$oneFieldVal = $this->usergroups[$oneFieldVal]->title;
								break;

							case 'imagelist':
								if(strlen($this->customFields[$mytag->id]->fieldparams['directory']) > 1) $oneFieldVal = '/'.$oneFieldVal;
								else $this->customFields[$mytag->id]->fieldparams['directory'] = '';
								$oneFieldVal = '<img src="images/'.$this->customFields[$mytag->id]->fieldparams['directory'].$oneFieldVal.'" />';
								break;

							case 'url':
								$oneFieldVal = '<a target="_blank" href="'.$oneFieldVal.'">'.$oneFieldVal.'</a>';
								break;

							case 'sql':
								if(empty($this->customFields[$mytag->id]->options)){
									$this->customFields[$mytag->id]->options = acymailing_loadObjectList($this->customFields[$mytag->id]->fieldparams['query'], 'value');
								}

								$oneFieldVal = $this->customFields[$mytag->id]->options[$oneFieldVal]->text;
								break;

							case 'user':
								$oneFieldVal = acymailing_currentUserName($oneFieldVal);
								break;

							case 'media':
								$oneFieldVal = '<img src="'.$oneFieldVal.'" />';
								break;

							case 'calendar':
								$format = $this->customFields[$mytag->id]->fieldparams['showtime'] == '1' ? 'Y-m-d H:i' : 'Y-m-d';
								$oneFieldVal = acymailing_date(strtotime($oneFieldVal), $format);
								break;
						}
					}

					$replaceme = implode(', ', $userFieldVals);
				}
			}else{
				$replaceme = isset($values->{$mytag->id}) ? $values->{$mytag->id} : $mytag->default;
			}

			$tags[$i] = $replaceme;
			$pluginsHelper->formatString($tags[$i], $mytag);
		}

		$pluginsHelper->replaceTags($email, $tags);
	}//endfct

	function onAcyDisplayFilters(&$type, $context = "massactions"){

		if($this->params->get('displayfilter_'.$context, true) == false) return;

		$fields = acymailing_getColumns('#__users');
		if(empty($fields)) return;

		$type['joomlafield'] = acymailing_translation('JOOMLA_FIELD');
		$type['joomlagroup'] = acymailing_translation('ACY_GROUP');

		$field = array();
		$field[] = acymailing_selectOption(0, '- - -');
		foreach($fields as $oneField => $fieldType){
			$field[] = acymailing_selectOption($oneField, $oneField);
		}

		if(ACYMAILING_J16){
			$extraFields = acymailing_loadObjectList('SELECT DISTINCT `profile_key` FROM `#__user_profiles`');
			if(!empty($extraFields)){
				foreach($extraFields as $oneField){
					$field[] = acymailing_selectOption('customfield_'.$oneField->profile_key, $oneField->profile_key);
				}
			}
		}

		$jversion = preg_replace('#[^0-9\.]#i', '', JVERSION);
		if(version_compare($jversion, '3.7.0', '>=')){
			$query = 'SELECT id, title 
						FROM #__fields 
						WHERE context = "com_users.user"
							AND state = 1
							AND type IN ("calendar", "checkboxes", "color", "integer", "list", "imagelist", "radio", "sql", "text", "textarea", "url", "user", "usergrouplist")
						ORDER BY title ASC';
			$customFields = acymailing_loadObjectList($query);
			foreach ($customFields as $oneCF) {
				$field[] = acymailing_selectOption($oneCF->id, $oneCF->title);
			}
		}

		$jsOnChange = "displayCondFilter('displayUserValues', 'toChange__num__',__num__,'map='+document.getElementById('filter__num__joomlafieldmap').value+'&cond='+document.getElementById('filter__num__joomlafieldoperator').value+'&value='+document.getElementById('filter__num__joomlafieldvalue').value); ";

		$operators = acymailing_get('type.operators');
		$operators->extra = 'onchange="'.$jsOnChange.'countresults(__num__)"';

		$return = '<div id="filter__num__joomlafield">'.acymailing_select($field, "filter[__num__][joomlafield][map]", 'class="inputbox" size="1" onchange="'.$jsOnChange.'countresults(__num__)"', 'value', 'text');
		$return .= ' '.$operators->display("filter[__num__][joomlafield][operator]").' <span id="toChange__num__"><input onchange="countresults(__num__)" class="inputbox" type="text" name="filter[__num__][joomlafield][value]" id="filter__num__joomlafieldvalue" style="width:200px" value=""></span></div>';

		if(!ACYMAILING_J16){
			$acl = JFactory::getACL();
			$groups = $acl->get_group_children_tree(null, 'USERS', false);
		}else{
			$groups = acymailing_loadObjectList('SELECT a.*, a.title as text, a.id as value FROM #__usergroups AS a ORDER BY a.lft ASC', 'id');
			foreach($groups as $id => $group){
				if(isset($groups[$group->parent_id])){
					$groups[$id]->level = empty($groups[$group->parent_id]->level) ? 1 : intval($groups[$group->parent_id]->level + 1);
					$groups[$id]->text = str_repeat('- - ', $groups[$id]->level).$groups[$id]->text;
				}
			}
		}

		$inoperator = acymailing_get('type.operatorsin');
		$inoperator->js = 'onchange="countresults(__num__)"';

		$return .= '<div id="filter__num__joomlagroup">'.$inoperator->display("filter[__num__][joomlagroup][type]").' '.acymailing_select($groups, "filter[__num__][joomlagroup][group]", 'class="inputbox" size="1" onchange="countresults(__num__)"', 'value', 'text').'<label for="filter__num__joomlagroupsubgroups"><input type="checkbox" value="1" id="filter__num__joomlagroupsubgroups" name="filter[__num__][joomlagroup][subgroups]" onchange="countresults(__num__)"/>'.acymailing_translation('ACY_SUB_GROUPS').'</label></div>';

		return $return;
	}

	function onAcyTriggerFct_displayUserValues(){
		$num = acymailing_getVar('int', 'num');
		$map = acymailing_getVar('cmd', 'map');
		$cond = acymailing_getVar('string', 'cond', '', '', ACY_ALLOWHTML);
		$value = acymailing_getVar('string', 'value', '', '', ACY_ALLOWHTML);

		$emptyInputReturn = '<input onchange="countresults('.$num.')" class="inputbox" type="text" name="filter['.$num.'][joomlafield][value]" id="filter'.$num.'joomlafieldvalue" style="width:200px" value="'.$value.'">';
		$dateInput = '<input onclick="displayDatePicker(this,event)" onchange="countresults('.$num.')" class="inputbox" type="text" name="filter['.$num.'][joomlafield][value]" id="filter'.$num.'joomlafieldvalue" style="width:200px" value="'.$value.'">';

		if(in_array($map, array('registerDate', 'lastvisitDate', 'lastResetTime'))) return $dateInput;

		if(empty($map) || in_array($map, array('password', 'params', 'optKey', 'otep')) || !in_array($cond, array('=', '!='))) return $emptyInputReturn;

		if(strpos($map, 'customfield_') !== false){
			$prop = acymailing_loadObjectList('SELECT DISTINCT TRIM(BOTH \'"\' FROM `profile_value`) AS value FROM #__user_profiles WHERE profile_key = '.acymailing_escapeDB(str_replace('customfield_', '', $map)).' LIMIT 100');
		}elseif(intval($map) != 0){
			$prop = acymailing_loadObjectList('SELECT DISTINCT `value` FROM #__fields_values WHERE field_id = '.intval($map).' LIMIT 100');
		}else{
			$prop = acymailing_loadObjectList('SELECT DISTINCT `' . acymailing_secureField($map) . '` AS value FROM #__users LIMIT 100');
		}

		if(empty($prop) || count($prop) >= 100 || (count($prop) == 1 && (empty($prop[0]->value) || $prop[0]->value == '-'))) return $emptyInputReturn;

		return acymailing_select($prop, "filter[$num][joomlafield][value]", 'onchange="countresults('.$num.')" class="inputbox" size="1" style="width:200px"', 'value', 'value', $value, 'filter'.$num.'joomlafieldvalue');
	}

	function onAcyProcessFilterCount_joomlafield(&$query, $filter, $num){
		$this->onAcyProcessFilter_joomlafield($query, $filter, $num);
		return acymailing_translation_sprintf('SELECTED_USERS', $query->count());
	}

	function onAcyDisplayFilter_joomlafield($filter){
		return acymailing_translation('JOOMLA_FIELD').' : '.$filter['map'].' '.$filter['operator'].' '.$filter['value'];
	}

	function onAcyProcessFilter_joomlafield(&$query, $filter, $num){
		if(empty($filter['map'])) return;
		$type = '';
		if(strpos($filter['map'], 'customfield_') !== false){
			$query->leftjoin['joomlauserprofiles'.$num] = '#__user_profiles AS joomlauserprofiles'.$num.' ON joomlauserprofiles'.$num.'.user_id = sub.userid AND joomlauserprofiles'.$num.'.profile_key = '.acymailing_escapeDB(str_replace('customfield_', '', $filter['map']));
			$val = trim($filter['value'], '"');
			if(in_array($filter['operator'], array('=', '!=', '<', '>', '<=', '>=', 'BEGINS', 'LIKE', 'NOT LIKE'))){
				$val = '"'.$val;
			}
			if(in_array($filter['operator'], array('=', '!=', '<', '>', '<=', '>=', 'END', 'LIKE', 'NOT LIKE'))){
				$val = $val.'"';
			}

			$query->where[] = $query->convertQuery('joomlauserprofiles'.$num, 'profile_value', $filter['operator'], $val, $type);
		}elseif(intval($filter['map']) != 0){
			$query->leftjoin['joomlauserfields'.$num] = '#__fields_values AS joomlauserfields'.$num.' ON joomlauserfields'.$num.'.item_id = sub.userid AND joomlauserfields'.$num.'.field_id = '.intval($filter['map']);
			$query->where[] = $query->convertQuery('joomlauserfields'.$num, 'value', $filter['operator'], $filter['value'], $type);
		}else{
			$query->leftjoin['joomlauser'.$num] = '#__users AS joomlauser'.$num.' ON joomlauser'.$num.'.id = sub.userid';
			if(in_array($filter['map'], array('registerDate', 'lastvisitDate'))){
				$filter['value'] = acymailing_replaceDate($filter['value']);
				if(!is_numeric($filter['value']) && strtotime($filter['value']) !== false) $filter['value'] = strtotime($filter['value']);
				if(is_numeric($filter['value'])) $filter['value'] = strftime('%Y-%m-%d %H:%M:%S', $filter['value']);
				$type = 'datetime';
			}
			$query->where[] = $query->convertQuery('joomlauser'.$num, $filter['map'], $filter['operator'], $filter['value'], $type);
		}
	}

	function onAcyProcessFilterCount_joomlagroup(&$query, $filter, $num){
		$this->onAcyProcessFilter_joomlagroup($query, $filter, $num);
		return acymailing_translation_sprintf('SELECTED_USERS', $query->count());
	}

	function onAcyProcessFilter_joomlagroup(&$query, $filter, $num){
		$operator = (empty($filter['type']) || $filter['type'] == 'IN') ? 'IS NOT NULL AND joomlauser'.$num.'.'.(ACYMAILING_J16 ? 'user_' : '').'id != 0' : "IS NULL";
		$filter['group'] = intval($filter['group']);

		if(!empty($filter['subgroups'])){
			$groupTable = ACYMAILING_J16 ? 'usergroups' : 'core_acl_aro_groups';
			$lftrgt = acymailing_loadObject('SELECT lft, rgt FROM #__'.$groupTable.' WHERE id = '.$filter['group']);
			$allGroups = acymailing_loadResultArray('SELECT id FROM #__'.$groupTable.' WHERE lft > '.$lftrgt->lft.' AND rgt < '.$lftrgt->rgt);
			array_unshift($allGroups, $filter['group']);
			$value = ' IN ('.implode(', ', $allGroups).')';
		}else{
			$value = ' = '.$filter['group'];
		}

		if(!ACYMAILING_J16){
			$query->leftjoin['joomlauser'.$num] = "#__users AS joomlauser$num ON joomlauser$num.id = sub.userid AND joomlauser$num.gid".$value;
			$query->where[] = "joomlauser$num.id ".$operator;
		}else{
			$query->leftjoin['joomlauser'.$num] = "#__user_usergroup_map AS joomlauser$num ON joomlauser$num.user_id = sub.userid AND joomlauser$num.group_id".$value;
			$query->where[] = "joomlauser$num.user_id ".$operator;
		}
	}
}//endclass

taguser/taguser.xml000060400000004501152455610250010413 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : Joomla User Information</name>
	<creationDate>March 2018</creationDate>
	<version>5.9.6</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add informations of the Joomla user in the Newsletter</description>
	<files>
		<filename plugin="taguser">taguser.php</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-taguser"/>
		<param name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the user fields filter and group filter on the Newsletter creation interface">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-taguser"/>
				<field name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the user fields filter and group filter on the Newsletter creation interface">
					<option value="0">JOOMEXT_NO</option>
					<option value="1">JOOMEXT_YES</option>
				</field>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
tagsubscriber/tagsubscriber.php000060400000044404152455610250012762 0ustar00<?php
/**
 * @package	AcyMailing for Joomla!
 * @version	5.9.6
 * @author	acyba.com
 * @copyright	(C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die('Restricted access');
?><?php

class plgAcymailingTagsubscriber extends JPlugin{

	var $fields = array();

	function __construct(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin = JPluginHelper::getPlugin('acymailing', 'tagsubscriber');
			$this->params = new acyParameter($plugin->params);
		}
	}

	function acymailing_getPluginType(){
		if($this->params->get('frontendaccess') == 'none' && !acymailing_isAdmin()) return;
		$onePlugin = new stdClass();
		$onePlugin->name = acymailing_translation('SUBSCRIBER_SUBSCRIBER');
		$onePlugin->function = 'acymailingtagsubscriber_show';
		$onePlugin->help = 'plugin-tagsubscriber';

		return $onePlugin;
	}

	function acymailingtagsubscriber_show(){
		$fields = acymailing_getColumns('#__acymailing_subscriber');

		$descriptions['subid'] = acymailing_translation('SUBSCRIBER_ID');
		$descriptions['email'] = acymailing_translation('SUBSCRIBER_EMAIL');
		$descriptions['name'] = acymailing_translation('SUBSCRIBER_NAME');
		$descriptions['userid'] = acymailing_translation('SUBSCRIBER_USERID');
		$descriptions['ip'] = acymailing_translation('SUBSCRIBER_IP');
		$descriptions['created'] = acymailing_translation('SUBSCRIBER_CREATED');
		echo '<br style="clear:both;"/>';
		if(acymailing_getVar('none', 'type') == 'notification'){
			$text = '<div class="onelineblockoptions">
						<span class="acyblocktitle">'.acymailing_translation('CURRENT_USER_INFO').'</span>
						<table class="acymailing_table" cellpadding="1">';
			$k = 0;
			foreach($fields as $fieldname => $oneField){
				if(!isset($descriptions[$fieldname]) AND $oneField == 'tinyint') continue;
				if(empty($descriptions[$fieldname])) $descriptions[$fieldname] = '';

				$type = '';
				if(in_array($fieldname, array('created', 'confirmed_date', 'lastclick_date', 'lastsent_date', 'lastopen_date'))) $type = '|type:time';
				$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\'{user:'.$fieldname.$type.'}\');insertTag();" ><td class="acytdcheckbox"></td><td>'.$fieldname.'</td><td>'.$descriptions[$fieldname].'</td></tr>';
				$k = 1 - $k;
			}
			$text .= '</table></div>';
			echo $text;
		}

		$text = '<div class="onelineblockoptions">
					<span class="acyblocktitle">'.acymailing_translation('RECEIVER_INFORMATION').'</span>
					<table class="acymailing_table" cellpadding="1">';

		$others = array();
		$others['{subtag:name|part:first|ucfirst}'] = array('name' => acymailing_translation('SUBSCRIBER_FIRSTPART'), 'desc' => acymailing_translation('SUBSCRIBER_FIRSTPART').' '.acymailing_translation('SUBSCRIBER_FIRSTPART_DESC'));
		$others['{subtag:name|part:last|ucfirst}'] = array('name' => acymailing_translation('SUBSCRIBER_LASTPART'), 'desc' => acymailing_translation('SUBSCRIBER_LASTPART').' '.acymailing_translation('SUBSCRIBER_LASTPART_DESC'));

		$k = 0;

		foreach($others as $tagname => $tag){
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\''.$tagname.'\');insertTag();" ><td class="acytdcheckbox"></td><td>'.$tag['name'].'</td><td>'.$tag['desc'].'</td></tr>';
			$k = 1 - $k;
		}

		foreach($fields as $fieldname => $oneField){
			if(!isset($descriptions[$fieldname]) AND $oneField == 'tinyint') continue;
			if(empty($descriptions[$fieldname])) $descriptions[$fieldname] = '';

			$type = '';
			if(in_array($fieldname, array('created', 'confirmed_date', 'lastclick_date', 'lastopen_date', 'lastsent_date'))) $type = '|type:time';
			$text .= '<tr style="cursor:pointer" class="row'.$k.'" onclick="setTag(\'{subtag:'.$fieldname.$type.'}\');insertTag();" ><td class="acytdcheckbox"></td><td>'.$fieldname.'</td><td>'.$descriptions[$fieldname].'</td></tr>';
			$k = 1 - $k;
		}

		$text .= '</table></div>';

		echo $text;
	}

	function acymailing_replaceusertags(&$email, &$user, $send = true){
		$this->pluginsHelper = acymailing_get('helper.acyplugins');
		$extractedTags = $this->pluginsHelper->extractTags($email, 'subtag');
		if(empty($extractedTags)) return;

		$tags = array();
		foreach($extractedTags as $i => $oneTag){
			if(isset($tags[$i])) continue;
			$tags[$i] = $this->replaceSubTag($oneTag, $user);
		}

		$this->pluginsHelper->replaceTags($email, $tags);
	}

	private function replaceSubTag(&$mytag, $user){
		if(!empty($mytag->juser)){
			$subClass = acymailing_get('class.subscriber');
			if(strpos($mytag->juser, '@') !== false){
				$userTmp = $subClass->get($mytag->juser);
			}else{
				$query = "SELECT * FROM #__users WHERE username= ".acymailing_escapeDB($mytag->juser);
				$JuserTmp = acymailing_loadObject($query);
				if(!empty($JuserTmp->email)) $userTmp = $subClass->get($JuserTmp->email);
			}
			if(!empty($userTmp)){
				$user = $userTmp;
			}else acymailing_enqueueMessage('User not found for tag juser', 'warning');
		}

		$field = $mytag->id;
		if(empty($mytag->titlevalue)){
			$replaceme = (isset($user->$field) && strlen($user->$field) > 0) ? $user->$field : $mytag->default;
		}else{
			$fieldClass = acymailing_get('class.fields');
			if(!isset($this->fields[$field])){
				$this->fields[$field] = $fieldClass->get($field);
			}
			$replaceme = (isset($user->$field) && strlen($user->$field) > 0 && !empty($this->fields[$field]->value[$user->$field]->value)) ? $fieldClass->trans($this->fields[$field]->value[$user->$field]->value) : $mytag->default;
		}
		$replaceme = nl2br($replaceme);

		$this->pluginsHelper->formatString($replaceme, $mytag);

		return $replaceme;
	}

	function onAcyDisplayFilters(&$type, $context = "massactions"){

		if($this->params->get('displayfilter_'.$context, true) == false) return;

		$fields = acymailing_getColumns('#__acymailing_subscriber');
		if(empty($fields)) return;

		$field = array();
		$field[] = acymailing_selectOption(0, '- - -');
		foreach($fields as $oneField => $fieldType){
			$field[] = acymailing_selectOption($oneField, $oneField);
		}
		$type['acymailingfield'] = acymailing_translation('ACYMAILING_FIELD');

		$jsOnChange = "displayCondFilter('displaySubscriberValues', 'toChange__num__',__num__,'map='+document.getElementById('filter__num__acymailingfieldmap').value+'&cond='+document.getElementById('filter__num__acymailingfieldoperator').value+'&value='+document.getElementById('filter__num__acymailingfieldvalue').value); ";

		$operators = acymailing_get('type.operators');
		$operators->extra = 'onchange="'.$jsOnChange.'"';

		$return = '<div id="filter__num__acymailingfield">'.acymailing_select($field, "filter[__num__][acymailingfield][map]", 'onchange="'.$jsOnChange.'" class="inputbox" size="1"', 'value', 'text');
		$return .= ' '.$operators->display("filter[__num__][acymailingfield][operator]").' <span id="toChange__num__"><input onchange="countresults(__num__)" class="inputbox" type="text" name="filter[__num__][acymailingfield][value]" style="width:200px" value="" id="filter__num__acymailingfieldvalue"></span></div>';

		return $return;
	}

	function onAcyTriggerFct_displaySubscriberValues(){
		$num = acymailing_getVar('int', 'num');
		$map = acymailing_getVar('cmd', 'map');
		$cond = acymailing_getVar('string', 'cond', '', '', ACY_ALLOWHTML);
		$value = acymailing_getVar('string', 'value', '', '', ACY_ALLOWHTML);

		$emptyInputReturn = '<input onchange="countresults('.$num.')" class="inputbox" type="text" name="filter['.$num.'][acymailingfield][value]" id="filter'.$num.'acymailingfieldvalue" style="width:200px" value="'.$value.'">';
		$dateInput = '<input onClick="displayDatePicker(this,event)" onchange="countresults('.$num.')" class="inputbox" type="text" name="filter['.$num.'][acymailingfield][value]" id="filter'.$num.'acymailingfieldvalue" style="width:200px" value="'.$value.'">';

		if(in_array($map, array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date'))) return $dateInput;

		if(empty($map) || $map == 'key' || !in_array($cond, array('=', '!='))) return $emptyInputReturn;

		$query = 'SELECT DISTINCT `'.acymailing_secureField($map).'` AS value FROM #__acymailing_subscriber LIMIT 100';
		$prop = acymailing_loadObjectList($query);

		if(empty($prop) || count($prop) >= 100 || (count($prop) == 1 && (empty($prop[0]->value) || $prop[0]->value == '-'))) return $emptyInputReturn;

		return acymailing_select($prop, "filter[$num][acymailingfield][value]", 'onchange="countresults('.$num.')" class="inputbox" size="1" style="width:200px"', 'value', 'value', $value, 'filter'.$num.'acymailingfieldvalue');
	}

	function onAcyDisplayFilter_acymailingfield($filter){
		return acymailing_translation('ACYMAILING_FIELD').' : '.$filter['map'].' '.$filter['operator'].' '.$filter['value'];
	}

	function onAcyProcessFilter_acymailingfield(&$query, $filter, $num){
		if(empty($filter['map'])) return;
		$type = '';
		$value = acymailing_replaceDate($filter['value']);

		if(strpos($filter['value'], '{time}') !== false && !in_array($filter['map'], array('created', 'confirmed_date', 'lastclick_date', 'lastopen_date', 'lastsent_date'))){
			$value = strftime('%Y-%m-%d', $value);
		}

		if(in_array($filter['map'], array('created', 'confirmed_date', 'lastclick_date', 'lastopen_date', 'lastsent_date'))){
			if(!is_numeric($value)) $value = strtotime($value);
			$type = 'timestamp';
		}

		$query->where[] = $query->convertQuery('sub', $filter['map'], $filter['operator'], $value, $type);
	}

	function onAcyProcessFilterCount_acymailingfield(&$query, $filter, $num){
		$this->onAcyProcessFilter_acymailingfield($query, $filter, $num);
		return acymailing_translation_sprintf('SELECTED_USERS', $query->count());
	}

	function onAcyDisplayActions(&$type){
		$config = acymailing_config();

		$type['acymailingfield'] = acymailing_translation('BOUNCE_ACTION');
		$status = array();
		$status[] = acymailing_selectOption('confirm', acymailing_translation('CONFIRM_USERS'));
		$status[] = acymailing_selectOption('unconfirm', acymailing_translation('ACY_ACTION_UNCONFIRM'));
		$status[] = acymailing_selectOption('enable', acymailing_translation('ENABLE_USERS'));
		$status[] = acymailing_selectOption('block', acymailing_translation('BLOCK_USERS'));

		if(acymailing_isAllowed($config->get('acl_subscriber_delete', 'all'))) $status[] = acymailing_selectOption('delete', acymailing_translation('DELETE_USERS'));

		$content = '<div id="action__num__acymailingfield">'.acymailing_select($status, "action[__num__][acymailingfield][action]", 'class="inputbox" size="1"', 'value', 'text').'</div>';

		if(!acymailing_level(3)) return $content;

		$fields = acymailing_getColumns('#__acymailing_subscriber');
		if(empty($fields)) return $content;

		$field = array();
		$field[] = acymailing_selectOption(0, '- - -');
		foreach($fields as $oneField => $fieldType){
			if(in_array($oneField, array('name', 'email', 'subid', 'created', 'ip'))) continue;
			$field[] = acymailing_selectOption($oneField, $oneField);
		}

		$jsOnChange = "if(document.getElementById('action__num__acymailingfieldvalvalue')!= undefined){ currentVal=document.getElementById('action__num__acymailingfieldvalvalue').value;} else{currentVal='';}
			displayCondFilter('displayFieldPossibleValues', 'toChangeAction__num__',__num__,'map='+document.getElementById('action__num__acymailingfieldvalmap').value+'&value='+currentVal+'&operator='+document.getElementById('action__num__acymailingfieldvaloperator').value); ";

		$operator = array();
		$operator[] = acymailing_selectOption('=', '=');
		$operator[] = acymailing_selectOption('+', '+');
		$operator[] = acymailing_selectOption('-', '-');
		$operator[] = acymailing_selectOption('addend', acymailing_translation('ACY_OPERATOR_ADDEND'));
		$operator[] = acymailing_selectOption('addbegin', acymailing_translation('ACY_OPERATOR_ADDBEGINNING'));

		$content .= '<div id="action__num__acymailingfieldval">'.acymailing_select($field, "action[__num__][acymailingfieldval][map]", 'onchange="'.$jsOnChange.'" class="inputbox" size="1"', 'value', 'text');
		$content .= ' '.acymailing_select($operator, "action[__num__][acymailingfieldval][operator]", 'onchange="'.$jsOnChange.'" class="inputbox" size="1" style="width:150px;"', 'value', 'text', '=');
		$content .= ' <span id="toChangeAction__num__"><input class="inputbox" type="text" id="action__num__acymailingfieldvalvalue" name="action[__num__][acymailingfieldval][value]" style="width:200px" value=""></span></div>';

		$type['acymailingfieldval'] = acymailing_translation('SET_SUBSCRIBER_VALUE');

		return $content;
	}

	function onAcyTriggerFct_displayFieldPossibleValues(){
		$num = acymailing_getVar('int', 'num');
		$map = acymailing_getVar('cmd', 'map');
		$value = acymailing_getVar('string', 'value');
		$operator = acymailing_getVar('string', 'operator');

		if(in_array($operator, array('addend', 'addbegin'))){
			$emptyInputReturn = '<textarea class="inputbox" type="text" name="action['.$num.'][acymailingfieldval][value]" id="action'.$num.'acymailingfieldvalvalue" style="width:200px">'.$value.'</textarea>';
		}else{
			$emptyInputReturn = '<input class="inputbox" type="text" name="action['.$num.'][acymailingfieldval][value]" id="action'.$num.'acymailingfieldvalvalue" style="width:200px" value="'.$value.'">';
		}

		if(empty($map) || $map == 'key' || $operator != '=') return $emptyInputReturn;

		$fieldClass = acymailing_get('class.fields');
		$myField = $fieldClass->get($map);
		if(empty($myField) || !in_array($myField->type, array('radio', 'checkbox', 'singledropdown', 'multipledropdown'))) return $emptyInputReturn;

		return $fieldClass->display($myField, '', 'action['.$num.'][acymailingfieldval][value]');
	}

	function onAcyProcessAction_acymailingfieldval($cquery, $action, $num){

		$value = is_array($action['value']) ? implode(',', $action['value']) : $action['value'];
		$replace = array('{year}', '{month}', '{weekday}', '{day}');
		$replaceBy = array(date('Y'), date('m'), date('N'), date('d'));
		$value = str_replace($replace, $replaceBy, $value);

		if(preg_match_all('#{(year|month|weekday|day)\|(add|remove):([^}]*)}#Uis', $value, $results)){
			foreach($results[0] as $i => $oneMatch){
				$format = str_replace(array('year', 'month', 'weekday', 'day'), array('Y','m','N','d'), $results[1][$i]);
				$delay = str_replace(array('add', 'remove'), array('+', '-'), $results[2][$i]).intval($results[3][$i]).' '.str_replace('weekday', 'day', $results[1][$i]);
				$value = str_replace($oneMatch, date($format, strtotime($delay)), $value);
			}
		}

		if(empty($action['operator'])) $action['operator'] = '=';

		preg_match_all('#(?:{|%7B)field:(.*)(?:}|%7D)#Ui', $value, $tags);
		$fields = array_keys(acymailing_getColumns('#__acymailing_subscriber'));
		if(!in_array($action['map'], $fields)) return 'Unexisting field: '.$action['map'].' | The available fields are: '.implode(', ', $fields);

		if(in_array($action['operator'], array('+', '-'))){
			if(empty($tags) || empty($tags[1])){
				$value = intval($value);
			}else{
				if(count($tags[1]) > 1 || substr($value, 0, 1) != '{' || substr($value, strlen($value) - 1, 1) != '}'){
					return 'You can\'t use more than one tag for the + and - operators (you also can\'t add or remove a value from the inserted tag for these two operators)';
				}
				if(!in_array($tags[1][0], $fields)) return 'Unexisting field: '.$tags[1][0].' | The available fields are: '.implode(', ', $fields);
				$value = 'sub.`'.acymailing_secureField($tags[1][0]).'`';
			}
		}else{
			$value = acymailing_escapeDB($value);
			if(!empty($tags)){
				foreach($tags[1] as $i => $oneField){
					if(!in_array($oneField, $fields)) return 'Unexisting field: '.$oneField.' | The available fields are: '.implode(', ', $fields);
					$value = str_replace($tags[0][$i], "', sub.`".acymailing_secureField($oneField)."`, '", $value);
				}
				$value = "CONCAT(".$value.")";
			}
		}

		$query = 'UPDATE #__acymailing_subscriber AS sub';
		if(!empty($cquery->join)) $query .= ' JOIN '.implode(' JOIN ', $cquery->join);
		if(!empty($cquery->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $cquery->leftjoin);

		if($action['operator'] == '='){
			$newValue = $value;
		}elseif(in_array($action['operator'], array('+', '-'))){
			$newValue = "sub.`".acymailing_secureField($action['map'])."` ".$action['operator']." ".$value;
		}elseif($action['operator'] == 'addend'){
			$newValue = "CONCAT(sub.`".acymailing_secureField($action['map'])."`, ".$value.")";
		}elseif($action['operator'] == 'addbegin'){
			$newValue = "CONCAT(".$value.", sub.`".acymailing_secureField($action['map'])."`)";
		}else{
			return 'Non existing operator: '.$action['operator'];
		}

		$query .= " SET sub.`".acymailing_secureField($action['map'])."` = ".$newValue;
		if(!empty($cquery->where)) $query .= ' WHERE ('.implode(') AND (', $cquery->where).')';

		$nbAffected = acymailing_query($query);
		return acymailing_translation_sprintf('NB_MODIFIED', $nbAffected);
	}

	function onAcyProcessAction_acymailingfield($cquery, $action, $num){

		$config = acymailing_config();
		$subClass = acymailing_get('class.subscriber');

		if($action['action'] == 'confirm'){
			$cquery->where['confirmed'] = 'sub.confirmed = 0';
			$allSubids = acymailing_loadResultArray($cquery->getQuery(array('sub.subid')));
			if(!empty($allSubids)){
				$subClass->sendConf = false;
				$subClass->sendWelcome = false;
				$subClass->sendNotif = false;
				foreach($allSubids as $oneId){
					$subClass->confirmSubscription($oneId);
				}
			}
			unset($cquery->where['confirmed']);
			return acymailing_translation_sprintf('NB_CONFIRMED', count($allSubids));
		}

		if($action['action'] == 'enable'){
			$action['map'] = 'enabled';
			$action['value'] = 1;
			return $this->onAcyProcessAction_acymailingfieldval($cquery, $action, $num);
		}

		if($action['action'] == 'block'){
			$action['map'] = 'enabled';
			$action['value'] = 0;
			return $this->onAcyProcessAction_acymailingfieldval($cquery, $action, $num);
		}

		if($action['action'] == 'unconfirm'){
			$action['map'] = 'confirmed';
			$action['value'] = 0;
			return $this->onAcyProcessAction_acymailingfieldval($cquery, $action, $num);
		}

		if($action['action'] == 'delete'){
			if(!acymailing_isAllowed($config->get('acl_subscriber_delete', 'all'))) return 'Not allowed to delete users';
			$query = $cquery->getQuery(array('sub.subid'));
			$allSubids = acymailing_loadResultArray($query);
			$nbAffected = $subClass->delete($allSubids);
			return acymailing_translation_sprintf('IMPORT_DELETE', $nbAffected);
		}

		return 'Filter AcyMailingField error, action not found : '.$action['action'];
	}
}//endclass
tagsubscriber/tagsubscriber.xml000060400000004543152455610250012773 0ustar00<?xml version="1.0" encoding="utf-8"?>

<extension type="plugin" version="2.5" method="upgrade" group="acymailing">
	<name>AcyMailing Tag : Subscriber information</name>
	<creationDate>March 2018</creationDate>
	<version>5.9.6</version>
	<author>Acyba</author>
	<authorEmail>dev@acyba.com</authorEmail>
	<authorUrl>http://www.acyba.com</authorUrl>
	<copyright>Copyright (C) 2009-2018 ACYBA SAS - All rights reserved..</copyright>
	<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
	<description>This plugin enables you to add information of the subscriber in your Newsletter</description>
	<files>
		<filename plugin="tagsubscriber">tagsubscriber.php</filename>
		<filename>index.html</filename>
	</files>
	<params addpath="/components/com_acymailing/params">
		<param name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagsubscriber"/>
		<param name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the subscriber fields filter on the Newsletter creation interface">
			<option value="0">JOOMEXT_NO</option>
			<option value="1">JOOMEXT_YES</option>
		</param>
		<param name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
			<option value="all">Always display this tag system</option>
			<option value="none">Don't display this tag system on the front-end</option>
		</param>
	</params>
	<config>
		<fields name="params" addfieldpath="/components/com_acymailing/params">
			<fieldset name="basic">
				<field name="help" type="help" label="Help" description="Click on the help button to get some help" default="plugin-tagsubscriber"/>
				<field name="displayfilter_mail" type="radio" default="1" label="Display filter" description="Display the subscriber fields filter on the Newsletter creation interface">
					<option value="0">JOOMEXT_NO</option>
					<option value="1">JOOMEXT_YES</option>
				</field>
				<field name="frontendaccess" type="list" default="all" label="Front-end Access" description="You can restrict the access to this tag system with this option">
					<option value="all">Always display this tag system</option>
					<option value="none">Don't display this tag system on the front-end</option>
				</field>
			</fieldset>
		</fields>
	</config>
</extension>
tagsubscriber/index.html000060400000000054152455610250011400 0ustar00<html><body bgcolor="#FFFFFF"></body></html>