feat(deployed): add AcyMailing 6.2.0 (no-source, vetted live)
AcyMailing (Acyba); installed 6.2.0 is on an EOL branch, only 7.7.5+ published -> deployed files. Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
This commit is contained in:
parent
15750207e8
commit
236e3bf5b6
89
deployed/acym/administrator/components/com_acym/acym.php
Normal file
89
deployed/acym/administrator/components/com_acym/acym.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
||||
echo '<p style="color:red">This version of AcyMailing requires at least PHP 5.4.0, it is time to update the PHP version of your server!</p>';
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!include_once(rtrim(JPATH_ADMINISTRATOR, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acym'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')) {
|
||||
echo "Could not load Acy helper file";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (acym_isDebug()) {
|
||||
acym_displayErrors();
|
||||
}
|
||||
|
||||
$ctrl = acym_getVar('cmd', 'ctrl', 'dashboard');
|
||||
$task = acym_getVar('cmd', 'task');
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
if ((($config->get('migration') == 0 && acym_existsAcyMailing59() && acym_getVar('string', 'task') != 'migrationDone') || $config->get('walk_through') == 1) && !acym_isNoTemplate()) {
|
||||
$ctrl = 'dashboard';
|
||||
}
|
||||
|
||||
|
||||
if (!include_once(ACYM_CONTROLLER.$ctrl.'.php')) {
|
||||
acym_redirect(acym_completeLink('dashboard'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$className = ucfirst($ctrl).'Controller';
|
||||
$controller = new $className();
|
||||
|
||||
if (empty($task)) {
|
||||
$task = acym_getVar('cmd', 'defaulttask', $controller->defaulttask);
|
||||
acym_setVar('task', $task);
|
||||
}
|
||||
|
||||
if (file_exists(ACYM_BACK.'extensions')) {
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installExtensions();
|
||||
}
|
||||
|
||||
acym_addScript(
|
||||
true,
|
||||
'var TOGGLE_URL_ACYM = "index.php?option='.ACYM_COMPONENT.'&'.acym_noTemplate().'&ctrl=toggle&'.acym_getFormToken().'";
|
||||
var AJAX_URL_ACYM = "index.php?option='.ACYM_COMPONENT.'&'.acym_noTemplate().'&'.acym_getFormToken().'";
|
||||
var AJAX_URL_ACYBA = "'.ACYM_ACYWEBSITE.'";
|
||||
var MEDIA_URL_ACYM = "'.ACYM_MEDIA_URL.'";
|
||||
var CMS_ACYM = "'.ACYM_CMS.'";
|
||||
var FOUNDATION_FOR_EMAIL = "'.ACYM_CSS.'libraries/foundation_email.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'libraries'.DS.'foundation_email.min.css').'";
|
||||
var ACYM_FIXES_FOR_EMAIL = "'.ACYM_CSS.'email.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'email.min.css').'";
|
||||
var ACYM_REGEX_EMAIL = /^'.acym_getEmailRegex(true).'$/i;
|
||||
var ACYM_JS_TXT = '.acym_getJSMessages().';
|
||||
var ACYM_JOOMLA_MEDIA_IMAGE = "'.ACYM_LIVE.'";'
|
||||
);
|
||||
|
||||
JHtml::_('jquery.framework');
|
||||
acym_addScript(false, 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js');
|
||||
|
||||
acym_addScript(false, ACYM_JS.'libraries/foundation.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'foundation.min.js'));
|
||||
acym_addScript(false, ACYM_JS.'libraries/select2.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'select2.min.js'));
|
||||
|
||||
acym_addStyle(false, 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
|
||||
|
||||
acym_addStyle(false, ACYM_CSS.'libraries/introjs.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'libraries'.DS.'introjs.min.css'));
|
||||
acym_addScript(false, ACYM_JS.'libraries/intro.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'intro.min.js'));
|
||||
|
||||
acym_addScript(false, ACYM_JS.'global.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'global.min.js'));
|
||||
acym_addScript(false, ACYM_JS.'back_global.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'back_global.min.js'));
|
||||
acym_addStyle(false, ACYM_CSS.'back_global.min.css?v='.filemtime(ACYM_MEDIA.'css'.DS.'back_global.min.css'));
|
||||
if (file_exists(ACYM_MEDIA.'js'.DS.'back'.DS.$ctrl.'.min.js')) {
|
||||
acym_addScript(false, ACYM_JS.'back/'.$ctrl.'.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'back'.DS.$ctrl.'.min.js'));
|
||||
}
|
||||
|
||||
$controller->loadScripts($task);
|
||||
$controller->$task();
|
||||
69
deployed/acym/administrator/components/com_acym/acym.xml
Normal file
69
deployed/acym/administrator/components/com_acym/acym.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="2.5" method="upgrade">
|
||||
<name>Acym</name>
|
||||
<creationDate>August 2019</creationDate>
|
||||
<version>6.2.0</version>
|
||||
<level>starter</level>
|
||||
<author>Acyba</author>
|
||||
<authorEmail>dev@acyba.com</authorEmail>
|
||||
<authorUrl>https://www.acyba.com</authorUrl>
|
||||
<copyright>Copyright (C) 2009-2019 ACYBA SAS - All rights reserved.</copyright>
|
||||
<description>Manage your Mailing lists and e-mail marketing campaigns</description>
|
||||
<license>GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html</license>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB.com_acym.ini</language>
|
||||
<language tag="en-US">en-US.com_acym.ini</language>
|
||||
</languages>
|
||||
<install>
|
||||
<sql>
|
||||
<file charset="utf8" driver="mysql">tables.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<scriptfile>install.joomla.php</scriptfile>
|
||||
<files folder="front">
|
||||
<folder>controllers</folder>
|
||||
<folder>inc</folder>
|
||||
<folder>views</folder>
|
||||
<folder>params</folder>
|
||||
<filename>acym.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>router.php</filename>
|
||||
</files>
|
||||
<media folder="media" destination="com_acym">
|
||||
<folder>css</folder>
|
||||
<folder>images</folder>
|
||||
<folder>js</folder>
|
||||
<filename>index.html</filename>
|
||||
</media>
|
||||
<administration>
|
||||
<files folder="back">
|
||||
<folder>classes</folder>
|
||||
<folder>controllers</folder>
|
||||
<folder>dynamics</folder>
|
||||
<folder>extensions</folder>
|
||||
<folder>helpers</folder>
|
||||
<folder>library</folder>
|
||||
<folder>types</folder>
|
||||
<folder>views</folder>
|
||||
<folder>templates</folder>
|
||||
<filename>acym.php</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>tables.sql</filename>
|
||||
</files>
|
||||
<menu img="../media/com_acym/images/icons/logo_acym.png" link="option=com_acym">COM_ACYM</menu>
|
||||
<submenu>
|
||||
<menu link="option=com_acym&ctrl=users">ACYM_USERS</menu>
|
||||
<menu link="option=com_acym&ctrl=fields">ACYM_CUSTOM_FIELDS</menu>
|
||||
<menu link="option=com_acym&ctrl=lists">ACYM_LISTS</menu>
|
||||
<menu link="option=com_acym&ctrl=campaigns">ACYM_CAMPAIGNS</menu>
|
||||
<menu link="option=com_acym&ctrl=mails">ACYM_TEMPLATES</menu>
|
||||
<menu link="option=com_acym&ctrl=automation">ACYM_AUTOMATION</menu>
|
||||
<menu link="option=com_acym&ctrl=queue">ACYM_QUEUE</menu>
|
||||
<menu link="option=com_acym&ctrl=stats">ACYM_STATISTICS</menu>
|
||||
<menu link="option=com_acym&ctrl=bounces">ACYM_BOUNCE_HANDLING</menu>
|
||||
<menu link="option=com_acym&ctrl=configuration">ACYM_CONFIGURATION</menu>
|
||||
</submenu>
|
||||
</administration>
|
||||
</extension>
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymactionClass extends acymClass
|
||||
{
|
||||
var $table = 'action';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function getActionsByStepId($stepId)
|
||||
{
|
||||
$query = 'SELECT action.* FROM #__acym_action AS action LEFT JOIN #__acym_condition AS conditionT ON action.condition_id = conditionT.id WHERE conditionT.step_id = '.intval($stepId).' ORDER BY action.order';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getActionsByConditionId($id)
|
||||
{
|
||||
$query = 'SELECT action.* FROM #__acym_action as action LEFT JOIN #__acym_condition as acycondition ON acycondition.id = action.condition_id WHERE acycondition.id = '.intval($id);
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return acym_loadObjectList('SELECT * FROM #__acym_action');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymautomationClass extends acymClass
|
||||
{
|
||||
|
||||
var $table = 'automation';
|
||||
var $pkey = 'id';
|
||||
var $didAnAction = false;
|
||||
var $report = [];
|
||||
|
||||
public function getMatchingAutomations($settings)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_automation';
|
||||
$queryCount = 'SELECT COUNT(id) FROM #__acym_automation';
|
||||
$filters = [];
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
} else {
|
||||
$query .= ' ORDER BY id asc';
|
||||
}
|
||||
$results['automations'] = acym_loadObjectList($query, '', $settings['offset'], $settings['automationsPerPage']);
|
||||
|
||||
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_automation WHERE `id` = '.intval($id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function save($automation)
|
||||
{
|
||||
foreach ($automation as $oneAttribute => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
$automation->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
return parent::save($automation);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$steps = acym_loadResultArray('SELECT id FROM #__acym_step WHERE automation_id IN ('.implode(',', $elements).')');
|
||||
$stepClass = acym_get('class.step');
|
||||
$stepsDeleted = $stepClass->delete($steps);
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function trigger($trigger, $data = [])
|
||||
{
|
||||
if (!acym_level(2)) return;
|
||||
|
||||
$stepClass = acym_get('class.step');
|
||||
$actionClass = acym_get('class.action');
|
||||
$conditionClass = acym_get('class.condition');
|
||||
$steps = $stepClass->getActiveStepByTrigger($trigger);
|
||||
|
||||
$data['time'] = time();
|
||||
foreach ($steps as $step) {
|
||||
$execute = false;
|
||||
|
||||
if (!empty($step->next_execution) && $step->next_execution <= $data['time']) {
|
||||
$execute = true;
|
||||
}
|
||||
|
||||
acym_trigger('onAcymExecuteTrigger', [&$step, &$execute, $data]);
|
||||
|
||||
$data['automation'] = $this->getOneById($step->automation_id);
|
||||
|
||||
if ($execute) {
|
||||
$step->last_execution = $data['time'];
|
||||
$conditions = $conditionClass->getConditionsByStepId($step->id);
|
||||
if (!empty($conditions)) {
|
||||
foreach ($conditions as $condition) {
|
||||
if (!$this->_verifyCondition($condition->conditions, $data)) continue;
|
||||
|
||||
$actions = $actionClass->getActionsByStepId($step->id);
|
||||
if (empty($actions)) continue;
|
||||
|
||||
foreach ($actions as $action) {
|
||||
$this->execute($action, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$stepClass->save($step);
|
||||
}
|
||||
}
|
||||
|
||||
public function execute($action, $data = [])
|
||||
{
|
||||
$userTriggeringAction = empty($data['userId']) ? 0 : $data['userId'];
|
||||
$action->actions = json_decode($action->actions, true);
|
||||
if (empty($action->actions)) return false;
|
||||
|
||||
$isMassAction = false;
|
||||
static $massAction = 0;
|
||||
if (empty($action->id)) {
|
||||
$action->id = $massAction--;
|
||||
$isMassAction = true;
|
||||
}
|
||||
|
||||
$action->filters = json_decode($action->filters, true);
|
||||
if (empty($action->filters)) return false;
|
||||
|
||||
|
||||
$query = acym_get('class.query');
|
||||
|
||||
$initialWhere = ['1 = 1'];
|
||||
$query->removeFlag($action->id);
|
||||
|
||||
if (!empty($action->filters['type_filter']) && $action->filters['type_filter'] == 'user') {
|
||||
$initialWhere = ['user.id = '.intval($userTriggeringAction)];
|
||||
}
|
||||
|
||||
$typeFilter = $action->filters['type_filter'];
|
||||
|
||||
unset($action->filters['type_filter']);
|
||||
if (empty($action->filters)) {
|
||||
$query->where = $initialWhere;
|
||||
}
|
||||
|
||||
foreach ($action->filters as $or => $orValue) {
|
||||
if (empty($orValue)) {
|
||||
continue;
|
||||
}
|
||||
$num = 0;
|
||||
$query->where = $initialWhere;
|
||||
foreach ($orValue as $and => $andValue) {
|
||||
$num++;
|
||||
foreach ($andValue as $filterName => $filterOptions) {
|
||||
acym_trigger('onAcymProcessFilter_'.$filterName, [&$query, &$filterOptions, &$num]);
|
||||
}
|
||||
}
|
||||
|
||||
$query->addFlag($action->id);
|
||||
}
|
||||
|
||||
$this->didAnAction = $this->didAnAction || $query->count() > 0;
|
||||
foreach ($action->actions as $and => $andValue) {
|
||||
foreach ($andValue as $actionName => $actionOptions) {
|
||||
$this->report = array_merge(
|
||||
$this->report,
|
||||
acym_trigger(
|
||||
'onAcymProcessAction_'.$actionName,
|
||||
[&$query, &$actionOptions, ['automationAdmin' => !empty($data['automation']->admin), 'user_id' => $userTriggeringAction]]
|
||||
)
|
||||
);
|
||||
$action->actions[$and][$actionName] = $actionOptions;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isMassAction) {
|
||||
$action->filters['type_filter'] = $typeFilter;
|
||||
$action->filters = json_encode($action->filters);
|
||||
$action->actions = json_encode($action->actions);
|
||||
$actionClass = acym_get('class.action');
|
||||
$actionClass->save($action);
|
||||
}
|
||||
|
||||
$query->removeFlag($action->id);
|
||||
|
||||
return $this->didAnAction;
|
||||
}
|
||||
|
||||
private function _verifyCondition($conditions, $data = [])
|
||||
{
|
||||
if (empty($conditions)) return true;
|
||||
$userTriggeringAction = empty($data['userId']) ? 0 : $data['userId'];
|
||||
|
||||
$conditions = json_decode($conditions, true);
|
||||
$query = acym_get('class.query');
|
||||
$initialWhere = ['1 = 1'];
|
||||
if (!empty($conditions['type_condition']) && $conditions['type_condition'] == 'user') {
|
||||
$initialWhere = ['user.id = '.intval($userTriggeringAction)];
|
||||
}
|
||||
unset($conditions['type_condition']);
|
||||
|
||||
if (empty($conditions)) return true;
|
||||
|
||||
foreach ($conditions as $or => $orValue) {
|
||||
if (empty($orValue)) continue;
|
||||
|
||||
$conditionNotValid = 0;
|
||||
$num = 0;
|
||||
foreach ($orValue as $and => $andValue) {
|
||||
$num++;
|
||||
$query->where = $initialWhere;
|
||||
foreach ($andValue as $filterName => $filterOptions) {
|
||||
acym_trigger('onAcymProcessCondition_'.$filterName, [&$query, &$filterOptions, &$num, &$conditionNotValid]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($conditionNotValid == 0) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAutomationsAdmin($ids = [])
|
||||
{
|
||||
acym_arrayToInteger($ids);
|
||||
|
||||
$query = 'SELECT * FROM #__acym_automation WHERE `admin` = 1';
|
||||
if (!empty($ids)) $query .= ' AND `id` IN ('.implode(', ', $ids).')';
|
||||
|
||||
return acym_loadObjectList($query, 'name');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymbounceClass extends acymClass
|
||||
{
|
||||
var $table = "bounce";
|
||||
var $pkey = "id";
|
||||
|
||||
public function getMatchingRules()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_rule ORDER BY `ordering` ASC';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOrderingNumber()
|
||||
{
|
||||
$query = 'SELECT COUNT(id) FROM #__acym_rule';
|
||||
|
||||
return acym_loadResult($query);
|
||||
}
|
||||
|
||||
public function cleanTable()
|
||||
{
|
||||
acym_query('TRUNCATE TABLE `#__acym_rule`');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,422 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymcampaignClass extends acymClass
|
||||
{
|
||||
|
||||
var $table = 'campaign';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_campaign';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getMatchingCampaigns($settings)
|
||||
{
|
||||
$tagClass = acym_get('class.tag');
|
||||
$mailClass = acym_get('class.mail');
|
||||
$statClass = acym_get('class.mailstat');
|
||||
$query = 'SELECT campaign.*, mail.name FROM #__acym_campaign AS campaign';
|
||||
$queryCount = 'SELECT COUNT(campaign.id) FROM #__acym_campaign AS campaign';
|
||||
$filters = [];
|
||||
$mailIds = [];
|
||||
|
||||
$query .= ' JOIN #__acym_mail AS mail ON campaign.mail_id = mail.id';
|
||||
$queryCount .= ' JOIN #__acym_mail AS mail ON campaign.mail_id = mail.id';
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$tagJoin = ' JOIN #__acym_tag AS tag ON campaign.mail_id = tag.id_element';
|
||||
$query .= $tagJoin;
|
||||
$queryCount .= $tagJoin;
|
||||
$filters[] = 'tag.name = '.acym_escapeDB($settings['tag']);
|
||||
$filters[] = 'tag.type = "mail"';
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'mail.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
$table = in_array($settings['ordering'], ['name', 'creation_date']) ? 'mail' : 'campaign';
|
||||
$query .= ' ORDER BY '.$table.'.'.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
}
|
||||
|
||||
$results['campaigns'] = $mailClass->decode(acym_loadObjectList($query, '', $settings['offset'], $settings['campaignsPerPage']));
|
||||
|
||||
foreach ($results['campaigns'] as $oneCampaign) {
|
||||
array_push($mailIds, $oneCampaign->mail_id);
|
||||
$oneCampaign->tags = '';
|
||||
}
|
||||
|
||||
$tags = $tagClass->getAllTagsByTypeAndElementIds('mail', $mailIds);
|
||||
$lists = $mailClass->getAllListsWithCountSubscribersByMailIds($mailIds);
|
||||
$totalStats = $statClass->getAllFromMailIds($mailIds);
|
||||
|
||||
foreach ($results['campaigns'] as $i => $oneCampaign) {
|
||||
$results['campaigns'][$i]->tags = [];
|
||||
$results['campaigns'][$i]->lists = [];
|
||||
$results['campaigns'][$i]->automation_id = null;
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if ($oneCampaign->id == $tag->id_element) {
|
||||
$results['campaigns'][$i]->tags[] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lists as $list) {
|
||||
if ($oneCampaign->mail_id == $list->mail_id) {
|
||||
array_push($results['campaigns'][$i]->lists, $list);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($totalStats[$oneCampaign->mail_id])) {
|
||||
$oneCampaignStats = $totalStats[$oneCampaign->mail_id];
|
||||
$results['campaigns'][$i]->subscribers = $oneCampaignStats->total_subscribers;
|
||||
$results['campaigns'][$i]->open = 0;
|
||||
if (!empty($oneCampaignStats->total_subscribers)) {
|
||||
$results['campaigns'][$i]->open = intval($oneCampaignStats->open_unique / $oneCampaignStats->total_subscribers * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
$query = 'SELECT campaign.* FROM #__acym_campaign AS campaign WHERE campaign.id = '.intval($id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getOneByIdWithMail($id)
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$query = 'SELECT campaign.*, mail.name, mail.subject, mail.body, mail.from_name, mail.from_email, mail.reply_to_name, mail.reply_to_email, mail.bcc
|
||||
FROM #__acym_campaign AS campaign
|
||||
JOIN #__acym_mail AS mail ON campaign.mail_id = mail.id
|
||||
WHERE campaign.id = '.intval($id);
|
||||
|
||||
return $mailClass->decode(acym_loadObject($query));
|
||||
}
|
||||
|
||||
public function get($identifier, $column = 'id')
|
||||
{
|
||||
return acym_loadObject('SELECT campaign.* FROM #__acym_campaign AS campaign WHERE campaign.'.acym_secureDBColumn($column).' = '.acym_escapeDB($identifier));
|
||||
}
|
||||
|
||||
public function getAllCampaignsNameMailId()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$query = 'SELECT m.id, m.name
|
||||
FROM #__acym_campaign as c
|
||||
LEFT JOIN #__acym_mail as m ON c.mail_id = m.id';
|
||||
|
||||
return $mailClass->decode(acym_loadObjectList($query));
|
||||
}
|
||||
|
||||
public function getOneCampaignByMailId($mailId)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_campaign WHERE mail_id = '.intval($mailId);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function manageListsToCampaign($listsIds, $mailId)
|
||||
{
|
||||
acym_query('DELETE FROM #__acym_mail_has_list WHERE mail_id = '.intval($mailId));
|
||||
|
||||
acym_arrayToInteger($listsIds);
|
||||
if (empty($listsIds)) return;
|
||||
|
||||
$values = [];
|
||||
$listsIds = array_unique($listsIds);
|
||||
foreach ($listsIds as $id) {
|
||||
array_push($values, '('.intval($mailId).', '.intval($id).')');
|
||||
}
|
||||
|
||||
if (!empty($values)) {
|
||||
acym_query('INSERT INTO #__acym_mail_has_list (`mail_id`, `list_id`) VALUES '.implode(',', $values));
|
||||
}
|
||||
}
|
||||
|
||||
public function save($campaign)
|
||||
{
|
||||
if (isset($campaign->tags)) {
|
||||
$tags = $campaign->tags;
|
||||
unset($campaign->tags);
|
||||
}
|
||||
|
||||
foreach ($campaign as $oneAttribute => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$campaign->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
$campaignID = parent::save($campaign);
|
||||
|
||||
if (!empty($campaignID) && isset($tags)) {
|
||||
$tagClass = acym_get('class.tag');
|
||||
$tagClass->setTags('mail', $campaign->mail_id, $tags);
|
||||
}
|
||||
|
||||
return $campaignID;
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$mailsToDelete = [];
|
||||
foreach ($elements as $id) {
|
||||
$mailsToDelete[] = acym_loadResult('SELECT mail_id FROM #__acym_campaign WHERE id = '.intval($id));
|
||||
acym_query('UPDATE #__acym_campaign SET mail_id = NULL WHERE id = '.intval($id));
|
||||
}
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailClass->delete($mailsToDelete);
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function send($campaignID, $result = 0)
|
||||
{
|
||||
$date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
$campaign = $this->getOneById($campaignID);
|
||||
|
||||
if ($campaign->scheduled == 0) {
|
||||
$campaign->sending_date = $date;
|
||||
$campaign->draft = 0;
|
||||
$this->save($campaign);
|
||||
}
|
||||
|
||||
if (empty($campaign->mail_id)) {
|
||||
$this->errors[] = 'Mail not found';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$lists = acym_loadResultArray('SELECT list_id FROM #__acym_mail_has_list WHERE mail_id = '.intval($campaign->mail_id));
|
||||
|
||||
if (empty($lists)) {
|
||||
$this->errors[] = acym_translation('ACYM_NO_LIST_SELECTED');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
acym_arrayToInteger($lists);
|
||||
|
||||
$config = acym_config();
|
||||
$confirmed = $config->get('require_confirmation', 1) == 1 ? ' AND user.confirmed = 1 ' : '';
|
||||
if (empty($result)) {
|
||||
$result = acym_query(
|
||||
'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`)
|
||||
SELECT '.intval($campaign->mail_id).', ul.user_id, '.acym_escapeDB($date).'
|
||||
FROM #__acym_user_has_list AS ul
|
||||
JOIN #__acym_user AS user ON user.id = ul.user_id
|
||||
WHERE user.active = 1 AND ul.status = 1 AND ul.list_id IN ('.implode(',', $lists).')'.$confirmed
|
||||
);
|
||||
}
|
||||
|
||||
$mailStat = [];
|
||||
$mailStat['mail_id'] = intval($campaign->mail_id);
|
||||
$mailStat['total_subscribers'] = intval($result);
|
||||
$mailStat['send_date'] = acym_date("now", "Y-m-d H:i:s");
|
||||
|
||||
$mailStatClass = acym_get('class.mailstat');
|
||||
$mailStatClass->save($mailStat);
|
||||
|
||||
if ($result === 0) {
|
||||
$this->errors[] = acym_translation('ACYM_CAMPAIGN_ALREADY_QUEUED');
|
||||
} else {
|
||||
acym_query('UPDATE #__acym_campaign SET sent = 1, active = 1 WHERE mail_id = '.intval($campaign->mail_id));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCampaignForDashboard()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$query = 'SELECT campaign.*, mail.name as name FROM #__acym_campaign as campaign LEFT JOIN #__acym_mail as mail ON campaign.mail_id = mail.id WHERE `active` = 1 AND `scheduled` = 1 AND `sent` = 0 LIMIT 3';
|
||||
|
||||
return $mailClass->decode(acym_loadObjectList($query));
|
||||
}
|
||||
|
||||
public function getOpenRateOneCampaign($mail_id)
|
||||
{
|
||||
$query = 'SELECT sent, open_unique FROM #__acym_mail_stat
|
||||
WHERE mail_id = '.intval($mail_id).' LIMIT 1';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getOpenRateAllCampaign()
|
||||
{
|
||||
$query = 'SELECT SUM(sent) as sent, SUM(open_unique) as open_unique FROM #__acym_mail_stat';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getBounceRateAllCampaign()
|
||||
{
|
||||
$query = 'SELECT SUM(sent) as sent, SUM(bounce_unique) as bounce_unique FROM #__acym_mail_stat';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
|
||||
public function getBounceRateOneCampaign($mail_id)
|
||||
{
|
||||
$query = 'SELECT sent, bounce_unique FROM #__acym_mail_stat
|
||||
WHERE mail_id = '.intval($mail_id).' LIMIT 1';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getOpenByMonth($mail_id = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(user_id) as open, DATE_FORMAT(open_date, \'%Y-%m\') as open_date FROM #__acym_user_stat WHERE open > 0';
|
||||
$query .= empty($mail_id) ? '' : ' AND `mail_id`='.intval($mail_id);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` >= '.acym_escapeDB($start);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY MONTH(open_date), YEAR(open_date) ORDER BY open_date';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOpenByWeek($mail_id = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(user_id) as open, DATE_FORMAT(open_date, \'%Y-%m-%d\') as open_date FROM #__acym_user_stat WHERE open > 0';
|
||||
$query .= empty($mail_id) ? '' : ' AND `mail_id`='.intval($mail_id);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` >= '.acym_escapeDB($start);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY WEEK(open_date), YEAR(open_date) ORDER BY open_date';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOpenByDay($mail_id = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(user_id) as open, DATE_FORMAT(open_date, \'%Y-%m-%d\') as open_date FROM #__acym_user_stat WHERE open > 0';
|
||||
$query .= empty($mail_id) ? '' : ' AND `mail_id`='.intval($mail_id);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` >= '.acym_escapeDB($start);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY DAYOFYEAR(open_date), YEAR(open_date) ORDER BY open_date';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOpenByHour($mail_id = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(user_id) as open, DATE_FORMAT(open_date, \'%Y-%m-%d %H:00:00\') as open_date FROM #__acym_user_stat WHERE open > 0';
|
||||
$query .= empty($mail_id) ? '' : ' AND `mail_id`='.intval($mail_id);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` >= '.acym_escapeDB($start);
|
||||
$query .= empty($start) ? '' : ' AND `open_date` <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY HOUR(open_date), DAYOFYEAR(open_date), YEAR(open_date) ORDER BY open_date';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getLastNewsletters($params)
|
||||
{
|
||||
$query = 'SELECT m.name, m.id, m.body, m.subject, c.sending_date FROM #__acym_campaign as c
|
||||
INNER JOIN #__acym_mail as m ON c.mail_id = m.id
|
||||
WHERE c.active = 1 AND c.sent = 1';
|
||||
|
||||
$queryCount = 'SELECT COUNT(*) FROM (SELECT m.id FROM #__acym_campaign as c INNER JOIN #__acym_mail as m ON c.mail_id = m.id WHERE c.active = 1 AND c.sent = 1';
|
||||
|
||||
if (isset($params['userId'])) {
|
||||
$query .= ' AND m.id IN (SELECT ml.mail_id FROM #__acym_mail_has_list ml
|
||||
INNER JOIN #__acym_user_has_list ul ON ml.list_id = ul.list_id
|
||||
WHERE ul.user_id = '.intval($params['userId']).')';
|
||||
$queryCount .= ' AND m.id IN (SELECT ml.mail_id FROM #__acym_mail_has_list ml
|
||||
INNER JOIN #__acym_user_has_list ul ON ml.list_id = ul.list_id
|
||||
WHERE ul.user_id = '.intval($params['userId']).')';
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY c.sending_date DESC';
|
||||
|
||||
$page = isset($params['page']) ? $params['page'] : 0;
|
||||
$numberPerPage = isset($params['numberPerPage']) ? $params['numberPerPage'] : 0;
|
||||
$lastNewsletters = isset($params['limit']) ? $params['limit'] : 0;
|
||||
|
||||
$queryCount .= empty($lastNewsletters) ? '' : ' LIMIT '.intval($lastNewsletters);
|
||||
|
||||
if (!empty($page) && !empty($numberPerPage)) {
|
||||
if (!empty($lastNewsletters)) {
|
||||
$limit = ((($page * $numberPerPage) > $lastNewsletters) ? fmod($lastNewsletters, $numberPerPage) : $numberPerPage);
|
||||
} else {
|
||||
$limit = $numberPerPage;
|
||||
}
|
||||
|
||||
$offset = ($params['page'] - 1) * $numberPerPage;
|
||||
$query .= ' LIMIT '.intval($offset).', '.intval($limit);
|
||||
} elseif (!empty($lastNewsletters)) {
|
||||
$limit = $lastNewsletters;
|
||||
|
||||
$query .= ' LIMIT '.intval($limit);
|
||||
}
|
||||
|
||||
$queryCount .= ') AS r';
|
||||
|
||||
|
||||
$return = [];
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$return['matchingNewsletters'] = $mailClass->decode(acym_loadObjectList($query));
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$userEmail = acym_currentUserEmail();
|
||||
$user = $userClass->getOneByEmail($userEmail);
|
||||
|
||||
foreach ($return['matchingNewsletters'] as $i => $oneNewsletter) {
|
||||
acym_trigger('replaceContent', [&$oneNewsletter]);
|
||||
acym_trigger('replaceUserInformation', [&$oneNewsletter, &$user, false]);
|
||||
|
||||
$return['matchingNewsletters'][$i] = $oneNewsletter;
|
||||
}
|
||||
|
||||
$return['count'] = acym_loadResult($queryCount);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function getListsForCampaign($mailId)
|
||||
{
|
||||
$query = 'SELECT list_id FROM #__acym_mail_has_list WHERE mail_id = '.intval($mailId);
|
||||
|
||||
return acym_loadResultArray($query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymconditionClass extends acymClass
|
||||
{
|
||||
var $table = 'condition';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function getOneByStepId($stepId)
|
||||
{
|
||||
$query = "SELECT * FROM #__acym_condition WHERE step_id = ".intval($stepId);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
acym_query('DELETE FROM #__acym_action WHERE condition_id IN ('.implode(',', $elements).')');
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function save($condition)
|
||||
{
|
||||
foreach ($condition as $oneAttribute => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
if ($oneAttribute != 'conditions') $condition->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
return parent::save($condition);
|
||||
}
|
||||
|
||||
|
||||
public function getConditionsByStepId($id)
|
||||
{
|
||||
$query = 'SELECT acycondition.* FROM #__acym_condition as acycondition LEFT JOIN #__acym_step AS step ON step.id = acycondition.step_id WHERE step.id = '.intval($id);
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return acym_loadObjectList('SELECT * FROM #__acym_condition');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymconfigurationClass extends acymClass
|
||||
{
|
||||
var $table = 'configuration';
|
||||
var $pkey = 'name';
|
||||
var $values = [];
|
||||
|
||||
function load()
|
||||
{
|
||||
$this->values = acym_loadObjectList('SELECT * FROM #__acym_configuration', 'name');
|
||||
}
|
||||
|
||||
function get($namekey, $default = '')
|
||||
{
|
||||
if (isset($this->values[$namekey])) {
|
||||
return $this->values[$namekey]->value;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
function save($newConfig)
|
||||
{
|
||||
$query = 'REPLACE INTO #__acym_configuration (`name`, `value`) VALUES ';
|
||||
|
||||
$params = [];
|
||||
foreach ($newConfig as $name => $value) {
|
||||
if (strpos($name, 'password') !== false && !empty($value) && trim($value, '*') == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = implode(',', $value);
|
||||
}
|
||||
|
||||
if (empty($this->values[$name])) {
|
||||
$this->values[$name] = new stdClass();
|
||||
}
|
||||
$this->values[$name]->value = $value;
|
||||
|
||||
$params[] = '('.acym_escapeDB(strip_tags($name)).','.acym_escapeDB(strip_tags($value)).')';
|
||||
}
|
||||
|
||||
if (empty($params)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$query .= implode(',', $params);
|
||||
|
||||
try {
|
||||
$status = acym_query($query);
|
||||
} catch (Exception $e) {
|
||||
$status = false;
|
||||
}
|
||||
if ($status === false) {
|
||||
acym_display(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error');
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymfieldClass extends acymClass
|
||||
{
|
||||
var $table = 'field';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function getMatchingFields()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_field ORDER BY `ordering` ASC';
|
||||
|
||||
return acym_loadObjectList($query, 'id');
|
||||
}
|
||||
|
||||
public function getOneFieldByID($id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_field WHERE `id` = '.intval($id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getFieldsByID($ids)
|
||||
{
|
||||
acym_arrayToInteger($ids);
|
||||
if (empty($ids)) return [];
|
||||
$query = 'SELECT * FROM #__acym_field WHERE `id` IN('.implode(',', $ids).') ORDER BY `ordering` ASC';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOrdering()
|
||||
{
|
||||
$query = 'SELECT COUNT(id) AS ordering_number FROM #__acym_field';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAllfields()
|
||||
{
|
||||
return acym_loadObjectList('SELECT * FROM #__acym_field', 'id');
|
||||
}
|
||||
|
||||
public function getAllFieldsForUser()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_field WHERE id NOT IN (1, 2) ORDER BY `ordering` ASC';
|
||||
|
||||
return acym_loadObjectList($query, 'id');
|
||||
}
|
||||
|
||||
public function getAllFieldsForModuleFront()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_field WHERE id != 2 ORDER BY `ordering` ASC';
|
||||
|
||||
return acym_loadObjectList($query, 'id');
|
||||
}
|
||||
|
||||
public function getFieldsValueByUserId($userId)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user_has_field WHERE user_id = '.intval($userId);
|
||||
|
||||
return acym_loadObjectList($query, 'field_id');
|
||||
}
|
||||
|
||||
public function generateNamekey($name, $namekey = '')
|
||||
{
|
||||
$fieldsNamekey = acym_loadResultArray('SELECT namekey FROM #__acym_field');
|
||||
|
||||
$namekey = empty($namekey) ? substr(preg_replace('#[^a-z0-9_]#i', '', strtolower($name)), 0, 50) : $namekey;
|
||||
if (in_array($namekey, $fieldsNamekey)) {
|
||||
$namekey = $namekey.'_'.count($fieldsNamekey);
|
||||
}
|
||||
|
||||
return $namekey;
|
||||
}
|
||||
|
||||
public function getValueFromDB($fieldDB)
|
||||
{
|
||||
$query = 'SELECT '.acym_secureDBColumn($fieldDB->value).' AS value, '.acym_secureDBColumn($fieldDB->title).' AS title
|
||||
FROM '.acym_secureDBColumn($fieldDB->database).'.'.acym_secureDBColumn($fieldDB->table);
|
||||
$query .= empty($fieldDB->where_value) ? '' : ' WHERE `'.acym_secureDBColumn($fieldDB->where).'` '.$fieldDB->where_sign.' '.acym_escapeDB($fieldDB->where_value);
|
||||
if (!empty($fieldDB->order_by)) $query .= ' ORDER BY '.acym_secureDBColumn($fieldDB->order_by).' '.acym_secureDBColumn($fieldDB->sort_order);
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function store($fields, $userID)
|
||||
{
|
||||
if (!empty($_FILES['customField'])) {
|
||||
$uploadFolder = trim(acym_cleanPath(html_entity_decode(acym_getFilesFolder())), DS.' ').DS;
|
||||
$uploadPath = acym_cleanPath(ACYM_ROOT.$uploadFolder.'userfiles'.DS);
|
||||
foreach ($_FILES['customField']['tmp_name'] as $key => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
$error = acym_uploadFile($value, $uploadPath.$_FILES['customField']['name'][$key]);
|
||||
if (!$error) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 5000);
|
||||
|
||||
return;
|
||||
}
|
||||
$fields[$key] = $_FILES['customField']['name'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($fields as $id => $field) {
|
||||
$query = 'INSERT INTO #__acym_user_has_field (`user_id`, `field_id`, `value`) VALUES ';
|
||||
if (is_array($field)) {
|
||||
$fullField = $this->getOneFieldByID($id);
|
||||
if (in_array($fullField->type, ['multiple_dropdown', 'radio', 'phone'])) {
|
||||
$field = implode(',', $field);
|
||||
} elseif ($fullField->type == 'checkbox') {
|
||||
$field = implode(',', array_keys($field));
|
||||
} elseif ($fullField->type == 'date') {
|
||||
$field = implode('/', $field);
|
||||
} else {
|
||||
$field = json_encode($field);
|
||||
}
|
||||
}
|
||||
$query .= '('.intval($userID).', '.intval($id).', '.acym_escapeDB($field).')';
|
||||
$query .= ' ON DUPLICATE KEY UPDATE `value`= VALUES(`value`)';
|
||||
acym_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllfieldBackEndListingByUserIds($ids, $fields, $forBackEnd = false)
|
||||
{
|
||||
$query = 'SELECT field.type as type, field.name as field_name, user_field.user_id as user_id, user_field.field_id as field_id, user_field.value as field_value
|
||||
FROM #__acym_user_has_field AS user_field
|
||||
LEFT JOIN #__acym_field AS field ON user_field.field_id = field.id';
|
||||
|
||||
$conditions = [];
|
||||
|
||||
if ($forBackEnd) $conditions[] = 'field.backend_listing = 1';
|
||||
|
||||
if (!is_array($ids)) $ids = [$ids];
|
||||
acym_arrayToInteger($ids);
|
||||
if (empty($ids)) $ids[] = 0;
|
||||
|
||||
if (!is_array($fields)) $fields = [$fields];
|
||||
acym_arrayToInteger($fields);
|
||||
if (empty($fields)) $fields[] = 0;
|
||||
|
||||
$conditions[] = 'user_field.user_id IN ('.implode(',', $ids).')';
|
||||
$conditions[] = 'user_field.field_id IN ('.implode(',', $fields).')';
|
||||
|
||||
$query .= !empty($conditions) ? ' WHERE ('.implode(') AND (', $conditions).')' : '';
|
||||
|
||||
$fieldValues = [];
|
||||
foreach (acym_loadObjectList($query) as $one) {
|
||||
$fieldValues[$one->field_id.$one->user_id] = is_array(json_decode($one->field_value)) ? implode(', ', json_decode($one->field_value)) : $one->field_value;
|
||||
}
|
||||
|
||||
return $fieldValues;
|
||||
}
|
||||
|
||||
public function getAllFieldsBackendListing()
|
||||
{
|
||||
$query = 'SELECT id, name FROM #__acym_field WHERE backend_listing = 1 AND id NOT IN (1, 2)';
|
||||
|
||||
$return = [
|
||||
'names' => [],
|
||||
'ids' => [],
|
||||
];
|
||||
|
||||
foreach (acym_loadObjectList($query) as $one) {
|
||||
$return['names'][] = $one->name;
|
||||
$return['ids'][] = $one->id;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
acym_query('DELETE FROM #__acym_user_has_field WHERE field_id IN ('.implode(',', $elements).')');
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function displayField($field, $defaultValue, $size, $valuesArray, $displayOutside = true, $displayFront = false, $user = null, $display = 1, $displayIf = '')
|
||||
{
|
||||
if ($display == 0) return '';
|
||||
|
||||
$cmsUser = false;
|
||||
if ($displayFront && !empty($user->id)) {
|
||||
$cmsUser = !empty($user->cms_id) ? true : false;
|
||||
if ($field->id == 1) {
|
||||
$defaultValue = $user->name;
|
||||
} elseif ($field->id == 2) {
|
||||
$defaultValue = $user->email;
|
||||
} else {
|
||||
$allValues = [];
|
||||
$defaultUserValue = $this->getFieldsValueByUserId($user->id);
|
||||
if (!empty($defaultUserValue)) {
|
||||
foreach ($defaultUserValue as $one) {
|
||||
$allValues[$one->field_id] = $one->value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($allValues[$field->id])) {
|
||||
$defaultValue = is_null(json_decode($allValues[$field->id])) ? $allValues[$field->id] : json_decode($allValues[$field->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($field->type, ['radio', 'checkbox'])) {
|
||||
$valuesArrayTmp = [];
|
||||
foreach ($valuesArray as $oneValue) {
|
||||
if (!is_object($oneValue)) {
|
||||
$valuesArrayTmp = $valuesArray;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($oneValue->disable)) continue;
|
||||
$valuesArrayTmp[$oneValue->value] = $oneValue->text;
|
||||
}
|
||||
$valuesArray = $valuesArrayTmp;
|
||||
}
|
||||
|
||||
if (is_array($valuesArray)) {
|
||||
foreach ($valuesArray as $key => $oneValue) {
|
||||
if (is_object($oneValue) && !empty($valuesArray[$key]->text)) {
|
||||
$valuesArray[$key]->text = acym_translation($valuesArray[$key]->text);
|
||||
} elseif (is_string($oneValue)) {
|
||||
$valuesArray[$key] = acym_translation($valuesArray[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return = '';
|
||||
|
||||
$field->name = acym_translation($field->name);
|
||||
|
||||
$style = empty($size) ? '' : ' style="'.$size.'"';
|
||||
$messageRequired = empty($field->option->error_message) ? acym_translation_sprintf('ACYM_DEFAULT_REQUIRED_MESSAGE', $field->name) : acym_translation($field->option->error_message);
|
||||
$requiredJson = json_encode(['type' => $field->type, 'message' => $messageRequired]);
|
||||
$required = $field->required ? ' data-required="'.acym_escape($requiredJson).'"' : '';
|
||||
$placeholder = '';
|
||||
if (!$displayOutside) $placeholder = ' placeholder="'.acym_escape($field->name).'"';
|
||||
|
||||
$name = 'customField['.intval($field->id).']';
|
||||
$nameAttribute = ' name="'.$name.'"';
|
||||
$value = ' value="'.acym_escape($defaultValue).'"';
|
||||
|
||||
|
||||
if ($field->type == 'date' || ($displayOutside && (in_array($field->id, [1, 2]) || in_array($field->type, ['text', 'textarea', 'single_dropdown', 'multiple_dropdown', 'custom_text'])))) {
|
||||
$return .= '<label '.$displayIf.' class="cell margin-top-1"><div class="acym__users__creation__fields__title">'.$field->name.'</div>';
|
||||
}
|
||||
|
||||
if ($field->id == 1) {
|
||||
$nameAttribute = ' name="user[name]"';
|
||||
$return .= '<input '.$nameAttribute.$placeholder.$required.$value.' type="text" class="cell">';
|
||||
} elseif ($field->id == 2) {
|
||||
$nameAttribute = ' name="user[email]"';
|
||||
$return .= '<input '.$nameAttribute.$placeholder.$value.' required type="email" class="cell" id="acym__user__edit__email" '.($displayFront && $cmsUser ? 'disabled' : '').'>';
|
||||
} elseif ($field->type == 'text') {
|
||||
$field->option->authorized_content->message = $field->option->error_message_invalid;
|
||||
$authorizedContent = ' data-authorized-content="'.acym_escape(json_encode($field->option->authorized_content)).'"';
|
||||
$return .= '<input '.$nameAttribute.$placeholder.$required.$value.$authorizedContent.$style.' type="text">';
|
||||
} elseif ($field->type == 'textarea') {
|
||||
$return .= '<textarea '.$nameAttribute.$required.' rows="'.intval($field->option->rows).'" cols="'.intval($field->option->columns).'">'.(empty($defaultValue) ? $field->name : $defaultValue).'</textarea>';
|
||||
} elseif ($field->type == 'radio') {
|
||||
if ($displayFront) {
|
||||
$return .= '<div '.$displayIf.' class="cell acym__content"><div class="acym__users__creation__fields__title">'.$field->name.'</div>';
|
||||
$defaultValue = empty($defaultValue) ? null : (is_array($defaultValue) ? $defaultValue[0] : $defaultValue);
|
||||
foreach ($valuesArray as $key => $value) {
|
||||
$defaultValue = $defaultValue == $key ? 'checked' : '';
|
||||
$return .= '<label>'.$value.'<input '.$nameAttribute.$required.' type="radio" value="'.acym_escape($key).'" '.$defaultValue.'></label>';
|
||||
}
|
||||
$return .= '</div>';
|
||||
} else {
|
||||
$return .= '<div '.$displayIf.' class="cell acym__content"><div class="cell">';
|
||||
$return .= '<div class="acym__users__creation__fields__title">'.$field->name.'</div>';
|
||||
$return .= acym_radio($valuesArray, $name.'[]', empty($defaultValue) ? null : (is_array($defaultValue) ? $defaultValue[0] : $defaultValue), null, ($field->required ? ['data-required' => $requiredJson] : []));
|
||||
$return .= '</div></div>';
|
||||
}
|
||||
} elseif ($field->type == 'checkbox') {
|
||||
$return .= '<div '.$displayIf.' class="cell margin-top-1"><div class="acym__users__creation__fields__title margin-bottom-1">'.$field->name.'</div>';
|
||||
if ($displayFront) {
|
||||
$defaultValue = empty($defaultValue) ? null : (explode(',', $defaultValue));
|
||||
foreach ($valuesArray as $key => $value) {
|
||||
$checked = !empty($defaultValue) && in_array($key, $defaultValue) ? 'checked' : '';
|
||||
$return .= '<label>'.$value.'<input '.$required.' type="checkbox" name="'.$name.'['.acym_escape($key).']" value="'.acym_escape($key).'" '.$checked.'></label>';
|
||||
}
|
||||
} else {
|
||||
if (!empty($defaultValue) && !is_object($defaultValue)) {
|
||||
$defaultValue = explode(',', $defaultValue);
|
||||
$temporaryObject = new stdClass();
|
||||
foreach ($defaultValue as $value) {
|
||||
$temporaryObject->$value = 'on';
|
||||
}
|
||||
$defaultValue = $temporaryObject;
|
||||
}
|
||||
$defaultValue = is_object($defaultValue) ? $defaultValue : new stdClass();
|
||||
foreach ($valuesArray as $key => $value) {
|
||||
if (empty($defaultValue->$key)) {
|
||||
$labelClass = 'class="cell margin-top-1"';
|
||||
$attributes = '';
|
||||
} else {
|
||||
$labelClass = '';
|
||||
$attributes = 'checked '.$required;
|
||||
}
|
||||
$return .= '<label '.$labelClass.'>'.$value;
|
||||
$return .= '<input '.$attributes.' type="checkbox" name="'.$name.'['.acym_escape($key).']" class="acym__users__creation__fields__checkbox"></label>';
|
||||
}
|
||||
}
|
||||
$return .= '</div>';
|
||||
} elseif ($field->type == 'single_dropdown') {
|
||||
$return .= acym_select($valuesArray, $name, empty($defaultValue) ? '' : $defaultValue, 'class="acym__custom__fields__select__form"'.$style.$required);
|
||||
} elseif ($field->type == 'multiple_dropdown') {
|
||||
$defaultValue = is_array($defaultValue) ? $defaultValue : explode(',', $defaultValue);
|
||||
|
||||
$attributes = [
|
||||
'class' => 'acym__custom__fields__select__multiple__form',
|
||||
'style' => $size,
|
||||
];
|
||||
if ($field->required) $attributes['data-required'] = $requiredJson;
|
||||
|
||||
$return .= acym_selectMultiple($valuesArray, $name, empty($defaultValue) ? [] : $defaultValue, $attributes);
|
||||
} elseif ($field->type == 'date') {
|
||||
$defaultValue = is_array($defaultValue) ? implode('/', $defaultValue) : $defaultValue;
|
||||
$return .= acym_displayDateFormat($field->option->format, $name.'[]', $defaultValue);
|
||||
} elseif ($field->type == 'file') {
|
||||
$defaultValue = is_array($defaultValue) ? $defaultValue[0] : $defaultValue;
|
||||
if ($displayFront) {
|
||||
$return .= '<label '.$displayIf.' class="cell margin-top-1 grid-x grid-margin-x"><div class="acym__users__creation__fields__title cell">'.$field->name.'</div>';
|
||||
$return .= '<input '.$nameAttribute.$required.' type="file"></label>';
|
||||
} else {
|
||||
$return .= acym_inputFile($name.'[]', $defaultValue, '', '', $required);
|
||||
}
|
||||
} elseif ($field->type == 'phone') {
|
||||
$defaultValue = !empty($defaultValue) ? explode(',', $defaultValue) : '';
|
||||
|
||||
if ($displayOutside) $return .= '<label '.$displayIf.' class="cell margin-top-1 grid-x grid-margin-x"><div class="acym__users__creation__fields__title cell">'.$field->name.'</div>';
|
||||
$return .= '<div class="medium-3">';
|
||||
$return .= acym_generateCountryNumber($name.'[code]', empty($defaultValue) ? '' : $defaultValue[0]);
|
||||
$return .= '</div>';
|
||||
$return .= '<input '.$placeholder.$required.$style.' class="medium-9 cell" type="tel" name="'.$name.'[phone]" value="'.acym_escape(empty($defaultValue) ? '' : $defaultValue[1]).'" data-format="'.acym_escape($field->option->format).'">';
|
||||
} elseif ($field->type == 'custom_text') {
|
||||
$return .= $field->option->custom_text;
|
||||
}
|
||||
|
||||
|
||||
if ($field->type == 'date' || ($displayOutside && (in_array($field->id, [1, 2]) || in_array($field->type, ['text', 'textarea', 'single_dropdown', 'multiple_dropdown', 'phone', 'custom_text'])))) {
|
||||
$return .= '</label>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymhistoryClass extends acymClass
|
||||
{
|
||||
|
||||
var $table = 'history';
|
||||
|
||||
function insert($userId, $action, $data = [], $mailid = 0)
|
||||
{
|
||||
$currentUserid = acym_currentUserId();
|
||||
if (!empty($currentUserid)) {
|
||||
$data[] = acym_translation('EXECUTED_BY').'::'.$currentUserid.' ( '.acym_currentUserName().' )';
|
||||
}
|
||||
$history = new stdClass();
|
||||
$history->user_id = intval($userId);
|
||||
$history->action = strip_tags($action);
|
||||
$history->data = implode("\n", $data);
|
||||
if (strlen($history->data) > 100000) {
|
||||
$history->data = substr($history->data, 0, 10000);
|
||||
}
|
||||
|
||||
static $date = null;
|
||||
if (empty($date)) {
|
||||
$date = time();
|
||||
}
|
||||
|
||||
$history->date = ++$date;
|
||||
while ($this->alreadyExists($history->user_id, $history->date)) {
|
||||
$history->date++;
|
||||
}
|
||||
|
||||
$date = $history->date;
|
||||
|
||||
$history->mail_id = $mailid;
|
||||
$config = acym_config();
|
||||
if ($config->get('anonymous_tracking', 0) == 0) {
|
||||
$history->ip = acym_getIP();
|
||||
}
|
||||
|
||||
if (!empty($_SERVER)) {
|
||||
$source = [];
|
||||
if ($config->get('anonymous_tracking', 0) == 0) {
|
||||
$vars = ['HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_HOST', 'SERVER_ADDR', 'REMOTE_ADDR', 'REQUEST_URI', 'QUERY_STRING'];
|
||||
} else {
|
||||
$vars = ['HTTP_REFERER', 'HTTP_HOST', 'SERVER_ADDR', 'REQUEST_URI', 'QUERY_STRING'];
|
||||
}
|
||||
|
||||
foreach ($vars as $oneVar) {
|
||||
if (!empty($_SERVER[$oneVar])) {
|
||||
$source[] = $oneVar.'::'.strip_tags($_SERVER[$oneVar]);
|
||||
}
|
||||
}
|
||||
$history->source = implode("\n", $source);
|
||||
}
|
||||
|
||||
return acym_insertObject('#__acym_history', $history);
|
||||
}
|
||||
|
||||
function alreadyExists($userId, $date)
|
||||
{
|
||||
$result = acym_loadResult('SELECT user_id FROM #__acym_history WHERE user_id = '.intval($userId).' AND date = '.acym_escapeDB($date));
|
||||
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function getHistoryOfOneById($id)
|
||||
{
|
||||
$query = 'SELECT h.*, m.id, m.subject FROM #__acym_'.$this->table.' AS h ';
|
||||
$query .= 'LEFT JOIN #__acym_mail AS m ON h.mail_id = m.id ';
|
||||
$query .= 'WHERE h.user_id = '.intval($id);
|
||||
$query .= ' ORDER BY h.date DESC';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
515
deployed/acym/administrator/components/com_acym/classes/list.php
Normal file
515
deployed/acym/administrator/components/com_acym/classes/list.php
Normal file
@ -0,0 +1,515 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymlistClass extends acymClass
|
||||
{
|
||||
var $table = 'list';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function getMatchingLists($settings)
|
||||
{
|
||||
$query = 'SELECT list.* FROM #__acym_list AS list';
|
||||
$queryCount = 'SELECT COUNT(list.id) FROM #__acym_list AS list';
|
||||
|
||||
$queryStatus = 'SELECT COUNT(id) AS number, active + (visible*2) AS score FROM #__acym_list AS list';
|
||||
$filters = [];
|
||||
$listsId = [];
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$tagJoin = ' JOIN #__acym_tag AS tag ON list.id = tag.id_element';
|
||||
$query .= $tagJoin;
|
||||
$queryCount .= $tagJoin;
|
||||
$queryStatus .= $tagJoin;
|
||||
$filters[] = 'tag.name = '.acym_escapeDB($settings['tag']);
|
||||
$filters[] = 'tag.type = "list"';
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'list.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$queryStatus .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['status'])) {
|
||||
$allowedStatus = [
|
||||
'active' => 'active = 1',
|
||||
'inactive' => 'active = 0',
|
||||
'visible' => 'visible = 1',
|
||||
'invisible' => 'visible = 0',
|
||||
];
|
||||
if (empty($allowedStatus[$settings['status']])) {
|
||||
die('Injection denied');
|
||||
}
|
||||
$filters[] = 'list.'.$allowedStatus[$settings['status']];
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
$query .= ' ORDER BY list.'.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
}
|
||||
|
||||
$settings['offset'] = $settings['offset'] < 0 ? 0 : $settings['offset'];
|
||||
|
||||
$results['lists'] = acym_loadObjectList($query, '', $settings['offset'], $settings['listsPerPage']);
|
||||
foreach ($results['lists'] as $i => $oneList) {
|
||||
array_push($listsId, $oneList->id);
|
||||
$results['lists'][$i]->subscribers = 0;
|
||||
$results['lists'][$i]->sendable = 0;
|
||||
}
|
||||
|
||||
if (empty($listsId)) {
|
||||
$countUserByList = [];
|
||||
} else {
|
||||
acym_arrayToInteger($listsId);
|
||||
$query = 'SELECT userList.list_id, COUNT(userList.user_id) AS users, SUM(acyuser.confirmed) AS sendable
|
||||
FROM #__acym_user_has_list AS userList
|
||||
JOIN #__acym_user AS acyuser
|
||||
ON acyuser.id = userList.user_id
|
||||
WHERE userList.list_id IN ('.implode(',', $listsId).')
|
||||
AND userList.status = 1
|
||||
AND acyuser.active = 1
|
||||
GROUP BY userList.list_id';
|
||||
|
||||
$countUserByList = acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
foreach ($results['lists'] as $i => $list) {
|
||||
$results['lists'][$i]->tags = [];
|
||||
foreach ($countUserByList as $userList) {
|
||||
if ($list->id == $userList->list_id) {
|
||||
$results['lists'][$i]->subscribers = $userList->users;
|
||||
$results['lists'][$i]->sendable = $userList->sendable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
$listsPerStatus = acym_loadObjectList($queryStatus.' GROUP BY score', 'score');
|
||||
for ($i = 0 ; $i < 4 ; $i++) {
|
||||
$listsPerStatus[$i] = empty($listsPerStatus[$i]) ? 0 : $listsPerStatus[$i]->number;
|
||||
}
|
||||
|
||||
$results['status'] = [
|
||||
'all' => array_sum($listsPerStatus),
|
||||
'active' => $listsPerStatus[1] + $listsPerStatus[3],
|
||||
'inactive' => $listsPerStatus[0] + $listsPerStatus[2],
|
||||
'visible' => $listsPerStatus[2] + $listsPerStatus[3],
|
||||
'invisible' => $listsPerStatus[0] + $listsPerStatus[1],
|
||||
];
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getListsWithIdNameCount($settings)
|
||||
{
|
||||
$filters = [];
|
||||
|
||||
if (isset($settings['ids'])) {
|
||||
if (empty($settings['ids'])) {
|
||||
return ['lists' => [], 'total' => 0];
|
||||
} else {
|
||||
acym_arrayToInteger($settings['ids']);
|
||||
$filters[] = 'list.id IN ('.implode(',', $settings['ids']).')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$config = acym_config();
|
||||
$confirmed = $config->get('require_confirmation', 1) == 1 ? ' AND user.confirmed = 1 ' : '';
|
||||
$query = 'SELECT list.id, list.name, list.color, list.active, COUNT(userList.user_id) AS subscribers
|
||||
FROM #__acym_list AS list
|
||||
LEFT JOIN #__acym_user_has_list AS userList
|
||||
JOIN #__acym_user AS user
|
||||
ON user.id = userList.user_id
|
||||
AND userList.status = 1
|
||||
AND user.active = 1 '.$confirmed.'
|
||||
ON list.id = userList.list_id';
|
||||
|
||||
$queryCount = 'SELECT COUNT(list.id)
|
||||
FROM #__acym_list AS list';
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'list.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($settings['already'])) {
|
||||
acym_arrayToInteger($settings['already']);
|
||||
$filters[] = 'list.id NOT IN('.implode(',', $settings['already']).')';
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
$query .= ' GROUP BY list.id ';
|
||||
|
||||
$results['lists'] = acym_loadObjectList($query, '', $settings['offset'], $settings['listsPerPage']);
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
return acym_loadObject('SELECT * FROM #__acym_list WHERE id = '.intval($id).' LIMIT 1');
|
||||
}
|
||||
|
||||
public function getOneByName($name)
|
||||
{
|
||||
return acym_loadObject('SELECT * FROM #__acym_list WHERE name='.acym_escapeDB($name));
|
||||
}
|
||||
|
||||
public function getListsByIds($ids)
|
||||
{
|
||||
|
||||
if (!is_array($ids)) $ids = [$ids];
|
||||
acym_arrayToInteger($ids);
|
||||
if (empty($ids)) return [];
|
||||
|
||||
$query = 'SELECT * FROM #__acym_list WHERE id IN ('.implode(', ', $ids).')';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllListUsers()
|
||||
{
|
||||
$query = 'SELECT #__acym_user_has_list.list_id, count(*)
|
||||
FROM #__acym_list AS list
|
||||
JOIN #__acym_user_has_list
|
||||
ON list.id = #__acym_user_has_list.list_id
|
||||
JOIN #__acym_user
|
||||
ON #__acym_user.id = #__acym_user_has_list.user_id
|
||||
GROUP BY list.id';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getMatchingSubscribersByListId($settings, $id)
|
||||
{
|
||||
$query = 'SELECT user.* FROM #__acym_user AS user JOIN #__acym_user_has_list AS userList ON user.id = userList.user_id';
|
||||
$queryCount = 'SELECT COUNT(user.id) FROM #__acym_user AS user JOIN #__acym_user_has_list AS userList ON user.id = userList.user_id';
|
||||
$queryStatus = 'SELECT COUNT(id) AS number, active FROM #__acym_user AS user JOIN #__acym_user_has_list AS userList ON user.id = userList.user_id';
|
||||
|
||||
$filters = [];
|
||||
$filters[] = 'userList.list_id = '.intval($id);
|
||||
$filters[] = 'userList.status = 1';
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$searchValue = acym_escapeDB('%'.$settings['search'].'%');
|
||||
$filters[] = 'user.email LIKE '.$searchValue.' OR user.name LIKE '.$searchValue;
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$queryStatus .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['status'])) {
|
||||
$allowedStatus = [
|
||||
'active' => 'active = 1',
|
||||
'inactive' => 'active = 0',
|
||||
];
|
||||
if (empty($allowedStatus[$settings['status']])) {
|
||||
die('Injection denied');
|
||||
}
|
||||
$filters[] = 'user.'.$allowedStatus[$settings['status']];
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY user.id DESC';
|
||||
|
||||
$results['users'] = acym_loadObjectList($query, '', $settings['offset'], $settings['usersPerPage']);
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
$usersPerStatus = acym_loadObjectList($queryStatus.' GROUP BY active', 'active');
|
||||
|
||||
for ($i = 0 ; $i < 2 ; $i++) {
|
||||
$usersPerStatus[$i] = empty($usersPerStatus[$i]) ? 0 : $usersPerStatus[$i]->number;
|
||||
}
|
||||
|
||||
$results['status'] = [
|
||||
'all' => array_sum($usersPerStatus),
|
||||
'active' => $usersPerStatus[1],
|
||||
'inactive' => $usersPerStatus[0],
|
||||
];
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getSubscribersCountByListId($id)
|
||||
{
|
||||
$config = acym_config();
|
||||
$confirmed = $config->get('require_confirmation', 1) == 1 ? ' AND users.confirmed = 1 ' : '';
|
||||
|
||||
$query = 'SELECT COUNT(userLists.user_id) AS subscribers
|
||||
FROM #__acym_user_has_list AS userLists
|
||||
JOIN #__acym_user AS users ON userLists.user_id = users.id
|
||||
WHERE userLists.list_id = '.intval($id).'
|
||||
AND userLists.status = 1
|
||||
AND users.active = 1 '.$confirmed.'
|
||||
GROUP BY userLists.list_id';
|
||||
|
||||
$result = acym_loadResult($query);
|
||||
|
||||
return empty($result) ? 0 : $result;
|
||||
}
|
||||
|
||||
public function getSubscribersCount($listsIds)
|
||||
{
|
||||
acym_arrayToInteger($listsIds);
|
||||
if (empty($listsIds)) return 0;
|
||||
|
||||
$query = 'SELECT COUNT(DISTINCT user.id)
|
||||
FROM #__acym_user AS user
|
||||
JOIN #__acym_user_has_list AS userList ON user.id = userList.user_id
|
||||
WHERE userList.list_id IN ('.implode(",", $listsIds).') AND userList.status = 1 AND user.active = 1';
|
||||
|
||||
$config = acym_config();
|
||||
if ($config->get('require_confirmation', 1) == 1) {
|
||||
$query .= ' AND user.confirmed = 1';
|
||||
}
|
||||
|
||||
$nbSubscribers = acym_loadResult($query);
|
||||
|
||||
return $nbSubscribers;
|
||||
}
|
||||
|
||||
public function getSubscribersIdsById($listId, $returnUnsubscribed = false)
|
||||
{
|
||||
$query = 'SELECT user_id FROM #__acym_user_has_list WHERE list_id = '.intval($listId);
|
||||
|
||||
if (!$returnUnsubscribed) {
|
||||
$query .= ' AND status = 1';
|
||||
}
|
||||
|
||||
return acym_loadResultArray($query);
|
||||
}
|
||||
|
||||
public function getSubscribersByListId($listId)
|
||||
{
|
||||
return acym_loadObjectList('SELECT user.* FROM #__acym_user AS user LEFT JOIN #__acym_user_has_list AS user_list ON user.id = user_list.user_id WHERE user_list.list_id = '.intval($listId));
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($elements as $id) {
|
||||
acym_query('DELETE FROM #__acym_mail_has_list WHERE list_id = '.intval($id));
|
||||
acym_query('DELETE FROM #__acym_user_has_list WHERE list_id = '.intval($id));
|
||||
acym_query('DELETE FROM #__acym_tag WHERE `id_element` = '.intval($id).' AND `type` = "list"');
|
||||
}
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function save($list)
|
||||
{
|
||||
if (isset($list->tags)) {
|
||||
$tags = $list->tags;
|
||||
unset($list->tags);
|
||||
}
|
||||
|
||||
if (empty($list->id)) {
|
||||
if (empty($list->cms_user_id)) $list->cms_user_id = acym_currentUserId();
|
||||
|
||||
$list->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
}
|
||||
|
||||
foreach ($list as $oneAttribute => $value) {
|
||||
if (empty($value)) continue;
|
||||
|
||||
$list->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
$listID = parent::save($list);
|
||||
|
||||
if (!empty($listID) && isset($tags)) {
|
||||
$tagClass = acym_get('class.tag');
|
||||
$tagClass->setTags('list', $listID, $tags);
|
||||
}
|
||||
|
||||
return $listID;
|
||||
}
|
||||
|
||||
function getAll($key = 'id')
|
||||
{
|
||||
$lists = acym_loadObjectList('SELECT * FROM #__acym_list', $key);
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
function getAllWithIdName()
|
||||
{
|
||||
$lists = acym_loadObjectList('SELECT id, name FROM #__acym_list', 'id');
|
||||
|
||||
$listsToReturn = [];
|
||||
|
||||
foreach ($lists as $key => $list) {
|
||||
$listsToReturn[$key] = $list->name;
|
||||
}
|
||||
|
||||
return $listsToReturn;
|
||||
}
|
||||
|
||||
function getAllForSelect()
|
||||
{
|
||||
$lists = acym_loadObjectList('SELECT * FROM #__acym_list', 'id');
|
||||
|
||||
$return = [];
|
||||
|
||||
$return[] = acym_translation('ACYM_SELECT_A_LIST');
|
||||
|
||||
foreach ($lists as $key => $list) {
|
||||
$return[$key] = $list->name;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function setVisible($elements, $status)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
|
||||
if (empty($elements)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_arrayToInteger($elements);
|
||||
$status = empty($status) ? 0 : 1;
|
||||
acym_query('UPDATE #__acym_list SET visible = '.intval($status).' WHERE id IN ('.implode(',', $elements).')');
|
||||
}
|
||||
|
||||
public function sendWelcome($userID, $listIDs)
|
||||
{
|
||||
if (acym_isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_arrayToInteger($listIDs);
|
||||
if (empty($listIDs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$messages = acym_loadObjectList('SELECT `welcome_id` FROM #__acym_list WHERE `id` IN ('.implode(',', $listIDs).') AND `active` = 1');
|
||||
|
||||
if (empty($messages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadySent = [];
|
||||
$config = acym_config();
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
$mailerHelper->report = $config->get('welcome_message', 1);
|
||||
foreach ($messages as $oneMessage) {
|
||||
$mailid = $oneMessage->welcome_id;
|
||||
if (empty($mailid)) continue;
|
||||
|
||||
if (isset($alreadySent[$mailid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mailerHelper->trackEmail = true;
|
||||
$mailerHelper->sendOne($mailid, $userID);
|
||||
$alreadySent[$mailid] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendUnsubscribe($userID, $listIDs)
|
||||
{
|
||||
if (acym_isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_arrayToInteger($listIDs);
|
||||
if (empty($listIDs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$messages = acym_loadObjectList('SELECT `unsubscribe_id` FROM #__acym_list WHERE `id` IN ('.implode(',', $listIDs).') AND `active` = 1');
|
||||
|
||||
if (empty($messages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadySent = [];
|
||||
$config = acym_config();
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
$mailerHelper->report = $config->get('unsub_message', 1);
|
||||
foreach ($messages as $oneMessage) {
|
||||
if (!empty($oneMessage->unsubscribe_id)) {
|
||||
$mailid = $oneMessage->unsubscribe_id;
|
||||
|
||||
if (isset($alreadySent[$mailid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mailerHelper->trackEmail = true;
|
||||
$mailerHelper->sendOne($mailid, $userID);
|
||||
$alreadySent[$mailid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addDefaultList()
|
||||
{
|
||||
$listId = acym_loadResult('SELECT `id` FROM #__acym_list LIMIT 1');
|
||||
if (empty($listId)) {
|
||||
$defaultList = new stdClass();
|
||||
$defaultList->name = 'Newsletters';
|
||||
$defaultList->color = '#3366ff';
|
||||
|
||||
$this->save($defaultList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getTotalSubCount($ids)
|
||||
{
|
||||
acym_arrayToInteger($ids);
|
||||
$query = "SELECT COUNT(DISTINCT hasList.user_id)
|
||||
FROM #__acym_user_has_list AS hasList
|
||||
JOIN #__acym_user AS user
|
||||
ON hasList.user_id = user.id
|
||||
WHERE hasList.status = 1
|
||||
AND user.active = 1
|
||||
AND hasList.list_id IN (".implode(',', $ids).")";
|
||||
|
||||
|
||||
$config = acym_config();
|
||||
if ($config->get('require_confirmation', 1) == 1) {
|
||||
$query .= ' AND user.confirmed = 1 ';
|
||||
}
|
||||
|
||||
return intval(acym_loadResult($query));
|
||||
}
|
||||
}
|
||||
|
||||
799
deployed/acym/administrator/components/com_acym/classes/mail.php
Normal file
799
deployed/acym/administrator/components/com_acym/classes/mail.php
Normal file
@ -0,0 +1,799 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymmailClass extends acymClass
|
||||
{
|
||||
var $table = 'mail';
|
||||
var $pkey = 'id';
|
||||
var $templateNames = [];
|
||||
var $checkAreas = true;
|
||||
|
||||
const FIELDS_ENCODING = ['name', 'subject', 'body', 'autosave', 'preheader'];
|
||||
|
||||
public function getMatchingMails($settings)
|
||||
{
|
||||
$query = 'SELECT mail.* FROM #__acym_mail AS mail';
|
||||
$queryCount = 'SELECT COUNT(mail.id) FROM #__acym_mail AS mail';
|
||||
$queryStatus = 'SELECT COUNT(mail.type) AS number, mail.type FROM #__acym_mail AS mail';
|
||||
|
||||
$filters = [];
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$tagJoin = ' JOIN #__acym_tag AS tag ON mail.id = tag.id_element';
|
||||
$query .= $tagJoin;
|
||||
$queryCount .= $tagJoin;
|
||||
$queryStatus .= $tagJoin;
|
||||
$filters[] = 'tag.name = '.acym_escapeDB($settings['tag']);
|
||||
$filters[] = 'tag.type = "mail"';
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'mail.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($settings['type'])) {
|
||||
if ($settings['type'] == 'custom') {
|
||||
$filters[] .= 'mail.library = 0';
|
||||
} else {
|
||||
$filters[] .= 'mail.library = 1';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($settings['automation']) || !$settings['automation']) {
|
||||
|
||||
if (!empty($settings['editor'])) {
|
||||
if ($settings['editor'] == 'html') {
|
||||
$filters[] .= 'mail.drag_editor = 0';
|
||||
} else {
|
||||
$filters[] .= 'mail.drag_editor = 1';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($settings['onlyStandard'])) {
|
||||
$filters[] = 'mail.type != \'notification\'';
|
||||
} else {
|
||||
$filters[] = 'mail.type = \'standard\'';
|
||||
}
|
||||
|
||||
$filters[] = 'mail.template = 1';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($filters)) {
|
||||
$queryStatus .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['status'])) {
|
||||
$allowedStatus = [
|
||||
'standard',
|
||||
'welcome',
|
||||
'unsubscribe',
|
||||
];
|
||||
|
||||
if (!in_array($settings['status'], $allowedStatus)) {
|
||||
die('Injection denied');
|
||||
}
|
||||
$filters[] = 'mail.type = '.acym_escapeDB($settings['status']);
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
$query .= ' ORDER BY mail.'.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
}
|
||||
|
||||
$results['mails'] = $this->decode(acym_loadObjectList($query, '', $settings['offset'], $settings['mailsPerPage']));
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
$mailsPerStatus = acym_loadObjectList($queryStatus.' GROUP BY type', 'type');
|
||||
$nbAllMail = 0;
|
||||
foreach ($mailsPerStatus as $oneMailType) {
|
||||
$nbAllMail += $oneMailType->number;
|
||||
}
|
||||
|
||||
$results['status'] = [
|
||||
'all' => $nbAllMail,
|
||||
'standard' => !empty($mailsPerStatus['standard']->number) ? $mailsPerStatus['standard']->number : 0,
|
||||
'welcome' => !empty($mailsPerStatus['welcome']->number) ? $mailsPerStatus['welcome']->number : 0,
|
||||
'unsubscribe' => !empty($mailsPerStatus['unsubscribe']->number) ? $mailsPerStatus['unsubscribe']->number : 0,
|
||||
];
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->decode(acym_loadObjectList('SELECT * FROM #__acym_mail'));
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
$mail = $this->decode(acym_loadObject('SELECT * FROM #__acym_mail WHERE id = '.intval($id)));
|
||||
|
||||
if (!empty($mail)) {
|
||||
$tagsClass = acym_get('class.tag');
|
||||
$mail->tags = $tagsClass->getAllTagsByElementId('mail', $id);
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function getOneByName($name)
|
||||
{
|
||||
$mail = $this->decode(acym_loadObject('SELECT * FROM #__acym_mail WHERE `name` = '.acym_escapeDB($name)));
|
||||
|
||||
if (!empty($mail)) {
|
||||
$tagsClass = acym_get('class.tag');
|
||||
$mail->tags = $tagsClass->getAllTagsByElementId('mail', $mail->id);
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function getMailsByType($typeMail, $settings)
|
||||
{
|
||||
if (empty($settings['key'])) {
|
||||
$settings['key'] = '';
|
||||
}
|
||||
if (empty($settings['offset'])) {
|
||||
$settings['offset'] = 0;
|
||||
}
|
||||
if (empty($settings['mailsPerPage'])) {
|
||||
$settings['mailsPerPage'] = 12;
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM #__acym_mail AS mail';
|
||||
$queryCount = 'SELECT count(*) FROM #__acym_mail AS mail';
|
||||
|
||||
$filters = [];
|
||||
$filters[] = 'mail.type = '.acym_escapeDB($typeMail);
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'mail.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
|
||||
$query .= ' ORDER BY id DESC';
|
||||
|
||||
$results['mails'] = $this->decode(acym_loadObjectList($query, $settings['key'], $settings['offset'], $settings['mailsPerPage']));
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getAllListsWithCountSubscribersByMailIds($ids)
|
||||
{
|
||||
acym_arrayToInteger($ids);
|
||||
if (empty($ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$query = 'SELECT mailLists.list_id, mailLists.mail_id, list.*, COUNT(userLists.user_id) AS subscribers
|
||||
FROM #__acym_mail_has_list AS mailLists
|
||||
JOIN #__acym_list AS list ON mailLists.list_id = list.id
|
||||
LEFT JOIN #__acym_user_has_list AS userLists
|
||||
JOIN #__acym_user AS acyuser ON userLists.user_id = acyuser.id
|
||||
AND userLists.status = 1
|
||||
AND acyuser.active = 1 ';
|
||||
|
||||
$config = acym_config();
|
||||
if ($config->get('require_confirmation', 1) == 1) {
|
||||
$query .= ' AND acyuser.confirmed = 1 ';
|
||||
}
|
||||
|
||||
$query .= 'ON list.id = userLists.list_id
|
||||
WHERE mailLists.mail_id IN ('.implode(",", $ids).')
|
||||
GROUP BY mailLists.list_id, mailLists.mail_id';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllListsByMailId($id)
|
||||
{
|
||||
$mail = $this->getOneById($id);
|
||||
if (empty($mail)) return [];
|
||||
|
||||
if ('welcome' === $mail->type) {
|
||||
$query = 'SELECT * FROM #__acym_list WHERE welcome_id = '.intval($id);
|
||||
} else {
|
||||
$query = 'SELECT list.*
|
||||
FROM #__acym_mail_has_list AS mailLists
|
||||
JOIN #__acym_list AS list ON mailLists.list_id = list.id
|
||||
WHERE mailLists.mail_id = '.intval($id).'
|
||||
GROUP BY mailLists.list_id, mailLists.mail_id';
|
||||
}
|
||||
|
||||
|
||||
return acym_loadObjectList($query, 'id');
|
||||
}
|
||||
|
||||
public function save($mail)
|
||||
{
|
||||
if (isset($mail->tags)) {
|
||||
$tags = $mail->tags;
|
||||
unset($mail->tags);
|
||||
}
|
||||
|
||||
if (empty($mail->id)) {
|
||||
$mail->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
if (empty($mail->creator_id)) $mail->creator_id = acym_currentUserId();
|
||||
}
|
||||
|
||||
$mail = $this->encode($mail);
|
||||
|
||||
$mail->autosave = null;
|
||||
|
||||
foreach ($mail as $oneAttribute => $value) {
|
||||
if (empty($value) || in_array($oneAttribute, ['thumbnail', 'settings'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($oneAttribute, ['body', 'headers'])) {
|
||||
$mail->$oneAttribute = preg_replace('#<input[^>]*value="[^"]*"[^>]*>#Uis', '', $mail->$oneAttribute);
|
||||
|
||||
$mail->$oneAttribute = str_replace(' contenteditable="true"', '', $mail->$oneAttribute);
|
||||
} else {
|
||||
$mail->$oneAttribute = strip_tags($mail->$oneAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
$mailID = parent::save($mail);
|
||||
|
||||
if (!empty($mailID) && isset($tags)) {
|
||||
$tagClass = acym_get('class.tag');
|
||||
$tagClass->setTags('mail', $mailID, $tags);
|
||||
}
|
||||
|
||||
return $mailID;
|
||||
}
|
||||
|
||||
public function autoSave($mail)
|
||||
{
|
||||
if (empty($mail->id)) return false;
|
||||
|
||||
$mail->autosave = str_replace(' contenteditable="true"', '', $mail->autosave);
|
||||
$mail = $this->encode($mail);
|
||||
|
||||
return parent::save($mail);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) $elements = [$elements];
|
||||
|
||||
if (empty($elements)) return 0;
|
||||
|
||||
$this->deleteMediaFolder($elements);
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
$allThumbnailToDelete = acym_loadResultArray('SELECT thumbnail FROM #__acym_mail WHERE id IN ('.implode(',', $elements).')');
|
||||
|
||||
$link = 'wordpress' === ACYM_CMS ? WP_CONTENT_DIR.DS.'uploads'.DS.'acymailing'.DS : ACYM_MEDIA.'images';
|
||||
|
||||
foreach ($allThumbnailToDelete as $one) {
|
||||
if (!empty($one) && file_exists($link.$one)) {
|
||||
unlink($link.$one);
|
||||
}
|
||||
}
|
||||
|
||||
acym_query('UPDATE #__acym_list SET welcome_id = null WHERE welcome_id IN ('.implode(',', $elements).')');
|
||||
acym_query('UPDATE #__acym_list SET unsubscribe_id = null WHERE unsubscribe_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_queue WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_mail_has_list WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_tag WHERE `type` = "mail" AND `id_element` IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_user_stat WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_url_click WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_mail_stat WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function deleteMediaFolder($elements)
|
||||
{
|
||||
if (empty($elements)) return;
|
||||
|
||||
acym_arrayToInteger($elements);
|
||||
$results = acym_loadResultArray('SELECT media_folder FROM #__acym_mail WHERE id IN ('.implode(',', $elements).')');
|
||||
|
||||
foreach ($results as $template) {
|
||||
if (empty($template) || !file_exists(ACYM_TEMPLATE.$template)) continue;
|
||||
acym_deleteFolder(ACYM_TEMPLATE.$template);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteOneAttachment($mailid, $idAttachment)
|
||||
{
|
||||
$mailid = intval($mailid);
|
||||
if (empty($mailid)) {
|
||||
return false;
|
||||
}
|
||||
$mail = $this->getOneById($mailid);
|
||||
|
||||
$attachments = $mail->attachments;
|
||||
if (empty($attachments)) {
|
||||
return false;
|
||||
}
|
||||
$decodedAttach = json_decode($attachments, true);
|
||||
unset($decodedAttach[$idAttachment]);
|
||||
$attachdb = json_encode($decodedAttach);
|
||||
|
||||
return acym_query('UPDATE #__acym_mail SET attachments = '.acym_escapeDB($attachdb).' WHERE id = '.intval($mailid).' LIMIT 1');
|
||||
}
|
||||
|
||||
public function createTemplateFile($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return '';
|
||||
}
|
||||
$cssfile = ACYM_TEMPLATE.'css'.DS.'template_'.$id.'.css';
|
||||
|
||||
$template = $this->getOneById($id);
|
||||
if (empty($template->id)) {
|
||||
return '';
|
||||
}
|
||||
$css = $this->buildCSS($template->stylesheet);
|
||||
|
||||
if (empty($css)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
acym_createDir(ACYM_TEMPLATE.'css');
|
||||
|
||||
if (acym_writeFile($cssfile, $css)) {
|
||||
return $cssfile;
|
||||
} else {
|
||||
acym_enqueueNotification('Could not create the file '.$cssfile, 'error');
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function buildCSS($stylesheet)
|
||||
{
|
||||
$inline = '';
|
||||
|
||||
if (preg_match_all('#@import[^;]*;#is', $stylesheet, $results)) {
|
||||
foreach ($results[0] as $oneResult) {
|
||||
$inline .= trim($oneResult)."\n";
|
||||
$stylesheet = str_replace($oneResult, '', $stylesheet);
|
||||
}
|
||||
}
|
||||
|
||||
$inline .= $stylesheet;
|
||||
|
||||
return $inline;
|
||||
}
|
||||
|
||||
public function getAllTemplatesForSelect()
|
||||
{
|
||||
$query = 'SELECT `id`, `subject`, `name` FROM #__acym_mail WHERE `template` IN(0, 2) AND `name` != "acy_report"';
|
||||
|
||||
$mails = $this->decode(acym_loadObjectList($query, 'id'));
|
||||
|
||||
$return = [];
|
||||
$return[] = acym_translation('ACYM_SELECT_A_MAIL');
|
||||
$return[-1] = acym_translation('ACYM_ALL_MAILS');
|
||||
|
||||
foreach ($mails as $id => $mail) {
|
||||
$return[$id] = empty($mail->subject) ? $mail->name : $mail->subject;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function doupload()
|
||||
{
|
||||
$importFile = acym_getVar('none', 'uploadedfile', '', 'files');
|
||||
|
||||
$fileError = $importFile['error'];
|
||||
if ($fileError > 0) {
|
||||
switch ($fileError) {
|
||||
case 1:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_1'), 'error');
|
||||
|
||||
return false;
|
||||
case 2:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_2'), 'error');
|
||||
|
||||
return false;
|
||||
case 3:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_3'), 'error');
|
||||
|
||||
return false;
|
||||
case 4:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_4'), 'error');
|
||||
|
||||
return false;
|
||||
default:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_5', $fileError), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (empty($importFile['name'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_BROWSE_FILE'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$uploadPath = acym_cleanPath(ACYM_ROOT.ACYM_MEDIA_FOLDER.DS.'templates');
|
||||
|
||||
if (!is_writable($uploadPath)) {
|
||||
@chmod($uploadPath, '0755');
|
||||
if (!is_writable($uploadPath)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_WRITABLE_FOLDER', $uploadPath), 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
if (!(bool)ini_get('file_uploads')) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_6'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!extension_loaded('zlib')) {
|
||||
acym_raiseError(E_WARNING, 'SOME_ERROR_CODE', acym_translation('WARNINSTALLZLIB'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = strtolower(acym_makeSafeFile($importFile['name']));
|
||||
$extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
|
||||
|
||||
if (!in_array($extension, ['zip', 'tar.gz'])) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_ACCEPTED_TYPE', $extension, 'zip,tar.gz'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$jpath = acym_getCMSConfig('tmp_path', ACYM_MEDIA.'tmp'.DS);
|
||||
$tmp_dest = acym_cleanPath($jpath.DS.$filename);
|
||||
$tmp_src = $importFile['tmp_name'];
|
||||
|
||||
$uploaded = acym_uploadFile($tmp_src, $tmp_dest);
|
||||
if (!$uploaded) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_7', $tmp_src, $tmp_dest), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmpdir = uniqid().'_template';
|
||||
|
||||
$extractdir = acym_cleanPath(dirname($tmp_dest).DS.$tmpdir);
|
||||
|
||||
$result = acym_extractArchive($tmp_dest, $extractdir);
|
||||
acym_deleteFile($tmp_dest);
|
||||
|
||||
$allFiles = acym_getFiles($extractdir, '.', true, true, [], []);
|
||||
foreach ($allFiles as $oneFile) {
|
||||
if (preg_match('#\.(jpg|gif|png|jpeg|ico|bmp|html|htm|css)$#i', $oneFile)) {
|
||||
continue;
|
||||
}
|
||||
if (acym_deleteFile($oneFile)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_8', $oneFile), 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_9', $tmp_dest, $extractdir), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->detecttemplates($extractdir)) {
|
||||
|
||||
$messages = $this->templateNames;
|
||||
array_unshift($messages, acym_translation_sprintf('ACYM_TEMPLATES_INSTALL', count($this->templateNames)));
|
||||
acym_enqueueNotification($messages, 'success');
|
||||
if (is_dir($extractdir)) acym_deleteFolder($extractdir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FILE_UPLOAD_ERROR_10'), 'error');
|
||||
if (is_dir($extractdir)) acym_deleteFolder($extractdir);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function detecttemplates($folder)
|
||||
{
|
||||
$allFiles = acym_getFiles($folder);
|
||||
if (!empty($allFiles)) {
|
||||
foreach ($allFiles as $oneFile) {
|
||||
if (preg_match('#^.*(html|htm)$#i', $oneFile)) {
|
||||
if ($this->installtemplate($folder.DS.$oneFile)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$status = false;
|
||||
$allFolders = acym_getFolders($folder);
|
||||
if (!empty($allFolders)) {
|
||||
foreach ($allFolders as $oneFolder) {
|
||||
$status = $this->detecttemplates($folder.DS.$oneFolder) || $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
function installtemplate($filepath)
|
||||
{
|
||||
$fileContent = acym_fileGetContent($filepath);
|
||||
|
||||
$newTemplate = new stdClass();
|
||||
$newTemplate->name = trim(preg_replace('#[^a-z0-9]#i', ' ', substr(dirname($filepath), strpos($filepath, '_template'))));
|
||||
if (preg_match('#< *title[^>]*>(.*)< */ *title *>#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->name = $results[1];
|
||||
|
||||
if (preg_match('#< *meta *name="description" *content="([^"]*)"#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->description = $results[1];
|
||||
if (preg_match('#< *meta *name="fromname" *content="([^"]*)"#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->fromname = $results[1];
|
||||
if (preg_match('#< *meta *name="fromemail" *content="([^"]*)"#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->fromemail = $results[1];
|
||||
if (preg_match('#< *meta *name="replyname" *content="([^"]*)"#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->replyname = $results[1];
|
||||
if (preg_match('#< *meta *name="replyemail" *content="([^"]*)"#Uis', $fileContent, $results) && !empty($results[1])) $newTemplate->replyemail = $results[1];
|
||||
|
||||
$newFolder = preg_replace('#[^a-z0-9]#i', '_', strtolower($newTemplate->name));
|
||||
$newTemplateFolder = $newFolder;
|
||||
$i = 1;
|
||||
while (is_dir(ACYM_TEMPLATE.$newTemplateFolder)) {
|
||||
$newTemplateFolder = $newFolder.'_'.$i;
|
||||
$i++;
|
||||
}
|
||||
$newTemplate->media_folder = $newTemplateFolder;
|
||||
|
||||
$moveResult = acym_copyFolder(dirname($filepath), ACYM_TEMPLATE.$newTemplateFolder);
|
||||
if ($moveResult !== true) {
|
||||
acym_display([acym_translation_sprintf('ACYM_ERROR_COPYING_FOLDER_TO', dirname($filepath), ACYM_TEMPLATE.$newTemplateFolder), $moveResult], 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists(ACYM_TEMPLATE.$newTemplateFolder.DS.'index.html')) {
|
||||
$indexFile = '<html><body bgcolor="#FFFFFF"></body></html>';
|
||||
acym_writeFile(ACYM_TEMPLATE.$newTemplateFolder.DS.'index.html', $indexFile);
|
||||
}
|
||||
|
||||
$fileContent = str_replace(
|
||||
[
|
||||
'src="./',
|
||||
'src="../',
|
||||
'src="images/',
|
||||
],
|
||||
[
|
||||
'src="'.ACYM_TEMPLATE_URL.$newTemplateFolder.'/',
|
||||
'src="'.ACYM_TEMPLATE_URL,
|
||||
'src="'.ACYM_TEMPLATE_URL.$newTemplateFolder.'/images/',
|
||||
],
|
||||
$fileContent
|
||||
);
|
||||
|
||||
$fileContent = preg_replace('#(src|background)[ ]*=[ ]*\"(?!(https?://|/))(?:\.\./|\./)?#', '$1="'.ACYM_TEMPLATE_URL.$newTemplateFolder.'/', $fileContent);
|
||||
|
||||
if (preg_match('#< *body[^>]*>(.*)< */ *body *>#Uis', $fileContent, $results)) {
|
||||
$newTemplate->body = $results[1];
|
||||
} else {
|
||||
$newTemplate->body = $fileContent;
|
||||
}
|
||||
|
||||
$newTemplate->stylesheet = '';
|
||||
if (preg_match_all('#< *style[^>]*>(.*)< */ *style *>#Uis', $fileContent, $results)) {
|
||||
$newTemplate->stylesheet .= preg_replace('#(<!--|-->)#s', '', implode("\n", $results[1]));
|
||||
}
|
||||
$cssFiles = [];
|
||||
$cssFiles[ACYM_TEMPLATE.$newTemplateFolder] = acym_getFiles(ACYM_TEMPLATE.$newTemplateFolder, '\.css$');
|
||||
$subFolders = acym_getFolders(ACYM_TEMPLATE.$newTemplateFolder);
|
||||
foreach ($subFolders as $oneFolder) {
|
||||
$cssFiles[ACYM_TEMPLATE.$newTemplateFolder.DS.$oneFolder] = acym_getFiles(ACYM_TEMPLATE.$newTemplateFolder.DS.$oneFolder, '\.css$');
|
||||
}
|
||||
|
||||
foreach ($cssFiles as $cssFolder => $cssFile) {
|
||||
if (empty($cssFile)) continue;
|
||||
$newTemplate->stylesheet .= "\n".acym_fileGetContent($cssFolder.DS.reset($cssFile));
|
||||
}
|
||||
|
||||
if (!empty($newTemplate->stylesheet)) {
|
||||
if (preg_match('#body *\{[^\}]*background-color:([^;\}]*)[;\}]#Uis', $newTemplate->stylesheet, $backgroundresults)) {
|
||||
$newTemplate->stylesheet = preg_replace('#(body *\{[^\}]*)background-color:[^;\}]*[;\}]#Uis', '$1', $newTemplate->stylesheet);
|
||||
}
|
||||
|
||||
$quickstyle = ['tag_h1' => 'h1', 'tag_h2' => 'h2', 'tag_h3' => 'h3', 'tag_h4' => 'h4', 'tag_h5' => 'h5', 'tag_h6' => 'h6', 'tag_a' => 'a', 'tag_ul' => 'ul', 'tag_li' => 'li', 'acym_unsub' => '\.acym_unsub', 'acym_online' => '\.acym_online', 'acym_title' => '\.acym_title', 'acym_content' => '\.acym_content', 'acym_readmore' => '\.acym_readmore'];
|
||||
foreach ($quickstyle as $styledb => $oneStyle) {
|
||||
if (preg_match('#[^a-z\. ,] *'.$oneStyle.' *{([^}]*)}#Uis', $newTemplate->stylesheet, $quickstyleresults)) {
|
||||
$newTemplate->stylesheet = str_replace($quickstyleresults[0], '', $newTemplate->stylesheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$foldersForPicts = [$newTemplateFolder];
|
||||
$otherFolders = acym_getFolders(ACYM_TEMPLATE.$newTemplateFolder);
|
||||
foreach ($otherFolders as $oneFold) {
|
||||
$foldersForPicts[] = $newTemplateFolder.DS.$oneFold;
|
||||
}
|
||||
$allPictures = [];
|
||||
foreach ($foldersForPicts as $oneFolder) {
|
||||
$allPictures[$oneFolder] = acym_getFiles(ACYM_TEMPLATE.$oneFolder);
|
||||
}
|
||||
|
||||
$uploadsFolder = ACYM_UPLOAD_FOLDER_THUMBNAIL;
|
||||
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
$thumbNb = intval($config->get('numberThumbnail', 2));
|
||||
|
||||
foreach ($allPictures as $folder => $pictfolders) {
|
||||
foreach ($pictfolders as $onePict) {
|
||||
if (!preg_match('#\.(jpg|gif|png|jpeg|ico|bmp)$#i', $onePict)) continue;
|
||||
if (preg_match('#(thumbnail|screenshot|muestra)#i', $onePict)) {
|
||||
$thumbNb++;
|
||||
$newNamePict = 'thumbnail_'.$thumbNb.'.png';
|
||||
copy(ACYM_TEMPLATE.str_replace(DS, '/', $folder).'/'.$onePict, $uploadsFolder.$newNamePict);
|
||||
$newTemplate->thumbnail = $newNamePict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$newConfig->numberThumbnail = $thumbNb;
|
||||
$config->save($newConfig);
|
||||
|
||||
$newTemplate->drag_editor = 0;
|
||||
$newTemplate->type = "standard";
|
||||
$newTemplate->template = 1;
|
||||
$newTemplate->library = 0;
|
||||
$newTemplate->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
|
||||
$tempid = $this->save($newTemplate);
|
||||
|
||||
$this->templateId = $tempid;
|
||||
$this->templateNames[] = $newTemplate->name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendAutomation($mailId, $userIds, $sendingDate, $automationAdmin = [])
|
||||
{
|
||||
|
||||
if (empty($mailId)) return acym_translation_sprintf('ACYM_EMAILS_ADDED_QUEUE', 0);
|
||||
if (empty($sendingDate)) return acym_translation('ACYM_WRONG_DATE');
|
||||
if (empty($userIds)) return acym_translation('ACYM_USER_NOT_FOUND');
|
||||
acym_arrayToInteger($userIds);
|
||||
|
||||
if (isset($automationAdmin['automationAdmin']) && $automationAdmin['automationAdmin']) {
|
||||
$userClass = acym_get('class.user');
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
$mail = $this->getOneById($mailId);
|
||||
$user = $userClass->getOneById($automationAdmin['user_id']);
|
||||
|
||||
if (empty($mail) || empty($user)) return false;
|
||||
|
||||
$acympluginHelper = acym_get('helper.plugin');
|
||||
$extractedTags = $acympluginHelper->extractTags($mail, 'subtag');
|
||||
if (!empty($extractedTags)) {
|
||||
foreach ($extractedTags as $dtext => $oneTag) {
|
||||
if (empty($oneTag->info) || $oneTag->info != 'current' || empty($user->{$oneTag->id})) continue;
|
||||
|
||||
$mailerHelper->addParam(str_replace(['{', '}'], '', $dtext), $user->{$oneTag->id});
|
||||
}
|
||||
}
|
||||
|
||||
$mailSent = 0;
|
||||
|
||||
foreach ($userIds as $userId) {
|
||||
if ($mailerHelper->sendOne($mail->id, $userId)) $mailSent++;
|
||||
}
|
||||
|
||||
return $mailSent;
|
||||
}
|
||||
|
||||
$result = acym_query(
|
||||
'INSERT IGNORE INTO #__acym_queue (`mail_id`, `user_id`, `sending_date`)
|
||||
SELECT '.intval($mailId).', user.id, '.acym_escapeDB($sendingDate).'
|
||||
FROM #__acym_user AS user
|
||||
WHERE user.active = 1 AND user.id IN ('.implode(',', $userIds).')'
|
||||
);
|
||||
|
||||
|
||||
$mailStatClass = acym_get('class.mailstat');
|
||||
$mailStat = $mailStatClass->getOneRowByMailId($mailId);
|
||||
|
||||
if (empty($mailStat)) {
|
||||
$mailStat = new stdClass();
|
||||
$mailStat->mail_id = intval($mailId);
|
||||
$mailStat->total_subscribers = intval($result);
|
||||
$mailStat->send_date = $sendingDate;
|
||||
} else {
|
||||
$mailStat->total_subscribers += intval($result);
|
||||
}
|
||||
|
||||
unset($mailStat->sent);
|
||||
$mailStatClass->save($mailStat);
|
||||
|
||||
if ($result === 0) {
|
||||
return acym_translation('ACYM_CAMPAIGN_ALREADY_QUEUED');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function encode($mails = [])
|
||||
{
|
||||
$isArray = true;
|
||||
if (!is_array($mails)) {
|
||||
$mails = [$mails];
|
||||
|
||||
$isArray = false;
|
||||
}
|
||||
|
||||
$return = array_map([$this, 'utf8Encode'], $mails);
|
||||
|
||||
return $isArray ? $return : $return[0];
|
||||
}
|
||||
|
||||
public function decode($mails = [])
|
||||
{
|
||||
$isArray = true;
|
||||
if (!is_array($mails)) {
|
||||
$mails = [$mails];
|
||||
|
||||
$isArray = false;
|
||||
}
|
||||
|
||||
$return = array_map([$this, 'utf8Decode'], $mails);
|
||||
|
||||
return $isArray ? $return : $return[0];
|
||||
}
|
||||
|
||||
protected function utf8Decode($mail)
|
||||
{
|
||||
if (!empty($mail)) {
|
||||
foreach (self::FIELDS_ENCODING as $oneField) {
|
||||
|
||||
if (is_array($mail)) {
|
||||
if (empty($mail[$oneField])) continue;
|
||||
$value = &$mail[$oneField];
|
||||
} else {
|
||||
if (empty($mail->$oneField)) continue;
|
||||
$value = &$mail->$oneField;
|
||||
}
|
||||
|
||||
$value = utf8_decode($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
protected function utf8Encode($mail)
|
||||
{
|
||||
if (!empty($mail)) {
|
||||
foreach (self::FIELDS_ENCODING as $oneField) {
|
||||
|
||||
if (is_array($mail)) {
|
||||
if (empty($mail[$oneField])) continue;
|
||||
$value = &$mail[$oneField];
|
||||
} else {
|
||||
if (empty($mail->$oneField)) continue;
|
||||
$value = &$mail->$oneField;
|
||||
}
|
||||
|
||||
$value = utf8_encode($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymmailStatClass extends acymClass
|
||||
{
|
||||
var $table = 'mail_stat';
|
||||
var $pkey = 'mail_id';
|
||||
|
||||
public function save($mailStat)
|
||||
{
|
||||
$column = [];
|
||||
$valueColumn = [];
|
||||
$columnName = acym_getColumns("mail_stat");
|
||||
|
||||
if (!is_array($mailStat)) {
|
||||
$mailStat = (array)$mailStat;
|
||||
}
|
||||
|
||||
foreach ($mailStat as $key => $value) {
|
||||
if (in_array($key, $columnName)) {
|
||||
$column[] = '`'.acym_secureDBColumn($key).'`';
|
||||
$valueColumn[] = acym_escapeDB($value);
|
||||
}
|
||||
}
|
||||
|
||||
$query = "#__acym_mail_stat (".implode(',', $column).") VALUES (".implode(',', $valueColumn).")";
|
||||
|
||||
$onDuplicate = [];
|
||||
|
||||
if (!empty($mailStat['sent'])) {
|
||||
$onDuplicate[] = " sent = sent + ".intval($mailStat['sent']);
|
||||
}
|
||||
|
||||
if (!empty($mailStat['fail'])) {
|
||||
$onDuplicate[] = " fail = fail + ".intval($mailStat['fail']);
|
||||
}
|
||||
|
||||
if (!empty($mailStat['open_unique'])) {
|
||||
$onDuplicate[] = "open_unique = open_unique + 1";
|
||||
}
|
||||
|
||||
if (!empty($mailStat['open_total'])) {
|
||||
$onDuplicate[] = "open_total = open_total + 1";
|
||||
}
|
||||
|
||||
if (!empty($mailStat['total_subscribers'])) {
|
||||
$onDuplicate[] = "total_subscribers = ".intval($mailStat['total_subscribers']);
|
||||
}
|
||||
|
||||
if (!empty($onDuplicate)) {
|
||||
$query .= " ON DUPLICATE KEY UPDATE ";
|
||||
$query .= implode(',', $onDuplicate);
|
||||
$query = "INSERT INTO ".$query;
|
||||
} else {
|
||||
$query = "INSERT IGNORE INTO ".$query;
|
||||
}
|
||||
|
||||
acym_query($query);
|
||||
}
|
||||
|
||||
public function getTotalSubscribersByMailId($mailId)
|
||||
{
|
||||
$result = acym_loadResult("SELECT total_subscribers FROM #__acym_mail_stat WHERE mail_id = ".intval($mailId)." LIMIT 1");
|
||||
|
||||
return $result === null ? 0 : $result;
|
||||
}
|
||||
|
||||
function getOneByMailId($id = '')
|
||||
{
|
||||
$query = 'SELECT SUM(sent) as sent, SUM(fail) as fail FROM #__acym_mail_stat';
|
||||
$query .= empty($id) ? '' : ' WHERE `mail_id` = '.intval($id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAllFromMailIds($mailsIds = [])
|
||||
{
|
||||
acym_arrayToInteger($mailsIds);
|
||||
if (empty($mailsIds)) {
|
||||
$mailsIds[] = 0;
|
||||
}
|
||||
|
||||
$result = acym_loadObjectList("SELECT * FROM #__acym_mail_stat WHERE mail_id IN (".implode(",", $mailsIds).")", "mail_id");
|
||||
|
||||
return $result === null ? 0 : $result;
|
||||
}
|
||||
|
||||
public function getOneRowByMailId($mailId)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_mail_stat WHERE mail_id = '.intval($mailId);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAllMailsForStats()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$query = 'SELECT mail.* FROM #__acym_mail_stat AS mail_stat LEFT JOIN #__acym_mail AS mail ON mail.id = mail_stat.mail_id';
|
||||
|
||||
return $mailClass->decode(acym_loadObjectList($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymqueryClass extends acymClass
|
||||
{
|
||||
var $from = ' `#__acym_user` AS `user`';
|
||||
var $leftjoin = [];
|
||||
var $join = [];
|
||||
var $where = [];
|
||||
var $orderBy = '';
|
||||
var $limit = '';
|
||||
|
||||
public function getQuery($select = [])
|
||||
{
|
||||
$query = '';
|
||||
if (!empty($select)) $query .= ' SELECT DISTINCT '.implode(',', $select);
|
||||
if (!empty($this->from)) $query .= ' FROM '.$this->from;
|
||||
if (!empty($this->join)) $query .= ' JOIN '.implode(' JOIN ', $this->join);
|
||||
if (!empty($this->leftjoin)) $query .= ' LEFT JOIN '.implode(' LEFT JOIN ', $this->leftjoin);
|
||||
if (!empty($this->where)) $query .= ' WHERE ('.implode(') AND (', $this->where).')';
|
||||
if (!empty($this->orderBy)) $query .= ' ORDER BY '.$this->orderBy;
|
||||
if (!empty($this->limit)) $query .= ' LIMIT '.$this->limit;
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return acym_loadResult($this->getQuery(['COUNT(DISTINCT user.id)']));
|
||||
}
|
||||
|
||||
public function addFlag($id)
|
||||
{
|
||||
if (!empty($this->orderBy) || !empty($this->limit)) {
|
||||
$flagQuery = 'UPDATE #__acym_user';
|
||||
$flagQuery .= ' SET automation = CONCAT(automation, "a'.intval($id).'a")';
|
||||
$flagQuery .= ' WHERE id IN (
|
||||
SELECT id FROM (SELECT user.id FROM #__acym_user AS user';
|
||||
if (!empty($this->join)) $flagQuery .= ' JOIN '.implode(' JOIN ', $this->join);
|
||||
if (!empty($this->leftjoin)) $flagQuery .= ' LEFT JOIN '.implode(' LEFT JOIN ', $this->leftjoin);
|
||||
if (!empty($this->where)) $flagQuery .= ' WHERE ('.implode(') AND (', $this->where).')';
|
||||
if (!empty($this->orderBy)) $flagQuery .= ' ORDER BY '.$this->orderBy;
|
||||
if (!empty($this->limit)) $flagQuery .= ' LIMIT '.$this->limit;
|
||||
$flagQuery .= ') tmp);';
|
||||
} else {
|
||||
$flagQuery = 'UPDATE #__acym_user AS user ';
|
||||
if (!empty($this->join)) $flagQuery .= ' JOIN '.implode(' JOIN ', $this->join);
|
||||
if (!empty($this->leftjoin)) $flagQuery .= ' LEFT JOIN '.implode(' LEFT JOIN ', $this->leftjoin);
|
||||
$flagQuery .= ' SET user.automation = CONCAT(user.automation, "a'.intval($id).'a")';
|
||||
if (!empty($this->where)) $flagQuery .= ' WHERE ('.implode(') AND (', $this->where).')';
|
||||
}
|
||||
acym_query($flagQuery);
|
||||
|
||||
$this->join = [];
|
||||
$this->leftjoin = [];
|
||||
$this->where = ['user.automation LIKE "%a'.intval($id).'a%"'];
|
||||
$this->orderBy = '';
|
||||
$this->limit = '';
|
||||
}
|
||||
|
||||
public function removeFlag($id)
|
||||
{
|
||||
acym_query('UPDATE #__acym_user SET automation = REPLACE(automation, "a'.intval($id).'a", "") WHERE automation LIKE "%a'.intval($id).'a%"');
|
||||
}
|
||||
|
||||
function convertQuery($table, $column, $operator, $value, $type = '')
|
||||
{
|
||||
$operator = str_replace(['<', '>'], ['<', '>'], $operator);
|
||||
|
||||
if ($operator == 'CONTAINS' || ($type == 'phone' && $operator == '=')) {
|
||||
$operator = 'LIKE';
|
||||
$value = '%'.$value.'%';
|
||||
} elseif ($operator == 'BEGINS') {
|
||||
$operator = 'LIKE';
|
||||
$value = $value.'%';
|
||||
} elseif ($operator == 'END') {
|
||||
$operator = 'LIKE';
|
||||
$value = '%'.$value;
|
||||
} elseif ($operator == 'NOTCONTAINS' || ($type == 'phone' && $operator == '!=')) {
|
||||
$operator = 'NOT LIKE';
|
||||
$value = '%'.$value.'%';
|
||||
} elseif ($operator == 'REGEXP') {
|
||||
if ($value === '') return '1 = 1';
|
||||
} elseif ($operator == 'NOT REGEXP') {
|
||||
if ($value === '') return '0 = 1';
|
||||
} elseif (!in_array($operator, ['IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='])) {
|
||||
die(acym_translation_sprintf('ACYM_UNKNOWN_OPERATOR', $operator));
|
||||
}
|
||||
|
||||
if (strpos($value, '[time]') !== false) {
|
||||
$value = acym_replaceDate($value);
|
||||
$value = strftime('%Y-%m-%d %H:%M:%S', $value);
|
||||
}
|
||||
|
||||
$replace = ['{year}', '{month}', '{weekday}', '{day}'];
|
||||
$replaceBy = [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(['year', 'month', 'weekday', 'day'], ['Y', 'm', 'N', 'd'], $results[1][$i]);
|
||||
$delay = str_replace(['add', 'remove'], ['+', '-'], $results[2][$i]).intval($results[3][$i]).' '.str_replace('weekday', 'day', $results[1][$i]);
|
||||
$value = str_replace($oneMatch, date($format, strtotime($delay)), $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_numeric($value) || in_array($operator, ['REGEXP', 'NOT REGEXP', 'NOT LIKE', 'LIKE', '=', '!='])) {
|
||||
$value = acym_escapeDB($value);
|
||||
}
|
||||
|
||||
if (in_array($operator, ['IS NULL', 'IS NOT NULL'])) {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
if ($type == 'datetime' && in_array($operator, ['=', '!='])) {
|
||||
return 'DATE_FORMAT('.acym_secureDBColumn($table).'.`'.acym_secureDBColumn($column).'`, "%Y-%m-%d") '.$operator.' '.'DATE_FORMAT('.$value.', "%Y-%m-%d")';
|
||||
}
|
||||
if ($type == 'timestamp' && in_array($operator, ['=', '!='])) {
|
||||
return 'FROM_UNIXTIME('.acym_secureDBColumn($table).'.`'.acym_secureDBColumn($column).'`, "%Y-%m-%d") '.$operator.' '.'FROM_UNIXTIME('.$value.', "%Y-%m-%d")';
|
||||
}
|
||||
|
||||
return acym_secureDBColumn($table).'.`'.acym_secureDBColumn($column).'` '.$operator.' '.$value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,388 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymqueueClass extends acymClass
|
||||
{
|
||||
|
||||
public function getMatchingCampaigns($settings)
|
||||
{
|
||||
|
||||
$mailStatClass = acym_get('class.mailstat');
|
||||
$query = 'FROM #__acym_mail AS mail
|
||||
LEFT JOIN #__acym_queue AS queue ON mail.id = queue.mail_id
|
||||
LEFT JOIN #__acym_campaign AS campaign ON mail.id = campaign.mail_id ';
|
||||
|
||||
$queryStatus = 'SELECT COUNT(DISTINCT mail.id) AS number, IF(queue.mail_id IS NULL, campaign.active + 2, campaign.active) AS score
|
||||
FROM #__acym_mail AS mail
|
||||
LEFT JOIN #__acym_queue AS queue ON queue.mail_id = mail.id
|
||||
LEFT JOIN #__acym_campaign AS campaign ON mail.id = campaign.mail_id';
|
||||
|
||||
$filters = [];
|
||||
$filters[] = '(campaign.id IS NULL AND queue.mail_id IS NOT NULL) OR (campaign.id IS NOT NULL AND campaign.draft = 0 AND ((queue.mail_id IS NULL AND campaign.scheduled = 1 AND campaign.sent = 0) OR queue.mail_id IS NOT NULL))';
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$query .= ' JOIN #__acym_tag AS tag ON mail.id = tag.id_element AND tag.type = "mail" AND tag.name = '.acym_escapeDB($settings['tag']);
|
||||
$queryStatus .= ' JOIN #__acym_tag AS tag ON mail.id = tag.id_element AND tag.type = "mail" AND tag.name = '.acym_escapeDB($settings['tag']);
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'mail.subject LIKE '.acym_escapeDB('%'.$settings['search'].'%').' OR mail.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$queryStatus .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['status'])) {
|
||||
$allowedStatus = [
|
||||
'sending' => 'campaign.active = 1 AND queue.mail_id IS NOT NULL',
|
||||
'paused' => 'campaign.active = 0',
|
||||
'scheduled' => 'campaign.active = 1 AND queue.mail_id IS NULL',
|
||||
'automation' => 'mail.type = '.acym_escapeDB('automation'),
|
||||
];
|
||||
|
||||
if (empty($allowedStatus[$settings['status']])) {
|
||||
die('Unauthorized filter: '.$settings['status']);
|
||||
}
|
||||
|
||||
$filters[] = $allowedStatus[$settings['status']];
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
$queryCount = 'SELECT COUNT(DISTINCT mail.id) '.$query;
|
||||
$query .= ' GROUP BY mail.id';
|
||||
|
||||
$query = 'SELECT mail.name, mail.subject, mail.id, campaign.id AS campaign, IF(campaign.sending_date IS NULL, queue.sending_date, campaign.sending_date) as sending_date, campaign.scheduled, campaign.active, COUNT(queue.mail_id) AS nbqueued '.$query.' ORDER BY queue.sending_date ASC';
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$results['elements'] = $mailClass->decode(acym_loadObjectList($query, '', $settings['offset'], $settings['campaignsPerPage']));
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
foreach ($results['elements'] as $i => $oneCampaign) {
|
||||
if (empty($oneCampaign->campaign)) {
|
||||
$results['elements'][$i]->iscampaign = false;
|
||||
$results['elements'][$i]->lists = acym_translation('ACYM_MAIL_FROM_AUTOMATION_SENT_TO');
|
||||
$results['elements'][$i]->recipients = acym_loadResult('SELECT COUNT(*) FROM #__acym_queue WHERE mail_id = '.intval($oneCampaign->id));
|
||||
} else {
|
||||
$results['elements'][$i]->iscampaign = true;
|
||||
$results['elements'][$i]->lists = acym_loadObjectList(
|
||||
'SELECT l.color, l.name , l.id
|
||||
FROM #__acym_list AS l
|
||||
JOIN #__acym_mail_has_list AS ml ON ml.list_id = l.id
|
||||
WHERE ml.mail_id = '.intval($oneCampaign->id)
|
||||
);
|
||||
$results['elements'][$i]->recipients = intval($mailStatClass->getTotalSubscribersByMailId($oneCampaign->id));
|
||||
}
|
||||
}
|
||||
|
||||
$automationNumber = acym_loadResult('SELECT COUNT(DISTINCT mail.id) FROM #__acym_mail as mail JOIN #__acym_queue AS queue ON mail.id = queue.mail_id WHERE mail.type = '.acym_escapeDB('automation'));
|
||||
|
||||
$elementsPerStatus = acym_loadObjectList($queryStatus.' GROUP BY score', 'score');
|
||||
for ($i = 0 ; $i < 4 ; $i++) {
|
||||
$elementsPerStatus[$i] = empty($elementsPerStatus[$i]) ? 0 : $elementsPerStatus[$i]->number;
|
||||
}
|
||||
|
||||
$results['status'] = [
|
||||
'all' => array_sum($elementsPerStatus) + $automationNumber,
|
||||
'sending' => $elementsPerStatus[1],
|
||||
'paused' => $elementsPerStatus[0] + $elementsPerStatus[2],
|
||||
'scheduled' => $elementsPerStatus[3],
|
||||
'automation' => $automationNumber,
|
||||
];
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getMatchingResults($settings)
|
||||
{
|
||||
$query = 'FROM #__acym_queue AS queue
|
||||
JOIN #__acym_mail AS mail ON mail.id = queue.mail_id
|
||||
JOIN #__acym_user AS user ON queue.user_id = user.id ';
|
||||
|
||||
$filters = [];
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$query .= ' JOIN #__acym_tag AS tag ON queue.mail_id = tag.id_element AND tag.type = "mail" AND tag.name = '.acym_escapeDB($settings['tag']);
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$filters[] = 'mail.subject LIKE '.acym_escapeDB('%'.$settings['search'].'%').' OR mail.name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['tag'])) {
|
||||
$query .= ' GROUP BY queue.mail_id, queue.user_id';
|
||||
}
|
||||
|
||||
$queryCount = 'SELECT COUNT(queue.mail_id) '.$query;
|
||||
$query = 'SELECT mail.id, queue.sending_date, mail.name, mail.subject, user.email, user.name AS user_name, queue.user_id, queue.try '.$query.' ORDER BY queue.sending_date ASC';
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$results['elements'] = $mailClass->decode(acym_loadObjectList($query, '', $settings['offset'], $settings['elementsPerPage']));
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function scheduleReady()
|
||||
{
|
||||
$this->messages = [];
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailReady = $mailClass->decode(
|
||||
acym_loadObjectList(
|
||||
'SELECT mail.id, campaign.sending_date, mail.name
|
||||
FROM #__acym_campaign AS campaign
|
||||
JOIN #__acym_mail AS mail
|
||||
ON campaign.mail_id = mail.id
|
||||
WHERE campaign.scheduled = 1
|
||||
AND campaign.draft = 0
|
||||
AND campaign.sending_date <= '.acym_escapeDB(acym_date('now', 'Y-m-d H:i:s', false)).'
|
||||
AND campaign.sent = 0',
|
||||
'id'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (empty($mailReady)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($mailReady as $mailid => $mail) {
|
||||
$nbQueue = $this->queue($mailid, $mail->sending_date);
|
||||
$this->messages[] = acym_translation_sprintf('ACYM_ADDED_QUEUE_SCHEDULE', $nbQueue, '<b>'.$mail->name.'</b>');
|
||||
}
|
||||
|
||||
$mailIds = array_keys($mailReady);
|
||||
acym_arrayToInteger($mailIds);
|
||||
$campaignsIDs = acym_loadResultArray('SELECT id FROM #__acym_campaign WHERE mail_id IN ('.implode(',', $mailIds).')');
|
||||
$campaignClass = acym_get('class.campaign');
|
||||
foreach ($campaignsIDs as $campaignID) {
|
||||
$campaignClass->send($campaignID, $nbQueue);
|
||||
}
|
||||
|
||||
return count($mailReady);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
$query = 'DELETE FROM #__acym_queue WHERE mail_id IN ('.implode(',', $elements).')';
|
||||
$result = acym_query($query);
|
||||
|
||||
acym_query('UPDATE #__acym_campaign SET draft = 1, active = 1 WHERE mail_id IN ('.implode(',', $elements).')');
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteOne($elements, $mailId = null)
|
||||
{
|
||||
if (!is_array($elements)) {
|
||||
$elements = [$elements];
|
||||
}
|
||||
|
||||
if (empty($elements)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$nbDeleted = 0;
|
||||
foreach ($elements as $one) {
|
||||
if (strpos($one, '_')) {
|
||||
list($mailId, $userId) = explode('_', $one);
|
||||
} else {
|
||||
$userId = $one;
|
||||
}
|
||||
|
||||
$query = 'DELETE FROM #__acym_queue WHERE user_id = '.intval($userId);
|
||||
if (!empty($mailId)) {
|
||||
$query .= ' AND mail_id = '.intval($mailId);
|
||||
}
|
||||
|
||||
$res = acym_query($query);
|
||||
if ($res === false) {
|
||||
$this->errors[] = acym_getDBError();
|
||||
} else {
|
||||
$nbDeleted += $res;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function getReady($limit, $mailid = 0)
|
||||
{
|
||||
if (empty($limit)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
$order = $config->get('sendorder');
|
||||
if (empty($order)) {
|
||||
$order = 'queue.`user_id` ASC';
|
||||
} else {
|
||||
if ($order == 'rand') {
|
||||
$order = 'RAND()';
|
||||
} else {
|
||||
$ordering = explode(',', $order);
|
||||
$order = 'queue.`'.acym_secureDBColumn(trim($ordering[0])).'` '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
}
|
||||
|
||||
$query = 'SELECT queue.* FROM #__acym_queue AS queue';
|
||||
$query .= ' JOIN #__acym_user AS user ON queue.`user_id` = user.`id` ';
|
||||
$query .= ' JOIN #__acym_mail AS mail ON queue.`mail_id` = mail.`id` ';
|
||||
$query .= ' LEFT JOIN #__acym_campaign AS campaign ON campaign.`mail_id` = mail.`id` ';
|
||||
$query .= ' WHERE queue.`sending_date` <= '.acym_escapeDB(acym_date('now', 'Y-m-d H:i:s', false)).' AND (campaign.mail_id IS NULL OR (campaign.`active` = 1 AND campaign.`draft` = 0 AND user.active = 1))';
|
||||
|
||||
if ($config->get('require_confirmation', 1) == 1) {
|
||||
$query .= ' AND (user.confirmed = 1 OR mail.type = "notification")';
|
||||
}
|
||||
|
||||
if (!empty($this->emailtypes)) {
|
||||
foreach ($this->emailtypes as &$oneType) {
|
||||
$oneType = acym_escapeDB($oneType);
|
||||
}
|
||||
$query .= ' AND (mail.type = '.implode(' OR mail.type = ', $this->emailtypes).')';
|
||||
}
|
||||
if (!empty($mailid)) {
|
||||
$query .= ' AND queue.`mail_id` = '.intval($mailid);
|
||||
}
|
||||
$query .= ' ORDER BY queue.`priority` ASC, queue.`sending_date` ASC, '.$order;
|
||||
$startqueue = acym_getVar('int', 'startqueue', 0);
|
||||
$query .= ' LIMIT '.intval($startqueue).','.intval($limit);
|
||||
try {
|
||||
$results = acym_loadObjectList($query);
|
||||
} catch (Exception $e) {
|
||||
$results = null;
|
||||
}
|
||||
|
||||
if ($results === null) {
|
||||
acym_query('REPAIR TABLE #__acym_queue, #__acym_user, #__acym_mail, #__acym_campaign');
|
||||
}
|
||||
|
||||
if (empty($results)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!empty($results)) {
|
||||
$firstElementQueued = reset($results);
|
||||
acym_query('UPDATE #__acym_queue SET sending_date = DATE_ADD(sending_date, INTERVAL 1 SECOND) WHERE mail_id = '.intval($firstElementQueued->mail_id).' AND user_id = '.intval($firstElementQueued->user_id).' LIMIT 1');
|
||||
}
|
||||
|
||||
$userIds = [];
|
||||
foreach ($results as $oneRes) {
|
||||
$userIds[$oneRes->user_id] = intval($oneRes->user_id);
|
||||
}
|
||||
|
||||
$cleanQueue = false;
|
||||
if (!empty($userIds)) {
|
||||
$allusers = acym_loadObjectList('SELECT * FROM #__acym_user WHERE id IN ('.implode(',', $userIds).')', 'id');
|
||||
foreach ($results as $oneId => $oneRes) {
|
||||
if (empty($allusers[$oneRes->user_id])) {
|
||||
$cleanQueue = true;
|
||||
continue;
|
||||
}
|
||||
foreach ($allusers[$oneRes->user_id] as $oneVar => $oneVal) {
|
||||
$results[$oneId]->$oneVar = $oneVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cleanQueue) {
|
||||
acym_query('DELETE queue.* FROM #__acym_queue AS queue LEFT JOIN #__acym_user AS user ON queue.user_id = user.id WHERE user.id IS NULL');
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function delayFailed($mailId, $userIds)
|
||||
{
|
||||
acym_arrayToInteger($userIds);
|
||||
if (empty($mailId) || empty($userIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return acym_query(
|
||||
'UPDATE #__acym_queue
|
||||
SET sending_date = DATE_ADD(sending_date, INTERVAL 1 HOUR), try = try +1
|
||||
WHERE mail_id = '.intval($mailId).'
|
||||
AND user_id IN ('.implode(',', $userIds).')'
|
||||
);
|
||||
}
|
||||
|
||||
private function queue($mailId, $sending_date)
|
||||
{
|
||||
$config = acym_config();
|
||||
$priority = $config->get('priority_newsletter', 3);
|
||||
|
||||
|
||||
return acym_query(
|
||||
'INSERT IGNORE INTO #__acym_queue
|
||||
SELECT '.intval($mailId).', userlist.user_id, '.acym_escapeDB($sending_date).', '.intval($priority).', 0
|
||||
FROM #__acym_user_has_list AS userlist
|
||||
JOIN #__acym_mail_has_list AS maillist ON userlist.list_id = maillist.list_id
|
||||
WHERE userlist.status = 1 AND maillist.mail_id = '.intval($mailId)
|
||||
);
|
||||
}
|
||||
|
||||
public function addQueue($userId, $mailId, $sendingDate)
|
||||
{
|
||||
$config = acym_config();
|
||||
$priority = $config->get('priority_newsletter', 3);
|
||||
|
||||
return acym_query('INSERT IGNORE INTO #__acym_queue VALUES ('.intval($mailId).', '.intval($userId).', '.intval($sendingDate).', '.intval($priority).')');
|
||||
}
|
||||
|
||||
public function unpauseCampaign($campaignId, $active)
|
||||
{
|
||||
if (acym_query('UPDATE #__acym_campaign SET active = '.intval($active).' WHERE id = '.intval($campaignId))) {
|
||||
acym_enqueueNotification(acym_translation($active ? 'ACYM_UNPAUSE_CAMPAIGN_SUCCESSFUL' : 'ACYM_PAUSE_CAMPAIGN_SUCCESSFUL'), "success", 10000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation($active ? 'ACYM_UNPAUSE_CAMPAIGN_FAIL' : 'ACYM_PAUSE_CAMPAIGN_FAIL'), "error", 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeUnconfirmedUsersEmails()
|
||||
{
|
||||
return acym_query(
|
||||
'DELETE `queue`.*
|
||||
FROM `#__acym_queue` AS `queue`
|
||||
JOIN `#__acym_user` AS `user` ON `queue`.`user_id` = `user`.`id`
|
||||
WHERE `user`.`confirmed` = 0 OR `user`.`active` = 0'
|
||||
);
|
||||
}
|
||||
|
||||
public function emptyQueue()
|
||||
{
|
||||
return acym_query('DELETE FROM `#__acym_queue`');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymruleClass extends acymClass
|
||||
{
|
||||
var $table = 'rule';
|
||||
var $pkey = 'id';
|
||||
var $errors = [];
|
||||
|
||||
public function getAll($active = false)
|
||||
{
|
||||
$rules = acym_loadObjectList('SELECT * FROM `#__acym_rule` '.($active ? 'WHERE active = 1' : '').' ORDER BY `ordering` ASC');
|
||||
|
||||
foreach ($rules as $i => $rule) {
|
||||
$rules[$i] = $this->_prepareRule($rule);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
$rule = acym_loadObject('SELECT * FROM `#__acym_rule` WHERE `id` = '.intval($id).' LIMIT 1');
|
||||
|
||||
return $this->_prepareRule($rule);
|
||||
}
|
||||
|
||||
private function _prepareRule($rule)
|
||||
{
|
||||
$columns = ['executed_on', 'action_message', 'action_user'];
|
||||
foreach ($columns as $oneColumn) {
|
||||
if (!empty($rule->$oneColumn)) {
|
||||
$rule->$oneColumn = json_decode($rule->$oneColumn, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $rule;
|
||||
}
|
||||
|
||||
public function save($rule)
|
||||
{
|
||||
if (empty($rule)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::save($rule);
|
||||
}
|
||||
|
||||
public function delete($ids)
|
||||
{
|
||||
return parent::delete($ids);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymstepClass extends acymClass
|
||||
{
|
||||
|
||||
var $table = 'step';
|
||||
var $pkey = 'id';
|
||||
|
||||
|
||||
public function save($step)
|
||||
{
|
||||
foreach ($step as $oneAttribute => $value) {
|
||||
if (empty($value)) continue;
|
||||
if (is_array($value)) $value = json_encode($value);
|
||||
|
||||
$step->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
return parent::save($step);
|
||||
}
|
||||
|
||||
public function getOneStepByAutomationId($automationId)
|
||||
{
|
||||
return acym_loadObject('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
return acym_loadObject('SELECT * FROM #__acym_step WHERE id = '.intval($id));
|
||||
}
|
||||
|
||||
public function getStepsByAutomationId($automationId)
|
||||
{
|
||||
return acym_loadObjectList('SELECT * FROM #__acym_step WHERE automation_id = '.intval($automationId));
|
||||
}
|
||||
|
||||
public function getActiveStepByTrigger($trigger)
|
||||
{
|
||||
return acym_loadObjectList(
|
||||
'SELECT step.*
|
||||
FROM #__acym_step AS step
|
||||
LEFT JOIN #__acym_automation AS automation ON step.automation_id = automation.id
|
||||
WHERE step.triggers LIKE '.acym_escapeDB('%"'.$trigger.'"%').' AND automation.active = 1'
|
||||
);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) $elements = [$elements];
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
if (empty($elements)) return 0;
|
||||
|
||||
$conditions = acym_loadResultArray('SELECT id FROM #__acym_condition WHERE step_id IN ('.implode(',', $elements).')');
|
||||
$conditionClass = acym_get('class.condition');
|
||||
$conditionsDeleted = $conditionClass->delete($conditions);
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymtagClass extends acymClass
|
||||
{
|
||||
var $table = 'tag';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function setTags($type, $elementId, $newTags)
|
||||
{
|
||||
acym_query('DELETE FROM #__acym_tag WHERE `type` = '.acym_escapeDB($type).' AND id_element = '.intval($elementId));
|
||||
|
||||
$tagsToInsertQuery = [];
|
||||
|
||||
foreach ($newTags as $oneTag) {
|
||||
|
||||
$newTag = new stdClass();
|
||||
$newTag->type = $type;
|
||||
|
||||
if (strpos($oneTag, "acy_new_tag_") !== false) {
|
||||
$tagName = substr($oneTag, strlen("acy_new_tag_"));
|
||||
if (empty($tagName)) {
|
||||
continue;
|
||||
}
|
||||
$newTag->name = $tagName;
|
||||
} else {
|
||||
$newTag->name = $oneTag;
|
||||
}
|
||||
$tagsToInsertQuery[] = '('.acym_escapeDB($newTag->name).','.acym_escapeDB($newTag->type).', '.intval($elementId).')';
|
||||
}
|
||||
if (!empty($tagsToInsertQuery)) {
|
||||
acym_query('INSERT INTO #__acym_tag (`name`, `type`, `id_element`) VALUES '.implode(',', $tagsToInsertQuery));
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllTagsByType($type)
|
||||
{
|
||||
$query = 'SELECT `name` as value, `name` FROM #__acym_tag WHERE `type` = '.acym_escapeDB($type).' GROUP BY `name`';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllTagsByElementId($type, $id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_tag WHERE type = '.acym_escapeDB($type).' AND id_element = '.intval($id);
|
||||
$tags = acym_loadResultArray($query);
|
||||
|
||||
return empty($tags) ? [] : $tags;
|
||||
}
|
||||
|
||||
public function getAllTagsByTypeAndElementIds($type, $ids)
|
||||
{
|
||||
acym_arrayToInteger($ids);
|
||||
if (empty($ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM #__acym_tag WHERE `type` = '.acym_escapeDB($type).' AND `id_element` IN ('.implode(',', $ids).')';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymurlClass extends acymClass
|
||||
{
|
||||
var $table = 'url';
|
||||
var $pkey = 'id';
|
||||
|
||||
public function save($url)
|
||||
{
|
||||
if (empty($url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($url as $oneAttribute => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$url->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
return parent::save($url);
|
||||
}
|
||||
|
||||
public function getOneUrlById($id)
|
||||
{
|
||||
$query = 'SELECT * from #__acym_url WHERE id = '.intval($id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function get($url)
|
||||
{
|
||||
$column = is_numeric($url) ? 'id' : 'url';
|
||||
$query = 'SELECT * FROM #__acym_url WHERE '.$column.' = '.acym_escapeDB($url).' LIMIT 1';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAdd($url)
|
||||
{
|
||||
$currentUrl = $this->get($url);
|
||||
if (empty($currentUrl->id)) {
|
||||
$currentUrl = new stdClass();
|
||||
$currentUrl->name = $url;
|
||||
$currentUrl->url = $url;
|
||||
$currentUrl->id = $this->save($currentUrl);
|
||||
|
||||
if (empty($currentUrl->id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return $currentUrl;
|
||||
}
|
||||
|
||||
public function getUrl($url, $mailid, $userid)
|
||||
{
|
||||
|
||||
if (empty($url) || empty($mailid) || empty($userid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $allurls;
|
||||
|
||||
$url = str_replace('&', '&', $url);
|
||||
|
||||
if (empty($allurls[$url])) {
|
||||
$currentUrl = $this->getAdd($url);
|
||||
|
||||
$allurls[$url] = acym_frontendLink('fronturl&action=acymailing_frontrouter&task=click&urlid='.$currentUrl->id.'&userid='.$userid.'&mailid='.$mailid);
|
||||
}
|
||||
|
||||
return $allurls[$url];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymurlClickClass extends acymClass
|
||||
{
|
||||
var $table = 'url_click';
|
||||
|
||||
public function save($urlClick)
|
||||
{
|
||||
$column = [];
|
||||
$valueColumn = [];
|
||||
$columnName = acym_getColumns("url_click");
|
||||
|
||||
if (!is_array($urlClick)) {
|
||||
$urlClick = (array)$urlClick;
|
||||
}
|
||||
|
||||
foreach ($urlClick as $key => $value) {
|
||||
if (in_array($key, $columnName)) {
|
||||
$column[] = '`'.acym_secureDBColumn($key).'`';
|
||||
$valueColumn[] = acym_escapeDB($value);
|
||||
}
|
||||
}
|
||||
|
||||
$query = "#__acym_url_click (".implode(',', $column).") VALUES (".implode(',', $valueColumn).")";
|
||||
|
||||
$onDuplicate = [];
|
||||
|
||||
if (!empty($urlClick['click'])) {
|
||||
$onDuplicate[] = "click = click + 1";
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('user_click', ['userId' => $urlClick['user_id']]);
|
||||
}
|
||||
|
||||
if (!empty($onDuplicate)) {
|
||||
$query .= " ON DUPLICATE KEY UPDATE ";
|
||||
$query .= implode(',', $onDuplicate);
|
||||
$query = "INSERT INTO ".$query;
|
||||
} else {
|
||||
$query = "INSERT IGNORE INTO ".$query;
|
||||
}
|
||||
|
||||
acym_query($query);
|
||||
}
|
||||
|
||||
public function getClickRate($mailid = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(DISTINCT user_id) as click FROM #__acym_url_click ';
|
||||
$query .= empty($mailid) ? '' : ' WHERE `mail_id` = '.intval($mailid);
|
||||
$query .= ' ORDER BY user_id';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAllClickByMailMonth($mailid = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(*) as click, DATE_FORMAT(date_click, \'%Y-%m\') as date_click FROM #__acym_url_click WHERE click > 0';
|
||||
$query .= empty($mailid) ? '' : ' AND `mail_id` = '.intval($mailid);
|
||||
$query .= empty($start) ? '' : ' AND date_click >= '.acym_escapeDB($start);
|
||||
$query .= empty($end) ? '' : ' AND date_click <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY MONTH(date_click), YEAR(date_click) ORDER BY date_click';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllClickByMailWeek($mailid = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(*) as click, DATE_FORMAT(date_click, \'%Y-%m-%d\') as date_click FROM #__acym_url_click WHERE click > 0';
|
||||
$query .= empty($mailid) ? '' : ' AND `mail_id` = '.intval($mailid);
|
||||
$query .= empty($start) ? '' : ' AND date_click >= '.acym_escapeDB($start);
|
||||
$query .= empty($end) ? '' : ' AND date_click <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY WEEK(date_click), YEAR(date_click) ORDER BY date_click';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllClickByMailDay($mailid = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(*) as click, DATE_FORMAT(date_click, \'%Y-%m-%d\') as date_click FROM #__acym_url_click WHERE click > 0';
|
||||
$query .= empty($mailid) ? '' : ' AND `mail_id` = '.intval($mailid);
|
||||
$query .= empty($start) ? '' : ' AND date_click >= '.acym_escapeDB($start);
|
||||
$query .= empty($end) ? '' : ' AND date_click <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY DAYOFYEAR(date_click), YEAR(date_click) ORDER BY date_click';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllClickByMailHour($mailid = '', $start = '', $end = '')
|
||||
{
|
||||
$query = 'SELECT COUNT(*) as click, DATE_FORMAT(date_click, \'%Y-%m-%d %H:00:00\') as date_click FROM #__acym_url_click WHERE click > 0';
|
||||
$query .= empty($mailid) ? '' : ' AND `mail_id` = '.intval($mailid);
|
||||
$query .= empty($start) ? '' : ' AND date_click >= '.acym_escapeDB($start);
|
||||
$query .= empty($end) ? '' : ' AND date_click <= '.acym_escapeDB($end);
|
||||
$query .= ' GROUP BY HOUR(date_click), DAYOFYEAR(date_click), YEAR(date_click) ORDER BY date_click';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getAllLinkFromEmail($id)
|
||||
{
|
||||
$queryClickUrl = 'SELECT url.name, SUM(urlclick.click) as click FROM #__acym_url_click AS urlclick
|
||||
LEFT JOIN #__acym_url AS url ON urlclick.url_id = url.id
|
||||
WHERE `mail_id` = '.intval($id).' GROUP BY `url_id`';
|
||||
|
||||
$queryCountAllClicks = 'SELECT SUM(click) FROM #__acym_url_click WHERE `mail_id` = '.intval($id);
|
||||
|
||||
$return = [
|
||||
'urls_click' => acym_loadObjectList($queryClickUrl),
|
||||
'allClick' => acym_loadResult($queryCountAllClicks),
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
812
deployed/acym/administrator/components/com_acym/classes/user.php
Normal file
812
deployed/acym/administrator/components/com_acym/classes/user.php
Normal file
@ -0,0 +1,812 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymuserClass extends acymClass
|
||||
{
|
||||
var $table = 'user';
|
||||
var $pkey = 'id';
|
||||
|
||||
var $sendWelcome = true;
|
||||
var $sendUnsubscribe = true;
|
||||
|
||||
var $checkVisitor = true;
|
||||
var $restrictedFields = ['id', 'key', 'confirmed', 'active', 'cms_id', 'creation_date'];
|
||||
var $allowModif = false;
|
||||
var $requireId = false;
|
||||
var $sendConf = true;
|
||||
var $forceConf = false;
|
||||
var $confirmationSentSuccess = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$missingKey = acym_loadResultArray('SELECT `id` FROM #__acym_user WHERE `key` IS NULL LIMIT 5000');
|
||||
if (!empty($missingKey)) {
|
||||
$newValues = [];
|
||||
foreach ($missingKey as $oneUserId) {
|
||||
$newValues[] = intval($oneUserId).','.acym_escapeDB(acym_generateKey(14));
|
||||
}
|
||||
acym_query('INSERT INTO #__acym_user (`id`, `key`) VALUES ('.implode('),(', $newValues).') ON DUPLICATE KEY UPDATE `key` = VALUES(`key`)');
|
||||
}
|
||||
}
|
||||
|
||||
public function getMatchingUsers($settings)
|
||||
{
|
||||
$query = 'SELECT user.* FROM #__acym_user AS user';
|
||||
$queryCount = 'SELECT COUNT(user.id) FROM #__acym_user AS user';
|
||||
$queryStatus = 'SELECT COUNT(id) AS number, active FROM #__acym_user AS user';
|
||||
$filters = [];
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$searchValue = acym_escapeDB('%'.$settings['search'].'%');
|
||||
$filters[] = 'user.email LIKE '.$searchValue.' OR user.name LIKE '.$searchValue;
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$queryStatus .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['status'])) {
|
||||
$allowedStatus = [
|
||||
'active' => 'active = 1',
|
||||
'inactive' => 'active = 0',
|
||||
];
|
||||
if (empty($allowedStatus[$settings['status']])) {
|
||||
die('Injection denied');
|
||||
}
|
||||
$filters[] = 'user.'.$allowedStatus[$settings['status']];
|
||||
}
|
||||
|
||||
if (!empty($settings['hiddenUsers'])) {
|
||||
acym_arrayToInteger($settings['hiddenUsers']);
|
||||
$filters[] = 'user.id NOT IN('.implode(',', $settings['hiddenUsers']).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['showOnlySelected'])) {
|
||||
if (!empty($settings['selectedUsers'])) {
|
||||
acym_arrayToInteger($settings['selectedUsers']);
|
||||
$filters[] = 'user.id IN('.implode(',', $settings['selectedUsers']).')';
|
||||
} else {
|
||||
return ['users' => [], 'total' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
$query .= ' ORDER BY user.'.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
}
|
||||
|
||||
$settings['offset'] = $settings['offset'] < 0 ? 0 : $settings['offset'];
|
||||
|
||||
$results['users'] = acym_loadObjectList($query, '', $settings['offset'], $settings['usersPerPage']);
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
$usersPerStatus = acym_loadObjectList($queryStatus.' GROUP BY active', 'active');
|
||||
|
||||
for ($i = 0 ; $i < 2 ; $i++) {
|
||||
$usersPerStatus[$i] = empty($usersPerStatus[$i]) ? 0 : $usersPerStatus[$i]->number;
|
||||
}
|
||||
|
||||
$results['status'] = [
|
||||
'all' => array_sum($usersPerStatus),
|
||||
'active' => $usersPerStatus[1],
|
||||
'inactive' => $usersPerStatus[0],
|
||||
];
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getOneById($id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user WHERE id = '.intval($id).' LIMIT 1';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getOneByCMSId($id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user WHERE cms_id = '.intval($id).' LIMIT 1';
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
|
||||
public function getOneByEmail($email)
|
||||
{
|
||||
$query = "SELECT * FROM #__acym_user WHERE email = ".acym_escapeDB($email)." LIMIT 1";
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getUserSubscriptionById($userId, $key = 'id')
|
||||
{
|
||||
$query = 'SELECT list.id, list.name, list.color, list.active, list.visible, userlist.status, userlist.subscription_date, userlist.unsubscribe_date
|
||||
FROM #__acym_list AS list
|
||||
JOIN #__acym_user_has_list AS userlist
|
||||
ON list.id = userlist.list_id
|
||||
WHERE userlist.user_id = '.intval($userId);
|
||||
|
||||
return acym_loadObjectList($query, $key);
|
||||
}
|
||||
|
||||
public function getAllListsUserSubscriptionById($userId, $key = 'id')
|
||||
{
|
||||
$query = 'SELECT list.id, list.name, list.color, list.active, list.visible, userlist.status, userlist.subscription_date, userlist.unsubscribe_date
|
||||
FROM #__acym_list AS list
|
||||
LEFT JOIN #__acym_user_has_list AS userlist
|
||||
ON list.id = userlist.list_id
|
||||
AND userlist.user_id = '.intval($userId);
|
||||
|
||||
return acym_loadObjectList($query, $key);
|
||||
}
|
||||
|
||||
public function getUsersSubscriptionsByIds($usersId)
|
||||
{
|
||||
$query = 'SELECT id, user_id, l.color, l.name
|
||||
FROM #__acym_list AS l
|
||||
JOIN #__acym_user_has_list AS userlist
|
||||
ON l.id = userlist.list_id
|
||||
WHERE user_id IN ('.implode(',', $usersId).')
|
||||
AND userlist.status = 1';
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
public function getCountTotalUsers()
|
||||
{
|
||||
$query = 'SELECT COUNT(id) FROM #__acym_user';
|
||||
|
||||
return acym_loadResult($query);
|
||||
}
|
||||
|
||||
public function getSubscriptionStatus($userId, $listids = [])
|
||||
{
|
||||
$query = 'SELECT status, list_id FROM #__acym_user_has_list WHERE user_id = '.intval($userId);
|
||||
if (!empty($listids)) {
|
||||
acym_arrayToInteger($listids);
|
||||
$query .= ' AND list_id IN ('.implode(',', $listids).')';
|
||||
}
|
||||
|
||||
return acym_loadObjectList($query, 'list_id');
|
||||
}
|
||||
|
||||
public function identify($onlyValue = false)
|
||||
{
|
||||
$id = acym_getVar('int', "id", 0);
|
||||
$key = acym_getVar('string', "key", '');
|
||||
|
||||
if (empty($id) || empty($key)) {
|
||||
$currentUserid = acym_currentUserId();
|
||||
if (!empty($currentUserid)) {
|
||||
return $this->getOneByCMSId($currentUserid);
|
||||
}
|
||||
if (!$onlyValue) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_LOGIN'), 'error', 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$userIdentified = acym_loadObject('SELECT * FROM #__acym_user WHERE `id` = '.intval($id).' AND `key` = '.acym_escapeDB($key));
|
||||
|
||||
if (!empty($userIdentified)) {
|
||||
return $userIdentified;
|
||||
}
|
||||
|
||||
if (!$onlyValue) {
|
||||
acym_enqueueNotification(acym_translation('INVALID_KEY'), 'error', 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function subscribe($userIds, $addLists)
|
||||
{
|
||||
if (empty($addLists)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array($userIds)) {
|
||||
$userIds = [$userIds];
|
||||
}
|
||||
|
||||
if (!is_array($addLists)) {
|
||||
$addLists = [$addLists];
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
$listClass = acym_get('class.list');
|
||||
$subscribedToLists = false;
|
||||
foreach ($userIds as $userId) {
|
||||
$user = $this->getOneById($userId);
|
||||
if (empty($user)) {
|
||||
continue;
|
||||
}
|
||||
$currentSubscription = $this->getUserSubscriptionById($userId);
|
||||
|
||||
$currentlySubscribed = [];
|
||||
$currentlyUnsubscribed = [];
|
||||
foreach ($currentSubscription as $oneList) {
|
||||
if ($oneList->status == 1) {
|
||||
$currentlySubscribed[$oneList->id] = $oneList;
|
||||
}
|
||||
if ($oneList->status == 0) {
|
||||
$currentlyUnsubscribed[$oneList->id] = $oneList;
|
||||
}
|
||||
}
|
||||
|
||||
$subscribedLists = [];
|
||||
foreach ($addLists as $oneListId) {
|
||||
if (empty($oneListId) || !empty($currentlySubscribed[$oneListId])) continue;
|
||||
|
||||
$subscription = new stdClass();
|
||||
$subscription->user_id = $userId;
|
||||
$subscription->list_id = $oneListId;
|
||||
$subscription->status = 1;
|
||||
$subscription->subscription_date = date("Y-m-d H:i:s", time());
|
||||
|
||||
if (empty($currentSubscription[$oneListId])) {
|
||||
acym_insertObject('#__acym_user_has_list', $subscription);
|
||||
} elseif (!empty($currentlyUnsubscribed[$oneListId])) {
|
||||
acym_updateObject('#__acym_user_has_list', $subscription, ['user_id', 'list_id']);
|
||||
}
|
||||
|
||||
$subscribedLists[] = $oneListId;
|
||||
$subscribedToLists = true;
|
||||
}
|
||||
|
||||
$historyClass = acym_get('class.history');
|
||||
$historyData = acym_translation_sprintf('ACYM_LISTS_NUMBERS', implode(', ', $addLists));
|
||||
$historyClass->insert($userId, 'subscribed', [$historyData]);
|
||||
|
||||
acym_trigger('onAcymAfterUserSubscribe', [&$user, &$subscribedLists]);
|
||||
|
||||
if ($config->get('require_confirmation', 1) == 0 || $user->confirmed == 1) {
|
||||
$listClass->sendWelcome($userId, $subscribedLists);
|
||||
}
|
||||
}
|
||||
|
||||
return $subscribedToLists;
|
||||
}
|
||||
|
||||
public function unsubscribe($userIds, $lists)
|
||||
{
|
||||
if (empty($lists)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array($userIds)) {
|
||||
$userIds = [$userIds];
|
||||
}
|
||||
|
||||
if (!is_array($lists)) {
|
||||
$lists = [$lists];
|
||||
}
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$unsubscribedFromLists = false;
|
||||
foreach ($userIds as $userId) {
|
||||
$currentSubscription = $this->getUserSubscriptionById($userId);
|
||||
|
||||
$currentlyUnsubscribed = [];
|
||||
foreach ($currentSubscription as $oneList) {
|
||||
if ($oneList->status == 0) {
|
||||
$currentlyUnsubscribed[$oneList->id] = $oneList;
|
||||
}
|
||||
}
|
||||
|
||||
$unsubscribedLists = [];
|
||||
foreach ($lists as $oneListId) {
|
||||
if (empty($oneListId) || !empty($currentlyUnsubscribed[$oneListId])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$subscription = new stdClass();
|
||||
$subscription->user_id = $userId;
|
||||
$subscription->list_id = $oneListId;
|
||||
$subscription->status = 0;
|
||||
$subscription->unsubscribe_date = date("Y-m-d H:i:s", time());
|
||||
|
||||
if (empty($currentSubscription[$oneListId])) {
|
||||
acym_insertObject('#__acym_user_has_list', $subscription);
|
||||
} else {
|
||||
acym_updateObject('#__acym_user_has_list', $subscription, ['user_id', 'list_id']);
|
||||
}
|
||||
|
||||
$unsubscribedLists[] = $oneListId;
|
||||
$unsubscribedFromLists = true;
|
||||
}
|
||||
|
||||
$historyClass = acym_get('class.history');
|
||||
$historyData = acym_translation_sprintf('ACYM_LISTS_NUMBERS', implode(', ', $lists));
|
||||
$historyClass->insert($userId, 'unsubscribed', [$historyData]);
|
||||
|
||||
acym_trigger('onAcymAfterUserUnsubscribe', [&$userId, &$unsubscribedLists]);
|
||||
|
||||
$listClass->sendUnsubscribe($userId, $unsubscribedLists);
|
||||
}
|
||||
|
||||
return $unsubscribedFromLists;
|
||||
}
|
||||
|
||||
public function removeSubscription($userId, $listIds = null)
|
||||
{
|
||||
if (!is_array($userId)) $userId = [$userId];
|
||||
if (!is_array($listIds) || empty($listIds) || empty($userId)) return false;
|
||||
|
||||
acym_arrayToInteger($listIds);
|
||||
$query = 'DELETE FROM #__acym_user_has_list WHERE user_id IN ('.implode(',', $userId).')';
|
||||
if (!empty($listIds)) $query .= ' AND list_id IN ('.implode(',', $listIds).')';
|
||||
|
||||
return acym_query($query);
|
||||
}
|
||||
|
||||
public function delete($elements)
|
||||
{
|
||||
if (!is_array($elements)) $elements = [$elements];
|
||||
acym_arrayToInteger($elements);
|
||||
|
||||
if (empty($elements)) return 0;
|
||||
|
||||
acym_trigger('onAcymBeforeUserDelete', [&$elements]);
|
||||
|
||||
acym_query('DELETE FROM #__acym_user_has_list WHERE user_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_queue WHERE user_id IN ('.implode(',', $elements).')');
|
||||
acym_query('DELETE FROM #__acym_user_has_field WHERE user_id IN ('.implode(',', $elements).')');
|
||||
|
||||
return parent::delete($elements);
|
||||
}
|
||||
|
||||
public function save($user, $customFields = null)
|
||||
{
|
||||
if (empty($user->email) && empty($user->id)) return false;
|
||||
|
||||
if (empty($user->id) && !isset($user->active)) $user->active = 1;
|
||||
|
||||
if (isset($user->email)) {
|
||||
$user->email = strtolower($user->email);
|
||||
if (!acym_isValidEmail($user->email)) {
|
||||
$this->errors[] = acym_translation('ACYM_VALID_EMAIL');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
if (empty($user->id)) {
|
||||
$currentUserid = acym_currentUserId();
|
||||
$currentEmail = acym_currentUserEmail();
|
||||
if ($this->checkVisitor && !acym_isAdmin() && intval($config->get('allow_visitor', 1)) != 1 && (empty($currentUserid) || strtolower($currentEmail) != $user->email)) {
|
||||
$this->errors[] = acym_translation('ACYM_ONLY_LOGGED');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($user->id)) {
|
||||
if (empty($user->name) && $config->get('generate_name', 1)) {
|
||||
$user->name = ucwords(trim(str_replace(['.', '_', ')', ',', '(', '-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], ' ', substr($user->email, 0, strpos($user->email, '@')))));
|
||||
}
|
||||
|
||||
if (empty($user->key)) $user->key = acym_generateKey(14);
|
||||
|
||||
$user->creation_date = date('Y-m-d H:i:s', time());
|
||||
} elseif (!empty($user->confirmed)) {
|
||||
$oldUser = $this->getOneById($user->id);
|
||||
if (!empty($oldUser) && empty($oldUser->confirmed)) {
|
||||
$user->confirmation_date = date('Y-m-d H:i:s', time());
|
||||
$user->confirmation_ip = acym_getIP();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($user as $oneAttribute => $value) {
|
||||
if (empty($value)) continue;
|
||||
|
||||
$oneAttribute = trim(strtolower($oneAttribute));
|
||||
if (!in_array($oneAttribute, $this->restrictedFields)) {
|
||||
$user->$oneAttribute = strip_tags($value);
|
||||
}
|
||||
|
||||
if (is_numeric($user->$oneAttribute)) continue;
|
||||
|
||||
if (function_exists('mb_detect_encoding')) {
|
||||
if (mb_detect_encoding($user->$oneAttribute, 'UTF-8', true) != 'UTF-8') {
|
||||
$user->$oneAttribute = utf8_encode($user->$oneAttribute);
|
||||
}
|
||||
} elseif (!preg_match('%^(?:[\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$%xs', $user->$oneAttribute)) {
|
||||
$user->$oneAttribute = utf8_encode($user->$oneAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($user->id)) {
|
||||
if (empty($user->cms_id) && !empty($user->email)) {
|
||||
$userCmsID = acym_loadResult('SELECT '.acym_secureDBColumn($this->cmsUserVars->id).' FROM '.$this->cmsUserVars->table.' WHERE '.acym_secureDBColumn($this->cmsUserVars->email).' = '.acym_escapeDB($user->email));
|
||||
if (!empty($userCmsID)) $user->cms_id = $userCmsID;
|
||||
}
|
||||
acym_trigger('onAcymBeforeUserCreate', [&$user]);
|
||||
} else {
|
||||
acym_trigger('onAcymBeforeUserModify', [&$user]);
|
||||
}
|
||||
|
||||
$userID = parent::save($user);
|
||||
|
||||
if (!empty($customFields)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$fieldClass->store($customFields, $userID);
|
||||
}
|
||||
|
||||
$historyClass = acym_get('class.history');
|
||||
if (empty($user->id)) {
|
||||
$user->id = $userID;
|
||||
$historyClass->insert($user->id, 'created');
|
||||
acym_trigger('onAcymAfterUserCreate', [&$user]);
|
||||
} else {
|
||||
$historyClass->insert($user->id, 'modified');
|
||||
acym_trigger('onAcymAfterUserModify', [&$user]);
|
||||
}
|
||||
|
||||
$this->sendConfirmation($userID);
|
||||
|
||||
return $userID;
|
||||
}
|
||||
|
||||
public function saveForm()
|
||||
{
|
||||
$config = acym_config();
|
||||
$allowUserModifications = (bool)($config->get('allow_modif', 'data') == 'all') || $this->allowModif;
|
||||
$allowSubscriptionModifications = (bool)($config->get('allow_modif', 'data') != 'none') || $this->allowModif;
|
||||
|
||||
$user = new stdClass();
|
||||
$user->id = acym_getCID('id');
|
||||
|
||||
if (!$this->allowModif && !empty($user->id)) {
|
||||
$currentUser = $this->identify();
|
||||
if ($currentUser->id != $user->id) {
|
||||
$this->errors[] = acym_translation('ACYM_NOT_ALLOWED_MODIFY_USER');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$allowUserModifications = true;
|
||||
$allowSubscriptionModifications = true;
|
||||
}
|
||||
|
||||
$userData = acym_getVar('array', 'user', []);
|
||||
if (!empty($userData)) {
|
||||
foreach ($userData as $attribute => $value) {
|
||||
$user->$attribute = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($user->id) && empty($user->email)) {
|
||||
$this->errors[] = acym_translation('ACYM_VALID_EMAIL');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($user->email)) {
|
||||
if (empty($user->id)) {
|
||||
$user->id = 0;
|
||||
}
|
||||
$existUser = acym_loadObject('SELECT * FROM #__acym_user WHERE email = '.acym_escapeDB($user->email).' AND id != '.intval($user->id));
|
||||
if (!empty($existUser->id) && !$this->allowModif) {
|
||||
$this->errors[] = acym_translation('ACYM_ADDRESS_TAKEN');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($user->id) && !empty($user->email)) {
|
||||
$existUser = $this->getOneById($user->id);
|
||||
if (trim(strtolower($user->email)) != strtolower($existUser->email)) {
|
||||
$user->confirmed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$this->newUser = empty($user->id);
|
||||
if (empty($user->id) || $allowUserModifications) {
|
||||
if (isset($user->confirmed) && $user->confirmed != 1) {
|
||||
$user->confirmed = 0;
|
||||
}
|
||||
if (isset($user->active) && $user->active != 1) {
|
||||
$user->active = 0;
|
||||
}
|
||||
$customFieldData = acym_getVar('array', 'customField', []);
|
||||
$id = $this->save($user, $customFieldData);
|
||||
$allowSubscriptionModifications = true;
|
||||
} else {
|
||||
$id = $user->id;
|
||||
if (isset($user->confirmed) && empty($user->confirmed)) {
|
||||
$this->sendConfirmation($id);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
return false;
|
||||
}
|
||||
$formData = acym_getVar('array', 'data', []);
|
||||
|
||||
acym_setVar('id', $id);
|
||||
|
||||
if (!acym_isAdmin()) {
|
||||
$hiddenlistsString = acym_getVar('string', 'hiddenlists', '');
|
||||
if (!empty($hiddenlistsString)) {
|
||||
$hiddenlists = explode(',', $hiddenlistsString);
|
||||
acym_arrayToInteger($hiddenlists);
|
||||
foreach ($hiddenlists as $oneListId) {
|
||||
$formData['listsub'][$oneListId] = ['status' => 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($formData['listsub'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$allowSubscriptionModifications) {
|
||||
$this->requireId = true;
|
||||
$this->errors[] = acym_translation('ACYM_NOT_ALLOWED_MODIFY_USER');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$addLists = [];
|
||||
$unsubLists = [];
|
||||
foreach ($formData['listsub'] as $listID => $oneList) {
|
||||
if ($oneList['status'] == 1) {
|
||||
$addLists[] = $listID;
|
||||
} else {
|
||||
$unsubLists[] = $listID;
|
||||
}
|
||||
}
|
||||
|
||||
$this->subscribe($id, $addLists);
|
||||
if (!$this->newUser) {
|
||||
$this->unsubscribe($id, $unsubLists);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendConfirmation($userID)
|
||||
{
|
||||
if (!$this->forceConf && !$this->sendConf) return true;
|
||||
|
||||
$config = acym_config();
|
||||
if ($config->get('require_confirmation', 1) != 1 || acym_isAdmin()) return false;
|
||||
|
||||
$myuser = $this->getOneById($userID);
|
||||
|
||||
if (!empty($myuser->confirmed)) return false;
|
||||
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
|
||||
$mailerHelper->checkConfirmField = false;
|
||||
$mailerHelper->checkEnabled = false;
|
||||
$mailerHelper->report = $config->get('confirm_message', 0);
|
||||
|
||||
$alias = "acy_confirm";
|
||||
|
||||
$this->confirmationSentSuccess = $mailerHelper->sendOne($alias, $myuser);
|
||||
$this->confirmationSentError = $mailerHelper->reportMessage;
|
||||
}
|
||||
|
||||
public function deactivate($userId)
|
||||
{
|
||||
acym_query('UPDATE `#__acym_user` SET `active` = 0 WHERE `id` = '.intval($userId));
|
||||
}
|
||||
|
||||
public function confirm($userId)
|
||||
{
|
||||
$confirmDate = date('Y-m-d H:i:s', time());
|
||||
$ip = acym_getIP();
|
||||
$query = 'UPDATE `#__acym_user`';
|
||||
$query .= ' SET `confirmed` = 1, `confirmation_date` = '.acym_escapeDB($confirmDate).', `confirmation_ip` = '.acym_escapeDB($ip);
|
||||
$query .= ' WHERE `id` = '.intval($userId).' LIMIT 1';
|
||||
$res = acym_query($query);
|
||||
if ($res === false) {
|
||||
$msg = 'Please contact the admin of this website with the error message:<br />'.substr(strip_tags(acym_getDBError()), 0, 200).'...';
|
||||
acym_display($msg, 'error');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$historyClass = acym_get('class.history');
|
||||
$historyClass->insert($userId, 'confirmed');
|
||||
|
||||
$listIDs = acym_loadResultArray('SELECT `list_id` FROM `#__acym_user_has_list` WHERE `status` = 1 AND `user_id` = '.intval($userId));
|
||||
|
||||
if (empty($listIDs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$listClass->sendWelcome($userId, $listIDs);
|
||||
}
|
||||
|
||||
public function getOneByIdWithCustomFields($id)
|
||||
{
|
||||
$user = $this->getOneById($id);
|
||||
$user = get_object_vars($user);
|
||||
|
||||
$fieldsValue = acym_loadObjectList(
|
||||
'SELECT user_field.value as value, field.name as name
|
||||
FROM #__acym_user_has_field as user_field
|
||||
LEFT JOIN #__acym_field as field ON user_field.field_id = field.id
|
||||
WHERE user_field.user_id = '.intval($id),
|
||||
'name'
|
||||
);
|
||||
|
||||
foreach ($fieldsValue as $key => $value) {
|
||||
$fieldsValue[$key] = $value->value;
|
||||
}
|
||||
|
||||
return array_merge($user, $fieldsValue);
|
||||
}
|
||||
|
||||
public function getAllColumnsUserAndCustomField($inAction = false)
|
||||
{
|
||||
$return = [];
|
||||
|
||||
$userFields = acym_getColumns('user');
|
||||
foreach ($userFields as $value) {
|
||||
$return[$value] = $value;
|
||||
}
|
||||
|
||||
$customFields = acym_loadObjectList('SELECT * FROM #__acym_field WHERE id NOT IN (1, 2) '.($inAction ? 'AND type != "phone"' : ''), 'id');
|
||||
if (!empty($customFields)) {
|
||||
foreach ($customFields as $key => $value) {
|
||||
$return[$key] = $value->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function getAllUserFields($user)
|
||||
{
|
||||
if (empty($user->id)) return $user;
|
||||
$query = 'SELECT field.*, userfield.*
|
||||
FROM #__acym_field AS field
|
||||
LEFT JOIN #__acym_user_has_field AS userfield ON field.id = userfield.field_id AND userfield.user_id = '.intval($user->id).'
|
||||
WHERE field.id NOT IN(1, 2)';
|
||||
|
||||
$allFields = acym_loadObjectList($query);
|
||||
|
||||
foreach ($allFields as $oneField) {
|
||||
$user->{$oneField->namekey} = empty($oneField->value) ? '' : $oneField->value;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function synchSaveCmsUser($user, $isnew, $oldUser = null)
|
||||
{
|
||||
$source = acym_getVar('cmd', 'acy_source', '');
|
||||
if (empty($source)) acym_setVar('acy_source', ACYM_CMS);
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
if (!$config->get('regacy', 0)) return;
|
||||
|
||||
$this->checkVisitor = false;
|
||||
$this->sendConf = false;
|
||||
|
||||
$cmsUser = new stdClass();
|
||||
$cmsUser->email = trim(strip_tags($user['email']));
|
||||
if (!acym_isValidEmail($cmsUser->email)) return;
|
||||
if (!empty($user['name'])) $cmsUser->name = trim(strip_tags($user['name']));
|
||||
if (!$config->get('regacy_forceconf', 0)) $cmsUser->confirmed = 1;
|
||||
$cmsUser->active = 1 - intval($user['block']);
|
||||
$cmsUser->cms_id = $user['id'];
|
||||
|
||||
if (!$isnew && !empty($oldUser['email']) && $user['email'] != $oldUser['email']) {
|
||||
$acyUser = $this->getOneByEmail($oldUser['email']);
|
||||
if (!empty($acyUser)) $cmsUser->id = $acyUser->id;
|
||||
}
|
||||
|
||||
if (empty($cmsUser->id) && !empty($cmsUser->cms_id)) {
|
||||
$acyUser = $this->getOneByCMSId($cmsUser->cms_id);
|
||||
if (!empty($acyUser)) $cmsUser->id = $acyUser->id;
|
||||
}
|
||||
|
||||
$acyUser = $this->getOneByEmail($cmsUser->email);
|
||||
if (!empty($acyUser)) {
|
||||
if (empty($cmsUser->id)) {
|
||||
$cmsUser->id = $acyUser->id;
|
||||
} elseif ($cmsUser->id != $acyUser->id) {
|
||||
$this->delete($acyUser->id);
|
||||
}
|
||||
}
|
||||
|
||||
$isnew = (bool)($isnew || empty($cmsUser->id));
|
||||
|
||||
$id = $this->save($cmsUser);
|
||||
|
||||
|
||||
|
||||
$currentSubscription = $this->getSubscriptionStatus($id);
|
||||
|
||||
$autoLists = $isnew ? $config->get('regacy_autolists') : '';
|
||||
$autoLists = explode(',', $autoLists);
|
||||
acym_arrayToInteger($autoLists);
|
||||
|
||||
$listsClass = acym_get('class.list');
|
||||
$allLists = $listsClass->getAll();
|
||||
|
||||
$visibleLists = acym_getVar('string', 'regacy_visible_lists');
|
||||
$visibleLists = explode(',', $visibleLists);
|
||||
acym_arrayToInteger($visibleLists);
|
||||
|
||||
$visibleListsChecked = acym_getVar('array', 'regacy_visible_lists_checked', []);
|
||||
acym_arrayToInteger($visibleListsChecked);
|
||||
|
||||
|
||||
if (!$isnew && !empty($visibleLists)) {
|
||||
$currentlySubscribedLists = [];
|
||||
foreach ($currentSubscription as $oneSubscription) {
|
||||
if ($oneSubscription->status == 1) $currentlySubscribedLists[] = $oneSubscription->list_id;
|
||||
}
|
||||
$unsubscribeLists = array_intersect($currentlySubscribedLists, array_diff($visibleLists, $visibleListsChecked));
|
||||
$this->unsubscribe($id, $unsubscribeLists);
|
||||
}
|
||||
|
||||
$listsToSubscribe = [];
|
||||
foreach ($allLists as $oneList) {
|
||||
if (!$oneList->active) continue;
|
||||
if (!empty($currentSubscription[$oneList->id]) && $currentSubscription[$oneList->id]->status == 1) continue;
|
||||
|
||||
if (in_array($oneList->id, $visibleListsChecked) || (in_array($oneList->id, $autoLists) && !in_array($oneList->id, $visibleLists) && empty($currentSubscription[$oneList->id]))) {
|
||||
$listsToSubscribe[] = $oneList->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($listsToSubscribe)) $this->subscribe($id, $listsToSubscribe);
|
||||
|
||||
$acymailingUser = $this->getOneById($id);
|
||||
if (!$config->get('regacy_forceconf', 0) || !empty($user['block']) || !empty($acymailingUser->confirmed)) return;
|
||||
|
||||
|
||||
if ($isnew || !empty($oldUser['block'])) {
|
||||
$this->forceConf = true;
|
||||
$this->sendConfirmation($id);
|
||||
}
|
||||
}
|
||||
|
||||
public function synchDeleteCmsUser($userEmail)
|
||||
{
|
||||
$acyUser = $this->getOneByEmail($userEmail);
|
||||
|
||||
if (empty($acyUser)) return;
|
||||
|
||||
$config = acym_config();
|
||||
if ($config->get('regacy', '0') == 1 && $config->get('regacy_delete', '0') == 1) {
|
||||
$this->delete($acyUser->id);
|
||||
} else {
|
||||
acym_query('UPDATE #__acym_user SET `cms_id` = 0 WHERE `id` = '.intval($acyUser->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymuserStatClass extends acymClass
|
||||
{
|
||||
var $table = 'user_stat';
|
||||
|
||||
public function save($userStat)
|
||||
{
|
||||
$column = [];
|
||||
$valueColumn = [];
|
||||
$columnName = acym_getColumns("user_stat");
|
||||
if (![$userStat]) {
|
||||
$userStat = (array)$userStat;
|
||||
}
|
||||
|
||||
foreach ($userStat as $key => $value) {
|
||||
if (in_array($key, $columnName)) {
|
||||
$column[] = '`'.acym_secureDBColumn($key).'`';
|
||||
$valueColumn[] = acym_escapeDB($value);
|
||||
}
|
||||
}
|
||||
|
||||
$query = "INSERT INTO #__acym_user_stat (".implode(',', $column).") VALUE (".implode(',', $valueColumn).")";
|
||||
$onDuplicate = [];
|
||||
|
||||
if (!empty($userStat['statusSending'])) {
|
||||
$onDuplicate[] = $userStat['statusSending'] == 0 ? "fail = fail + 1" : "sent = sent + 1";
|
||||
}
|
||||
|
||||
if (!empty($userStat['open'])) {
|
||||
$onDuplicate[] = "open = open + 1";
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('user_open', ['userId' => $userStat['user_id']]);
|
||||
}
|
||||
|
||||
if (!empty($userStat['open_date'])) {
|
||||
$onDuplicate[] = 'open_date = '.acym_escapeDB($userStat['open_date']);
|
||||
}
|
||||
|
||||
if (!empty($onDuplicate)) {
|
||||
$query .= " ON DUPLICATE KEY UPDATE ";
|
||||
$query .= implode(',', $onDuplicate);
|
||||
}
|
||||
|
||||
acym_query($query);
|
||||
}
|
||||
|
||||
public function getOneByMailAndUserId($mail_id, $user_id)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user_stat WHERE `mail_id` = '.intval($mail_id).' AND `user_id` = '.intval($user_id);
|
||||
|
||||
return acym_loadObject($query);
|
||||
}
|
||||
|
||||
public function getAllUserStatByUserId($idUser)
|
||||
{
|
||||
$query = 'SELECT * FROM #__acym_user_stat WHERE user_id = '.intval($idUser);
|
||||
|
||||
return acym_loadObjectList($query);
|
||||
}
|
||||
|
||||
|
||||
public function getDetailedStats($settings)
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$query = 'SELECT us.*, m.name, m.subject, u.email, c.id as campaign_id
|
||||
FROM #__acym_user_stat AS us
|
||||
LEFT JOIN #__acym_user AS u ON us.user_id = u.id
|
||||
INNER JOIN #__acym_mail AS m ON us.mail_id = m.id
|
||||
LEFT JOIN #__acym_campaign AS c ON m.id = c.mail_id';
|
||||
$queryCount = 'SELECT COUNT(*) FROM #__acym_user_stat as us
|
||||
LEFT JOIN #__acym_user AS u ON us.user_id = u.id
|
||||
INNER JOIN #__acym_mail AS m ON us.mail_id = m.id';
|
||||
$where = [];
|
||||
|
||||
if (!empty($settings['mail_id'])) {
|
||||
$where[] = 'us.mail_id = '.intval($settings['mail_id']);
|
||||
}
|
||||
|
||||
if (!empty($settings['search'])) {
|
||||
$where[] = 'm.name LIKE '.acym_escapeDB('%'.$settings['search'].'%').' OR u.email LIKE '.acym_escapeDB('%'.$settings['search'].'%');
|
||||
}
|
||||
|
||||
if (!empty($where)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $where).')';
|
||||
$queryCount .= ' WHERE ('.implode(') AND (', $where).')';
|
||||
}
|
||||
|
||||
if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
|
||||
if ($settings['ordering'] == 'email') {
|
||||
$table = 'u';
|
||||
} elseif ($settings['ordering'] == 'subject') {
|
||||
$table = 'm';
|
||||
} else {
|
||||
$table = 'us';
|
||||
}
|
||||
$query .= ' ORDER BY '.$table.'.'.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
|
||||
}
|
||||
|
||||
$results['detailed_stats'] = $mailClass->decode(acym_loadObjectList($query, '', $settings['offset'], $settings['detailedStatsPerPage']));
|
||||
$results['total'] = acym_loadResult($queryCount);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getTotalFailClickOpenByMailIds($mailIds)
|
||||
{
|
||||
acym_arrayToInteger($mailIds);
|
||||
if (empty($mailIds)) return [];
|
||||
|
||||
$query = "SELECT mail_id, SUM(fail) AS fail, SUM(sent) AS sent, SUM(open) AS open FROM #__acym_user_stat WHERE mail_id IN (".implode(',', $mailIds).") GROUP BY mail_id";
|
||||
|
||||
return acym_loadObjectList($query, 'mail_id');
|
||||
}
|
||||
|
||||
public function getUserWithNoMailOpen()
|
||||
{
|
||||
$query = 'SELECT user_id FROM #__acym_user_stat GROUP BY user_id HAVING MAX(open) = 0';
|
||||
|
||||
return acym_loadResultArray($query);
|
||||
}
|
||||
}
|
||||
|
||||
10
deployed/acym/administrator/components/com_acym/config.xml
Normal file
10
deployed/acym/administrator/components/com_acym/config.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<config>
|
||||
<fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC">
|
||||
<field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" filter="rules" component="com_acym" section="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC"/>
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC"/>
|
||||
</field>
|
||||
</fieldset>
|
||||
</config>
|
||||
|
||||
@ -0,0 +1,640 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 AutomationController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_AUTOMATION')] = acym_completeLink('automation');
|
||||
$this->loadScripts = [
|
||||
'all' => ['datepicker'],
|
||||
];
|
||||
acym_setVar('edition', '1');
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function condition()
|
||||
{
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function filter()
|
||||
{
|
||||
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
public function switches($matches)
|
||||
{
|
||||
return $matches[1].'__numand__'.$matches[2].'__numand__'.$matches[3].'__numand__'.$matches[4];
|
||||
}
|
||||
|
||||
public function action()
|
||||
{
|
||||
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
public function summary()
|
||||
{
|
||||
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
private function _saveInfos($isMassAction = false)
|
||||
{
|
||||
if ($isMassAction) {
|
||||
acym_session();
|
||||
}
|
||||
|
||||
$automationId = acym_getVar('int', 'id');
|
||||
$automation = acym_getVar('array', 'automation');
|
||||
$automationClass = acym_get('class.automation');
|
||||
|
||||
$stepAutomationId = acym_getVar('int', 'stepAutomationId');
|
||||
$stepAutomation = acym_getVar('array', 'stepAutomation');
|
||||
$stepClass = acym_get('class.step');
|
||||
|
||||
if (!empty($automationId)) {
|
||||
$automation['id'] = $automationId;
|
||||
}
|
||||
|
||||
if (!empty($stepAutomationId)) {
|
||||
$stepAutomation['id'] = $stepAutomationId;
|
||||
}
|
||||
|
||||
$typeTrigger = acym_getVar('string', 'type_trigger');
|
||||
|
||||
if (empty($automation['admin']) && empty($automation['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($stepAutomation['triggers'][$typeTrigger])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_SELECT_ONE_TRIGGER'), 'error', 5000);
|
||||
|
||||
$this->info();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$stepAutomation['triggers'][$typeTrigger]['type_trigger'] = $typeTrigger;
|
||||
$stepAutomation['triggers'] = json_encode($stepAutomation['triggers'][$typeTrigger]);
|
||||
|
||||
$stepAutomation['automation_id'] = $automationId;
|
||||
|
||||
foreach ($automation as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
foreach ($stepAutomation as $stepColumn => $stepValue) {
|
||||
acym_secureDBColumn($stepColumn);
|
||||
}
|
||||
|
||||
$automation = (object)$automation;
|
||||
$stepAutomation = (object)$stepAutomation;
|
||||
|
||||
$automation->id = $automationClass->save($automation);
|
||||
$stepAutomation->automation_id = $automation->id;
|
||||
$stepAutomation->id = $stepClass->save($stepAutomation);
|
||||
|
||||
$returnIds = [
|
||||
"automationId" => $automation->id,
|
||||
"stepId" => $stepAutomation->id,
|
||||
"typeTrigger" => $typeTrigger,
|
||||
];
|
||||
|
||||
if ($isMassAction) {
|
||||
return true;
|
||||
} elseif (!empty($returnIds['automationId']) && !empty($returnIds['stepId'])) {
|
||||
return $returnIds;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function _saveConditions($isMassAction = false)
|
||||
{
|
||||
$automationID = acym_getVar('int', 'id');
|
||||
$conditionId = acym_getVar('int', 'conditionId');
|
||||
$condition = acym_getVar('array', 'acym_condition', []);
|
||||
$conditionClass = acym_get('class.condition');
|
||||
|
||||
$stepAutomationId = acym_getVar('int', 'stepAutomationId');
|
||||
|
||||
if (!empty($stepAutomationId)) {
|
||||
$stepAutomation['id'] = $stepAutomationId;
|
||||
}
|
||||
|
||||
if (!empty($conditionId)) {
|
||||
$condition['id'] = $conditionId;
|
||||
}
|
||||
|
||||
$condition['conditions']['type_condition'] = acym_getVar('string', 'type_condition');
|
||||
|
||||
if ($isMassAction) {
|
||||
acym_session();
|
||||
$_SESSION['massAction']['conditions'] = $condition['conditions'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$condition['conditions'] = json_encode($condition['conditions']);
|
||||
|
||||
$condition['step_id'] = $stepAutomationId;
|
||||
|
||||
foreach ($condition as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
$condition = (object)$condition;
|
||||
|
||||
$condition->id = $conditionClass->save($condition);
|
||||
|
||||
$returnIds = [
|
||||
'automationId' => $automationID,
|
||||
'stepId' => $stepAutomationId,
|
||||
'conditionId' => $condition->id,
|
||||
];
|
||||
|
||||
return $returnIds;
|
||||
}
|
||||
|
||||
private function _saveFilters($isMassAction = false)
|
||||
{
|
||||
$automationID = acym_getVar('int', 'id');
|
||||
$actionId = acym_getVar('int', 'actionId');
|
||||
$action = acym_getVar('array', 'acym_action', []);
|
||||
$actionClass = acym_get('class.action');
|
||||
$conditionId = acym_getVar('int', 'conditionId');
|
||||
|
||||
$stepAutomationId = acym_getVar('int', 'stepAutomationId');
|
||||
|
||||
if (!empty($stepAutomationId)) {
|
||||
$stepAutomation['id'] = $stepAutomationId;
|
||||
}
|
||||
|
||||
if (!empty($conditionId)) {
|
||||
$action['condition_id'] = $conditionId;
|
||||
}
|
||||
|
||||
if (!empty($actionId)) {
|
||||
$action['id'] = $actionId;
|
||||
}
|
||||
|
||||
$action['filters']['type_filter'] = acym_getVar('string', 'type_filter');
|
||||
|
||||
if ($isMassAction) {
|
||||
acym_session();
|
||||
$_SESSION['massAction']['filters'] = $action['filters'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$action['filters'] = json_encode($action['filters']);
|
||||
|
||||
$action['order'] = 1;
|
||||
|
||||
foreach ($action as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
$action = (object)$action;
|
||||
|
||||
$action->id = $actionClass->save($action);
|
||||
|
||||
$returnIds = [
|
||||
'automationId' => $automationID,
|
||||
'stepId' => $stepAutomationId,
|
||||
'actionId' => $action->id,
|
||||
];
|
||||
|
||||
return $returnIds;
|
||||
}
|
||||
|
||||
private function _saveActions($isMassAction = false)
|
||||
{
|
||||
if ($isMassAction) {
|
||||
acym_session();
|
||||
}
|
||||
|
||||
$automationID = acym_getVar('int', 'id');
|
||||
$stepID = acym_getVar('int', 'id');
|
||||
$actionId = acym_getVar('int', 'actionId');
|
||||
$action = acym_getVar('array', 'acym_action');
|
||||
$actionClass = acym_get('class.action');
|
||||
$stepAutomationId = acym_getVar('int', 'stepAutomationId');
|
||||
$conditionId = acym_getVar('int', 'conditionId');
|
||||
|
||||
if (!empty($stepAutomationId)) {
|
||||
$stepAutomation['id'] = $stepAutomationId;
|
||||
}
|
||||
|
||||
if ((!empty($conditionId))) {
|
||||
$action['condition_id'] = $conditionId;
|
||||
}
|
||||
|
||||
if (!empty($actionId)) {
|
||||
$action['id'] = $actionId;
|
||||
}
|
||||
|
||||
if (empty($action['actions'])) {
|
||||
$action['actions'] = [];
|
||||
}
|
||||
|
||||
if ($isMassAction) {
|
||||
$_SESSION['massAction']['actions'] = $action['actions'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$action['actions'] = json_encode($action['actions']);
|
||||
|
||||
foreach ($action as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
$action = (object)$action;
|
||||
|
||||
$action->id = $actionClass->save($action);
|
||||
|
||||
$returnIds = [
|
||||
'automationId' => $automationID,
|
||||
'stepId' => $stepAutomationId,
|
||||
'actionId' => $action->id,
|
||||
];
|
||||
|
||||
return $returnIds;
|
||||
}
|
||||
|
||||
private function _saveAutomation($from, $isMassAction = false)
|
||||
{
|
||||
if ($isMassAction) {
|
||||
acym_session();
|
||||
}
|
||||
|
||||
$automationId = acym_getVar('int', 'id');
|
||||
$automation = acym_getVar('array', 'automation');
|
||||
$automationClass = acym_get('class.automation');
|
||||
|
||||
$stepAutomationId = acym_getVar('int', 'stepAutomationId');
|
||||
$stepAutomation = acym_getVar('array', 'stepAutomation');
|
||||
$stepClass = acym_get('class.step');
|
||||
|
||||
if (!empty($automationId)) {
|
||||
$automation['id'] = $automationId;
|
||||
}
|
||||
|
||||
if (!empty($stepAutomationId)) {
|
||||
$stepAutomation['id'] = $stepAutomationId;
|
||||
}
|
||||
|
||||
if ($from == 'info') {
|
||||
$typeTrigger = acym_getVar('string', 'type_trigger');
|
||||
|
||||
if (empty($automation['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($stepAutomation['triggers'][$typeTrigger])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_SELECT_ONE_TRIGGER'), 'error', 5000);
|
||||
|
||||
$this->info();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$stepAutomation['triggers'][$typeTrigger]['type_trigger'] = $typeTrigger;
|
||||
$stepAutomation['triggers'] = json_encode($stepAutomation['triggers'][$typeTrigger]);
|
||||
|
||||
$stepAutomation['automation_id'] = $automationId;
|
||||
|
||||
foreach ($automation as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
foreach ($stepAutomation as $stepColumn => $stepValue) {
|
||||
acym_secureDBColumn($stepColumn);
|
||||
}
|
||||
|
||||
$automation = (object)$automation;
|
||||
$stepAutomation = (object)$stepAutomation;
|
||||
|
||||
$saveIdStepAutomation = $stepClass->save($stepAutomation);
|
||||
$saveIdAutomation = $automationClass->save($automation);
|
||||
|
||||
$returnIds = [
|
||||
"automationId" => $saveIdAutomation,
|
||||
"stepId" => $saveIdStepAutomation,
|
||||
];
|
||||
|
||||
if ($isMassAction) {
|
||||
return true;
|
||||
} elseif (!empty($returnIds['automationId']) && !empty($returnIds['stepId'])) {
|
||||
return $returnIds;
|
||||
} else return false;
|
||||
} elseif ($from == 'filters') {
|
||||
$stepAutomation['filters']['type_filter'] = acym_getVar('string', 'type_filter');
|
||||
if ($isMassAction) {
|
||||
$_SESSION['massAction']['filters'] = $stepAutomation['filters'];
|
||||
}
|
||||
$stepAutomation['filters'] = json_encode($stepAutomation['filters']);
|
||||
} elseif ($from == 'actions') {
|
||||
if (empty($stepAutomation['actions'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_SET_ACTIONS'), 'error', 5000);
|
||||
if (!empty($automationId)) acym_setVar('id', $automationId);
|
||||
$this->action();
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($isMassAction) {
|
||||
$_SESSION['massAction']['actions'] = $stepAutomation['actions'];
|
||||
}
|
||||
$stepAutomation['actions'] = json_encode($stepAutomation['actions']);
|
||||
} elseif ($from == 'summary') {
|
||||
$automation = $automationClass->getOneById($automationId);
|
||||
$automation->active = 1;
|
||||
}
|
||||
|
||||
if ($isMassAction) {
|
||||
return true;
|
||||
} else {
|
||||
switch ($from) {
|
||||
case 'info':
|
||||
case 'summary':
|
||||
foreach ($automation as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
$automation = (object)$automation;
|
||||
|
||||
return $automationClass->save($automation);
|
||||
case 'filters':
|
||||
case 'actions':
|
||||
$stepAutomation['automation_id'] = $automationId;
|
||||
$stepAutomation['order'] = 1;
|
||||
|
||||
foreach ($stepAutomation as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
}
|
||||
|
||||
$stepAutomation = (object)$stepAutomation;
|
||||
|
||||
return $stepClass->save($stepAutomation);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveExitInfo()
|
||||
{
|
||||
$ids = $this->_saveInfos();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
|
||||
acym_setVar('id', $ids['automationId']);
|
||||
acym_setVar('stepId', $ids['stepId']);
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function saveInfo()
|
||||
{
|
||||
$ids = $this->_saveInfos();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_setVar('id', $ids['automationId']);
|
||||
acym_setVar('stepId', $ids['stepId']);
|
||||
$this->condition();
|
||||
}
|
||||
|
||||
public function saveExitConditions()
|
||||
{
|
||||
$ids = $this->_saveConditions();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function saveConditions()
|
||||
{
|
||||
$ids = $this->_saveConditions();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_setVar('id', $ids['automationId']);
|
||||
acym_setVar('stepId', $ids['stepId']);
|
||||
acym_setVar('conditionId', $ids['conditionId']);
|
||||
$this->action();
|
||||
}
|
||||
|
||||
public function saveExitFilters()
|
||||
{
|
||||
$ids = $this->_saveFilters();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function saveFilters()
|
||||
{
|
||||
$ids = $this->_saveFilters();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_setVar('id', $ids['automationId']);
|
||||
acym_setVar('stepId', $ids['stepId']);
|
||||
acym_setVar('actionId', $ids['actionId']);
|
||||
$this->summary();
|
||||
}
|
||||
|
||||
public function saveExitActions()
|
||||
{
|
||||
$ids = $this->_saveActions();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function saveActions()
|
||||
{
|
||||
$ids = $this->_saveActions();
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
acym_setVar('id', $ids['automationId']);
|
||||
acym_setVar('stepId', $ids['stepId']);
|
||||
acym_setVar('actionId', $ids['actionId']);
|
||||
$this->filter();
|
||||
}
|
||||
|
||||
public function activeAutomation()
|
||||
{
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automation = $automationClass->getOneById(acym_getVar('int', 'id'));
|
||||
$automation->active = 1;
|
||||
$saved = $automationClass->save($automation);
|
||||
if (!empty($saved)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
$this->listing();
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 5000);
|
||||
$this->listing();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function setFilterMassAction()
|
||||
{
|
||||
$this->_saveFilters(true);
|
||||
$this->summary();
|
||||
}
|
||||
|
||||
public function setActionMassAction()
|
||||
{
|
||||
$res = $this->_saveActions(true);
|
||||
if (!$res) return false;
|
||||
$this->filter();
|
||||
}
|
||||
|
||||
function processMassAction()
|
||||
{
|
||||
acym_session();
|
||||
$automationClass = acym_get('class.automation');
|
||||
$massAction = empty($_SESSION['massAction']) ? '' : $_SESSION['massAction'];
|
||||
if (!empty($massAction)) {
|
||||
$automation = new stdClass();
|
||||
$automation->filters = json_encode($massAction['filters']);
|
||||
$automation->actions = json_encode($massAction['actions']);
|
||||
$automationClass->execute($automation);
|
||||
|
||||
if (!empty($automationClass->report)) {
|
||||
foreach ($automationClass->report as $oneReport) {
|
||||
acym_enqueueNotification($oneReport, 'info', 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function createMail()
|
||||
{
|
||||
$id = acym_getVar('int', 'id');
|
||||
$idAdmin = acym_getVar('boolean', 'automation_admin');
|
||||
$type = 'automation';
|
||||
if ($idAdmin) $type = 'automation_admin';
|
||||
$and = acym_getVar('string', 'and_action');
|
||||
$this->_saveActions(empty($id));
|
||||
$actions = acym_getVar('array', 'acym_action');
|
||||
$mailId = $actions['actions'][$and]['acy_add_queue']['mail_id'];
|
||||
acym_redirect(acym_completeLink('mails&task=edit&step=editEmail&type='.$type.'&from='.$mailId.'&return='.urlencode(acym_completeLink('automation&task=edit&step=action&id='.$id.'&fromMailEditor=1&mailid={mailid}&and='.$and)), false, true));
|
||||
}
|
||||
|
||||
|
||||
public function countresults()
|
||||
{
|
||||
$or = acym_getVar('int', 'or');
|
||||
$and = acym_getVar('int', 'and');
|
||||
$stepAutomation = acym_getVar('array', 'acym_action');
|
||||
|
||||
if (empty($stepAutomation['filters'][$or][$and])) die(acym_translation('ACYM_AUTOMATION_NOT_FOUND'));
|
||||
|
||||
$query = acym_get('class.query');
|
||||
$messages = '';
|
||||
|
||||
foreach ($stepAutomation['filters'][$or][$and] as $filterName => $options) {
|
||||
$messages = acym_trigger('onAcymProcessFilterCount_'.$filterName, [&$query, &$options, &$and]);
|
||||
break;
|
||||
}
|
||||
|
||||
echo implode(' | ', $messages);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function countResultsOrTotal()
|
||||
{
|
||||
$or = acym_getVar('int', 'or');
|
||||
$stepAutomation = acym_getVar('array', 'acym_action');
|
||||
|
||||
$query = acym_get('class.query');
|
||||
|
||||
if (!empty($stepAutomation) && !empty($stepAutomation['filters'][$or])) {
|
||||
|
||||
foreach ($stepAutomation['filters'][$or] as $and => $andValues) {
|
||||
$and = intval($and);
|
||||
foreach ($andValues as $filterName => $options) {
|
||||
acym_trigger('onAcymProcessFilter_'.$filterName, [&$query, &$options, &$and]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = $query->count();
|
||||
|
||||
echo acym_translation_sprintf('ACYM_SELECTED_USERS_TOTAL', $result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 BouncesController extends acymController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_BOUNCE_HANDLING')] = acym_completeLink('bounces');
|
||||
}
|
||||
|
||||
function listing()
|
||||
{
|
||||
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function edit()
|
||||
{
|
||||
$ruleClass = acym_get('class.rule');
|
||||
acym_setVar("layout", "edit");
|
||||
$ruleId = acym_getVar("int", "id", 0);
|
||||
$listsClass = acym_get('class.list');
|
||||
|
||||
$rule = "";
|
||||
|
||||
if (!empty($ruleId)) {
|
||||
$rule = $ruleClass->getOneById($ruleId);
|
||||
$this->breadcrumb[acym_translation($rule->name)] = acym_completeLink('bounces&task=edit&id='.$ruleId);
|
||||
} else {
|
||||
$this->breadcrumb[acym_translation('ACYM_NEW')] = acym_completeLink('bounces&task=edit');
|
||||
}
|
||||
|
||||
$data = [
|
||||
"id" => $ruleId,
|
||||
"lists" => $listsClass->getAllWithIdName(),
|
||||
"rule" => $rule,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function apply()
|
||||
{
|
||||
$this->saveRule();
|
||||
acym_setVar("id", acym_getVar('array', 'bounce')['id']);
|
||||
$this->edit();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->saveRule();
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function saveRule()
|
||||
{
|
||||
$rule = acym_getVar('array', 'bounce');
|
||||
|
||||
$ruleClass = acym_get('class.rule');
|
||||
$bounceClass = acym_get('class.bounce');
|
||||
|
||||
$rule['executed_on'] = !empty($rule['executed_on']) ? json_encode($rule['executed_on']) : '[]';
|
||||
|
||||
if (!empty($rule['action_user'])) {
|
||||
if (in_array('subscribe_user', $rule['action_user'])) {
|
||||
$rule['action_user']['subscribe_user_list'] = $rule['subscribe_user_list'];
|
||||
}
|
||||
}
|
||||
unset($rule['subscribe_user_list']);
|
||||
|
||||
if (!empty($rule['action_message']) && !in_array('forward_message', $rule['action_message'])) {
|
||||
unset($rule['action_message']['forward_to']);
|
||||
}
|
||||
|
||||
if (empty($rule['id'])) {
|
||||
$rule['ordering'] = $bounceClass->getOrderingNumber() + 1;
|
||||
}
|
||||
|
||||
$ruleObject = new stdClass();
|
||||
$ruleObject->executed_on = '[]';
|
||||
$ruleObject->action_message = '[]';
|
||||
$ruleObject->action_user = '[]';
|
||||
|
||||
foreach ($rule as $column => $value) {
|
||||
acym_secureDBColumn($column);
|
||||
if (is_array($value) || is_object($value)) {
|
||||
$ruleObject->$column = json_encode($value);
|
||||
} else {
|
||||
$ruleObject->$column = strip_tags($value);
|
||||
}
|
||||
}
|
||||
|
||||
$res = $ruleClass->save($ruleObject);
|
||||
|
||||
if (!$res) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 5000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 5000);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOrdering()
|
||||
{
|
||||
$order = json_decode(acym_getVar('string', 'order'));
|
||||
$i = 1;
|
||||
$error = false;
|
||||
foreach ($order as $rule) {
|
||||
$query = 'UPDATE #__acym_rule SET `ordering` = '.intval($i).' WHERE `id` = '.intval($rule);
|
||||
$error = acym_query($query) >= 0 ? false : true;
|
||||
$i++;
|
||||
}
|
||||
if ($error) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'updated';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function process()
|
||||
{
|
||||
acym_increasePerf();
|
||||
|
||||
$config = acym_config();
|
||||
$bounceClass = acym_get('helper.bounce');
|
||||
$bounceClass->report = true;
|
||||
if (!$bounceClass->init()) {
|
||||
return;
|
||||
}
|
||||
if (!$bounceClass->connect()) {
|
||||
acym_display($bounceClass->getErrors(), 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
$disp = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n";
|
||||
$disp .= '<title>'.addslashes(acym_translation('ACYM_BOUNCE_PROCESS')).'</title>'."\n";
|
||||
$disp .= "<style>body{font-size:12px;font-family: Arial,Helvetica,sans-serif;padding-top:30px;}</style>\n</head>\n<body>";
|
||||
echo $disp;
|
||||
|
||||
acym_display(acym_translation_sprintf('ACYM_BOUNCE_CONNECT_SUCC', $config->get('bounce_username')), 'success');
|
||||
$nbMessages = $bounceClass->getNBMessages();
|
||||
acym_display(acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages), 'info');
|
||||
|
||||
if (empty($nbMessages)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$bounceClass->handleMessages();
|
||||
$bounceClass->close();
|
||||
|
||||
$cronHelper = acym_get('helper.cron');
|
||||
$cronHelper->messages[] = acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages);
|
||||
$cronHelper->detailMessages = $bounceClass->messages;
|
||||
$cronHelper->saveReport();
|
||||
|
||||
if ($config->get('bounce_max', 0) != 0 && $nbMessages > $config->get('bounce_max', 0)) {
|
||||
$url = acym_completeLink('bounces&task=process&continuebounce=1', true, true);
|
||||
if (acym_getVar('int', 'continuebounce')) {
|
||||
echo '<script type="text/javascript" language="javascript">document.location.href=\''.$url.'\';</script>';
|
||||
} else {
|
||||
echo '<div style="padding:20px;"><a href="'.$url.'">'.acym_translation('ACYM_CLICK_HANDLE_ALL_BOUNCES').'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo "</body></html>";
|
||||
while ($bounceClass->obend-- > 0) {
|
||||
ob_start();
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveconfig()
|
||||
{
|
||||
$this->_saveconfig();
|
||||
|
||||
return $this->listing();
|
||||
}
|
||||
|
||||
function _saveconfig()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$config = acym_config();
|
||||
$newConfig = acym_getVar('array', 'config', [], 'POST');
|
||||
if (!empty($newConfig['bounce_username'])) {
|
||||
$newConfig['bounce_username'] = acym_punycode($newConfig['bounce_username']);
|
||||
}
|
||||
|
||||
$newConfig['auto_bounce_next'] = min($config->get('auto_bounce_last', time()), time()) + $newConfig['auto_bounce_frequency'];
|
||||
|
||||
$status = $config->save($newConfig);
|
||||
|
||||
if ($status) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'message');
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error');
|
||||
}
|
||||
|
||||
$config->load();
|
||||
}
|
||||
|
||||
function chart()
|
||||
{
|
||||
acym_setVar('layout', 'chart');
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
|
||||
function test()
|
||||
{
|
||||
|
||||
$bounceClass = acym_get('class.bounce');
|
||||
|
||||
if ($bounceClass->getOrderingNumber() < 1) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_NO_RULES'), 'error', 5000);
|
||||
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
acym_increasePerf();
|
||||
$config = acym_config();
|
||||
$bounceClass = acym_get('helper.bounce');
|
||||
$bounceClass->report = true;
|
||||
|
||||
if ($bounceClass->init()) {
|
||||
if ($bounceClass->connect()) {
|
||||
$nbMessages = $bounceClass->getNBMessages();
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_BOUNCE_CONNECT_SUCC', $config->get('bounce_username')), "success", 5000);
|
||||
$bounceClass->close();
|
||||
if (!empty($nbMessages)) {
|
||||
acym_enqueueNotification(
|
||||
[
|
||||
acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages),
|
||||
acym_modal(
|
||||
acym_translation('ACYM_CLICK_BOUNCE'),
|
||||
'',
|
||||
null,
|
||||
'data-reveal-larger',
|
||||
'data-ajax="true" data-iframe="&ctrl=bounces&task=process" class="acym__color__light-blue cursor-pointer" style="margin: 0"'
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$errors = $bounceClass->getErrors();
|
||||
if (!empty($errors)) {
|
||||
acym_enqueueNotification($errors, 'error');
|
||||
$errorString = implode(' ', $errors);
|
||||
$port = $config->get('bounce_port', '');
|
||||
if (preg_match('#certificate#i', $errorString) && !$config->get('bounce_certif', false)) {
|
||||
acym_enqueueNotification('You may need to turn ON the option <i>'.acym_translation('ACYM_SELF_SIGNED_CERTIFICATE').'</i>', 'warning');
|
||||
} elseif (!empty($port) && !in_array($port, ['993', '143', '110'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_BOUNCE_WRONG_PORT'), 'warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->listing();
|
||||
}
|
||||
|
||||
function reinstall()
|
||||
{
|
||||
$bounceClass = acym_get('class.bounce');
|
||||
$bounceClass->cleanTable();
|
||||
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installBounceRules();
|
||||
|
||||
return $this->listing();
|
||||
}
|
||||
|
||||
public function config()
|
||||
{
|
||||
acym_redirect(acym_completeLink('configuration', false, true));
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$rulesSelected = acym_getVar('array', 'elements_checked');
|
||||
|
||||
$ruleClass = acym_get('class.rule');
|
||||
$ruleClass->delete($rulesSelected);
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,437 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 ConfigurationController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_CONFIGURATION')] = acym_completeLink('configuration');
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar('layout', 'listing');
|
||||
|
||||
$config = acym_config();
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
|
||||
$langs = acym_getLanguages();
|
||||
$languages = [];
|
||||
|
||||
foreach ($langs as $lang => $obj) {
|
||||
if (strlen($lang) != 5 || $lang == "xx-XX") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$oneLanguage = new stdClass();
|
||||
$oneLanguage->language = $lang;
|
||||
$oneLanguage->name = $obj->name;
|
||||
|
||||
$linkEdit = acym_completeLink('language&task=displayLanguage&code='.$lang, true);
|
||||
$icon = $obj->exists ? 'edit' : 'add';
|
||||
$idModalLanguage = 'acym_modal_language_'.$lang;
|
||||
$oneLanguage->edit = acym_modal(
|
||||
'<i class="acymicon-'.$icon.' cursor-pointer acym__color__blue" data-open="'.$idModalLanguage.'" data-ajax="false" data-iframe="'.$linkEdit.'" data-iframe-class="acym__iframe_language" id="image'.$lang.'"></i>',
|
||||
'', //<iframe src="'.$linkEdit.'"></iframe>
|
||||
$idModalLanguage,
|
||||
'data-reveal-larger',
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
$languages[] = $oneLanguage;
|
||||
}
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$lists = $listClass->getAll();
|
||||
foreach ($lists as $i => $oneList) {
|
||||
if ($oneList->active == 0) {
|
||||
unset($lists[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'config' => $config,
|
||||
'tab' => $tabHelper,
|
||||
'languages' => $languages,
|
||||
'lists' => $lists,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
function checkDB()
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
$queries = file_get_contents(ACYM_BACK.'tables.sql');
|
||||
$tables = explode("CREATE TABLE IF NOT EXISTS ", $queries);
|
||||
$structure = [];
|
||||
$createTable = [];
|
||||
$indexes = [];
|
||||
|
||||
foreach ($tables as $oneTable) {
|
||||
if (strpos($oneTable, '`#__') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tableName = substr($oneTable, 1, strpos($oneTable, '`', 1) - 1);
|
||||
|
||||
$fields = explode("\n", $oneTable);
|
||||
foreach ($fields as $oneField) {
|
||||
if (strpos($oneField, '#__') === 1) {
|
||||
continue;
|
||||
}
|
||||
$oneField = rtrim(trim($oneField), ',');
|
||||
|
||||
if (substr($oneField, 0, 1) == '`') {
|
||||
$columnName = substr($oneField, 1, strpos($oneField, '`', 1) - 1);
|
||||
$structure[$tableName][$columnName] = trim($oneField, ",");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($oneField, 'PRIMARY KEY') === 0) {
|
||||
$indexes[$tableName]['PRIMARY'] = $oneField;
|
||||
} elseif (strpos($oneField, 'INDEX') === 0) {
|
||||
$firstBackquotePos = strpos($oneField, '`');
|
||||
$indexName = substr($oneField, $firstBackquotePos + 1, strpos($oneField, '`', $firstBackquotePos + 1) - $firstBackquotePos - 1);
|
||||
|
||||
$indexes[$tableName][$indexName] = $oneField;
|
||||
}
|
||||
}
|
||||
$createTable[$tableName] = "CREATE TABLE IF NOT EXISTS ".$oneTable;
|
||||
}
|
||||
|
||||
|
||||
$columnNames = [];
|
||||
$tableNames = array_keys($structure);
|
||||
|
||||
foreach ($tableNames as $oneTableName) {
|
||||
try {
|
||||
$columns = acym_loadObjectList("SHOW COLUMNS FROM ".$oneTableName);
|
||||
} catch (Exception $e) {
|
||||
$columns = null;
|
||||
}
|
||||
|
||||
if (!empty($columns)) {
|
||||
foreach ($columns as $oneField) {
|
||||
$columnNames[$oneTableName][$oneField->Field] = $oneField->Field;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$errorMessage = (isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200));
|
||||
$messages[] = "<span style=\"color:blue\">Could not load columns from the table ".$oneTableName." : ".$errorMessage."</span>";
|
||||
|
||||
if (strpos($errorMessage, 'marked as crashed')) {
|
||||
$repairQuery = 'REPAIR TABLE '.$oneTableName;
|
||||
|
||||
try {
|
||||
$isError = acym_query($repairQuery);
|
||||
} catch (Exception $e) {
|
||||
$isError = null;
|
||||
}
|
||||
|
||||
if ($isError === null) {
|
||||
$errorMessage = (isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200));
|
||||
$messages[] = "<span style=\"color:red\">[ERROR]Could not repair the table ".$oneTableName." : ".$errorMessage."</span>";
|
||||
} else {
|
||||
$messages[] = "<span style=\"color:green\">[OK]Problem solved : Table ".$oneTableName." repaired</span>";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$isError = acym_query($createTable[$oneTableName]);
|
||||
} catch (Exception $e) {
|
||||
$isError = null;
|
||||
}
|
||||
|
||||
if ($isError === null) {
|
||||
$errorMessage = (isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200));
|
||||
$messages[] = "<span style=\"color:red\">[ERROR]Could not create the table ".$oneTableName." : ".$errorMessage."</span>";
|
||||
} else {
|
||||
$messages[] = "<span style=\"color:green\">[OK]Problem solved : Table ".$oneTableName." created</span>";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tableNames as $oneTableName) {
|
||||
if (empty($columnNames[$oneTableName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$idealColumnNames = array_keys($structure[$oneTableName]);
|
||||
$missingColumns = array_diff($idealColumnNames, $columnNames[$oneTableName]);
|
||||
|
||||
if (!empty($missingColumns)) {
|
||||
foreach ($missingColumns as $oneColumn) {
|
||||
$messages[] = "<span style=\"color:blue\">Column ".$oneColumn." missing in ".$oneTableName."</span>";
|
||||
try {
|
||||
$isError = acym_query('ALTER TABLE '.$oneTableName.' ADD '.$structure[$oneTableName][$oneColumn]);
|
||||
} catch (Exception $e) {
|
||||
$isError = null;
|
||||
}
|
||||
if ($isError === null) {
|
||||
$errorMessage = (isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200));
|
||||
$messages[] = '<span style="color:red">[ERROR]Could not add the column '.$oneColumn.' on the table '.$oneTableName.' : '.$errorMessage.'</span>';
|
||||
} else {
|
||||
$messages[] = '<span style="color:green">[OK]Problem solved : Added '.$oneColumn.' in '.$oneTableName.'</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$results = acym_loadObjectList('SHOW INDEX FROM '.$oneTableName, 'Key_name');
|
||||
if (empty($results)) {
|
||||
$results = [];
|
||||
}
|
||||
|
||||
foreach ($indexes[$oneTableName] as $name => $query) {
|
||||
$name = acym_prepareQuery($name);
|
||||
if (in_array($name, array_keys($results))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$keyName = $name == 'PRIMARY' ? 'primary key' : 'index '.$name;
|
||||
|
||||
$messages[] = "<span style=\"color:blue\">".$keyName." missing in ".$oneTableName."</span>";
|
||||
try {
|
||||
$isError = acym_query('ALTER TABLE '.$oneTableName.' ADD '.$query);
|
||||
} catch (Exception $e) {
|
||||
$isError = null;
|
||||
}
|
||||
|
||||
if ($isError === null) {
|
||||
$errorMessage = (isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200));
|
||||
$messages[] = "<span style=\"color:red\">[ERROR]Could not add the ".$keyName." on the table ".$oneTableName." : ".$errorMessage."</span>";
|
||||
} else {
|
||||
$messages[] = "<span style=\"color:green\">[OK]Problem solved : Added ".$keyName." to ".$oneTableName."</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($messages)) {
|
||||
echo '<i class="fa fa-check-circle-o acym__color__green"></i>';
|
||||
} else {
|
||||
echo implode('<br />', $messages);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function store()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$formData = acym_getVar('array', 'config', []);
|
||||
if (empty($formData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($formData['from_as_replyto'] == 1) {
|
||||
$formData['replyto_name'] = $formData['from_name'];
|
||||
$formData['replyto_email'] = $formData['from_email'];
|
||||
}
|
||||
|
||||
|
||||
$config = acym_config();
|
||||
$status = $config->save($formData);
|
||||
|
||||
if ($status) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 0);
|
||||
}
|
||||
|
||||
$config->load();
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->store();
|
||||
|
||||
$config = acym_config();
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
$addedName = $config->get('add_names', true) ? $mailerHelper->cleanText(acym_currentUserName()) : '';
|
||||
|
||||
$mailerHelper->AddAddress(acym_currentUserEmail(), $addedName);
|
||||
$mailerHelper->Subject = 'Test e-mail from '.ACYM_LIVE;
|
||||
$mailerHelper->Body = acym_translation('ACYM_TEST_EMAIL');
|
||||
$mailerHelper->SMTPDebug = 1;
|
||||
if (acym_isDebug()) {
|
||||
$mailerHelper->SMTPDebug = 2;
|
||||
}
|
||||
|
||||
$mailerHelper->isHTML(false);
|
||||
$result = $mailerHelper->send();
|
||||
|
||||
if (!$result) {
|
||||
$sendingMethod = $config->get('mailer_method');
|
||||
|
||||
if ($sendingMethod == 'smtp') {
|
||||
if ($config->get('smtp_secured') == 'ssl' && !function_exists('openssl_sign')) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_OPENSSL'), 'notice');
|
||||
}
|
||||
|
||||
if (!$config->get('smtp_auth') && strlen($config->get('smtp_password')) > 1) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ADVICE_SMTP_AUTH'), 'notice');
|
||||
}
|
||||
|
||||
if ($config->get('smtp_port') && !in_array($config->get('smtp_port'), [25, 2525, 465, 587])) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_ADVICE_PORT', $config->get('smtp_port')), 'notice');
|
||||
}
|
||||
}
|
||||
|
||||
if (acym_isLocalWebsite() && in_array($sendingMethod, ['sendmail', 'qmail', 'mail'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ADVICE_LOCALHOST'), 'notice');
|
||||
}
|
||||
|
||||
$bounce = $config->get('bounce_email');
|
||||
if (!empty($bounce) && !in_array($sendingMethod, ['smtp', 'elasticemail'])) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_ADVICE_BOUNCE', '<b>'.$bounce.'</b>'), 'notice');
|
||||
}
|
||||
}
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function ports()
|
||||
{
|
||||
if (!function_exists('fsockopen')) {
|
||||
echo '<span style="color:red">'.acym_translation('ACYM_FSOCKOPEN').'</span>';
|
||||
exit;
|
||||
}
|
||||
|
||||
$tests = [25 => 'smtp.sendgrid.com', 2525 => 'smtp.sendgrid.com', 587 => 'smtp.sendgrid.com', 465 => 'ssl://smtp.sendgrid.com'];
|
||||
$total = 0;
|
||||
foreach ($tests as $port => $server) {
|
||||
$fp = @fsockopen($server, $port, $errno, $errstr, 5);
|
||||
if ($fp) {
|
||||
echo '<br /><span style="color:#3dea91" >'.acym_translation_sprintf('ACYM_SMTP_AVAILABLE_PORT', $port).'</span>';
|
||||
fclose($fp);
|
||||
$total++;
|
||||
} else {
|
||||
echo '<br /><span style="color:#ff5259" >'.acym_translation_sprintf('ACYM_SMTP_NOT_AVAILABLE_PORT', $port, $errno.' - '.utf8_encode($errstr)).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function detecttimeout()
|
||||
{
|
||||
acym_query('REPLACE INTO `#__acym_configuration` (`name`,`value`) VALUES ("max_execution_time","5"), ("last_maxexec_check","'.time().'")');
|
||||
@ini_set('max_execution_time', 600);
|
||||
@ignore_user_abort(true);
|
||||
$i = 0;
|
||||
while ($i < 480) {
|
||||
sleep(8);
|
||||
$i += 10;
|
||||
acym_query('UPDATE `#__acym_configuration` SET `value` = "'.intval($i).'" WHERE `name` = "max_execution_time"');
|
||||
acym_query('UPDATE `#__acym_configuration` SET `value` = "'.intval(time()).'" WHERE `name` = "last_maxexec_check"');
|
||||
sleep(2);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public function deletereport()
|
||||
{
|
||||
$config = acym_config();
|
||||
$path = trim(html_entity_decode($config->get('cron_savepath')));
|
||||
if (!preg_match('#^[a-z0-9/_\-{}]*\.log$#i', $path)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_WRONG_LOG_NAME'), 'error', 6000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$path = str_replace(['{year}', '{month}'], [date('Y'), date('m')], $config->get('cron_savepath'));
|
||||
$reportPath = acym_cleanPath(ACYM_ROOT.$path);
|
||||
|
||||
if (is_file($reportPath)) {
|
||||
$result = acym_deleteFile($reportPath);
|
||||
if ($result) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCC_DELETE_LOG'), 'success', 4000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_DELETE_LOG'), 'error', 4000);
|
||||
}
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_EXIST_LOG'), 'info', 4000);
|
||||
}
|
||||
|
||||
return $this->listing();
|
||||
}
|
||||
|
||||
public function seereport()
|
||||
{
|
||||
acym_noCache();
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
$path = trim(html_entity_decode($config->get('cron_savepath')));
|
||||
if (!preg_match('#^[a-z0-9/_\-{}]*\.log$#i', $path)) {
|
||||
acym_display(acym_translation('ACYM_WRONG_LOG_NAME'), 'error');
|
||||
}
|
||||
|
||||
$path = str_replace(['{year}', '{month}'], [date('Y'), date('m')], $path);
|
||||
$reportPath = acym_cleanPath(ACYM_ROOT.$path);
|
||||
|
||||
if (file_exists($reportPath) && !is_dir($reportPath)) {
|
||||
try {
|
||||
$lines = 5000;
|
||||
$f = fopen($reportPath, "rb");
|
||||
fseek($f, -1, SEEK_END);
|
||||
if (fread($f, 1) != "\n") {
|
||||
$lines -= 1;
|
||||
}
|
||||
|
||||
$report = '';
|
||||
while (ftell($f) > 0 && $lines >= 0) {
|
||||
$seek = min(ftell($f), 4096); // Figure out how far back we should jump
|
||||
fseek($f, -$seek, SEEK_CUR);
|
||||
$report = ($chunk = fread($f, $seek)).$report; // Get the line
|
||||
fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
|
||||
$lines -= substr_count($chunk, "\n"); // Move to previous line
|
||||
}
|
||||
|
||||
while ($lines++ < 0) {
|
||||
$report = substr($report, strpos($report, "\n") + 1);
|
||||
}
|
||||
fclose($f);
|
||||
} catch (Exception $e) {
|
||||
$report = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($report)) {
|
||||
$report = acym_translation('ACYM_EMPTY_LOG');
|
||||
}
|
||||
|
||||
echo nl2br($report);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function redomigration()
|
||||
{
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->migration = 0;
|
||||
$config->save($newConfig);
|
||||
|
||||
acym_redirect(acym_completeLink('dashboard', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,845 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 DashboardController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->loadScripts = [
|
||||
'all' => ['colorpicker', 'datepicker', 'thumbnail', 'foundation-email', 'parse-css'],
|
||||
];
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar('layout', 'listing');
|
||||
$config = acym_config();
|
||||
|
||||
if ($config->get('migration') == 0 && acym_existsAcyMailing59()) {
|
||||
|
||||
acym_setVar("layout", "migrate");
|
||||
|
||||
parent::display();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ACYM_CMS === 'wordpress') {
|
||||
$installDate = $config->get('install_date', time());
|
||||
$remindme = json_decode($config->get('remindme', '[]'));
|
||||
|
||||
if ($installDate < time() - 1814400 && !in_array('reviews', $remindme)) {
|
||||
$this->feedback();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$newConfig = new stdClass();
|
||||
|
||||
$newConfig->migration = '1';
|
||||
$config->save($newConfig);
|
||||
|
||||
if ($config->get('walk_through') == 1) {
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
if (!empty($walkthroughParams['step'])) {
|
||||
$this->{$walkthroughParams['step']}();
|
||||
} else {
|
||||
$this->stepSubscribe();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$campaignClass = acym_get('class.campaign');
|
||||
$mailStatsClass = acym_get('class.mailstat');
|
||||
$urlClickClass = acym_get('class.urlclick');
|
||||
$mails = $mailStatsClass->getAllMailsForStats();
|
||||
$data['campaignsScheduled'] = $campaignClass->getCampaignForDashboard();
|
||||
$data['dashboard_stats'] = true;
|
||||
|
||||
if (empty($mails)) {
|
||||
$data['emptyGlobal'] = 'campaigns';
|
||||
parent::display($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data['mails'] = [];
|
||||
|
||||
foreach ($mails as $mail) {
|
||||
if (empty($mail->name) || (empty($mail->id) && $mail->sent != 1)) continue;
|
||||
|
||||
$newMail = new stdClass();
|
||||
$newMail->name = $mail->name;
|
||||
$newMail->value = $mail->id;
|
||||
$data['mails'][] = $newMail;
|
||||
}
|
||||
|
||||
$data['selectedMailid'] = empty($selectedMail) ? '' : $selectedMail;
|
||||
|
||||
$statsMailSelected = $mailStatsClass->getOneByMailId($data['selectedMailid']);
|
||||
|
||||
if (empty($statsMailSelected)) {
|
||||
$data['emptyGlobal'] = empty($data['selectedMailid']) ? 'campaigns' : 'stats';
|
||||
}
|
||||
|
||||
if (empty($statsMailSelected->sent)) {
|
||||
$data['emptyGlobal'] = 'stats';
|
||||
}
|
||||
|
||||
$statsMailSelected->totalMail = $statsMailSelected->sent + $statsMailSelected->fail;
|
||||
$statsMailSelected->pourcentageSent = empty($statsMailSelected->totalMail) ? 0 : intval(($statsMailSelected->sent * 100) / $statsMailSelected->totalMail);
|
||||
$statsMailSelected->allSent = empty($statsMailSelected->totalMail) ? acym_translation_sprintf('ACYM_X_MAIL_SUCCESSFULLY_SENT_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_SUCCESSFULLY_SENT_OF_X', $statsMailSelected->sent, $statsMailSelected->totalMail);
|
||||
|
||||
$openRateCampaign = empty($data['selectedMailid']) ? $campaignClass->getOpenRateAllCampaign() : $campaignClass->getOpenRateOneCampaign($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageOpen = empty($openRateCampaign->sent) ? 0 : intval(($openRateCampaign->open_unique * 100) / $openRateCampaign->sent);
|
||||
$statsMailSelected->allOpen = empty($openRateCampaign->sent) ? acym_translation_sprintf('ACYM_X_MAIL_OPENED_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_OPENED_OF_X', $openRateCampaign->open_unique, $openRateCampaign->sent);
|
||||
|
||||
$clickRateCampaign = $urlClickClass->getClickRate($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageClick = empty($statsMailSelected->sent) ? 0 : intval(($clickRateCampaign->click * 100) / $statsMailSelected->sent);
|
||||
$statsMailSelected->allClick = empty($statsMailSelected->sent) ? acym_translation_sprintf('ACYM_X_MAIL_CLICKED_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_CLICKED_OF_X', $clickRateCampaign->click, $statsMailSelected->sent);
|
||||
|
||||
$bounceRateCampaign = empty($data['selectedMailid']) ? $campaignClass->getBounceRateAllCampaign() : $campaignClass->getBounceRateOneCampaign($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageBounce = empty($statsMailSelected->sent) ? 0 : intval(($bounceRateCampaign->bounce_unique * 100) / $statsMailSelected->sent);
|
||||
$statsMailSelected->allBounce = empty($statsMailSelected->sent) ? acym_translation_sprintf('ACYM_X_BOUNCE_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_BOUNCE_OF_X', $bounceRateCampaign->bounce_unique, $statsMailSelected->sent);
|
||||
|
||||
|
||||
$campaignOpenByMonth = $campaignClass->getOpenByMonth($data['selectedMailid']);
|
||||
$campaignOpenByDay = $campaignClass->getOpenByDay($data['selectedMailid']);
|
||||
$campaignOpenByHour = $campaignClass->getOpenByHour($data['selectedMailid']);
|
||||
|
||||
$campaignClickByMonth = $urlClickClass->getAllClickByMailMonth($data['selectedMailid']);
|
||||
$campaignClickByDay = $urlClickClass->getAllClickByMailDay($data['selectedMailid']);
|
||||
$campaignClickByHour = $urlClickClass->getAllClickByMailHour($data['selectedMailid']);
|
||||
|
||||
if (empty($campaignOpenByMonth) || empty($campaignOpenByDay) || empty($campaignOpenByHour)) {
|
||||
$statsMailSelected->empty = true;
|
||||
$data['stats_mail_1'] = $statsMailSelected;
|
||||
|
||||
parent::display($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#To get all the month between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByMonth) ? $campaignOpenByMonth[0]->open_date : min([$campaignOpenByMonth[0]->open_date, $campaignClickByMonth[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByMonth) ? end($campaignOpenByMonth)->open_date : max([end($campaignOpenByMonth)->open_date, end($campaignClickByMonth)->date_click]));
|
||||
|
||||
$end->modify('+1 day');
|
||||
|
||||
$interval = new DateInterval('P1M');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeMonth = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeMonth[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
#To get all the day between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByDay) ? $campaignOpenByDay[0]->open_date : min([$campaignOpenByDay[0]->open_date, $campaignClickByDay[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByDay) ? end($campaignOpenByDay)->open_date : max([end($campaignOpenByDay)->open_date, end($campaignClickByDay)->date_click]));
|
||||
|
||||
$end->modify('+1 hour');
|
||||
|
||||
$interval = new DateInterval('P1D');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeDay = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeDay[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
|
||||
#To get all the hour between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByHour) ? $campaignOpenByHour[0]->open_date : min([$campaignOpenByHour[0]->open_date, $campaignClickByHour[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByHour) ? end($campaignOpenByHour)->open_date : max([end($campaignOpenByHour)->open_date, end($campaignClickByHour)->date_click]));
|
||||
|
||||
$end->modify('+1 min');
|
||||
|
||||
$interval = new DateInterval('PT1H');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeHour = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeHour[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$openMonthArray = [];
|
||||
$openDayArray = [];
|
||||
$openHourArray = [];
|
||||
|
||||
foreach ($campaignOpenByMonth as $one) {
|
||||
$openMonthArray[acym_date(acym_getTime($one->open_date), 'M Y')] = $one->open;
|
||||
}
|
||||
|
||||
foreach ($campaignOpenByDay as $one) {
|
||||
$openDayArray[acym_date(acym_getTime($one->open_date), 'd M Y')] = $one->open;
|
||||
}
|
||||
|
||||
foreach ($campaignOpenByHour as $one) {
|
||||
$openHourArray[acym_date(acym_getTime($one->open_date), 'd M Y H')] = $one->open;
|
||||
}
|
||||
|
||||
$clickMonthArray = [];
|
||||
$clickDayArray = [];
|
||||
$clickHourArray = [];
|
||||
|
||||
foreach ($campaignClickByMonth as $one) {
|
||||
$clickMonthArray[acym_date(acym_getTime($one->date_click), 'M Y')] = $one->click;
|
||||
}
|
||||
|
||||
foreach ($campaignClickByDay as $one) {
|
||||
$clickDayArray[acym_date(acym_getTime($one->date_click), 'd M Y')] = $one->click;
|
||||
}
|
||||
|
||||
foreach ($campaignClickByHour as $one) {
|
||||
$clickHourArray[acym_date(acym_getTime($one->date_click), 'd M Y H')] = $one->click;
|
||||
}
|
||||
|
||||
$statsMailSelected->month = [];
|
||||
foreach ($rangeMonth as $one) {
|
||||
$one = acym_date($one, 'M Y');
|
||||
$currentMonth = [];
|
||||
$currentMonth['open'] = empty($openMonthArray[$one]) ? 0 : $openMonthArray[$one];
|
||||
$currentMonth['click'] = empty($clickMonthArray[$one]) ? 0 : $clickMonthArray[$one];
|
||||
$statsMailSelected->month[$one] = $currentMonth;
|
||||
}
|
||||
|
||||
$statsMailSelected->day = [];
|
||||
foreach ($rangeDay as $one) {
|
||||
$one = acym_date($one, 'd M Y');
|
||||
$currentDay = [];
|
||||
$currentDay['open'] = empty($openDayArray[$one]) ? 0 : $openDayArray[$one];
|
||||
$currentDay['click'] = empty($clickDayArray[$one]) ? 0 : $clickDayArray[$one];
|
||||
$statsMailSelected->day[$one] = $currentDay;
|
||||
}
|
||||
|
||||
$statsMailSelected->hour = [];
|
||||
foreach ($rangeHour as $one) {
|
||||
$one = acym_date($one, 'd M Y H');
|
||||
$currentHour = [];
|
||||
$currentHour['open'] = empty($openHourArray[$one]) ? 0 : $openHourArray[$one];
|
||||
$currentHour['click'] = empty($clickHourArray[$one]) ? 0 : $clickHourArray[$one];
|
||||
$statsMailSelected->hour[$one.':00'] = $currentHour;
|
||||
}
|
||||
$data['stats_mail_1'] = $statsMailSelected;
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function stepSubscribe()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'subscribe',
|
||||
'email' => acym_currentUserEmail(),
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepSubscribe()
|
||||
{
|
||||
$this->_saveWalkthrough(['step' => 'stepEmail']);
|
||||
$this->stepEmail();
|
||||
}
|
||||
|
||||
public function stepEmail()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$updateHelper = acym_get('helper.update');
|
||||
|
||||
$mail = empty($walkthroughParams['mail_id']) ? $mailClass->getOneByName(acym_translation($updateHelper::FIRST_EMAIL_NAME_KEY)) : $mailClass->getOneById($walkthroughParams['mail_id']);
|
||||
|
||||
if (empty($mail)) {
|
||||
$updateHelper = acym_get('helper.update');
|
||||
if (!$updateHelper->installNotifications()) {
|
||||
$this->stepSubscribe();
|
||||
|
||||
return;
|
||||
}
|
||||
$mail = $mailClass->getOneByName(acym_translation($updateHelper::FIRST_EMAIL_NAME_KEY));
|
||||
}
|
||||
|
||||
$editor = acym_get('helper.editor');
|
||||
$editor->content = $mail->body;
|
||||
$editor->autoSave = '';
|
||||
$editor->settings = $mail->settings;
|
||||
$editor->stylesheet = $mail->stylesheet;
|
||||
$editor->editor = 'acyEditor';
|
||||
$editor->mailId = $mail->id;
|
||||
$editor->walkThrough = true;
|
||||
|
||||
$data = [
|
||||
'step' => 'email',
|
||||
'editor' => $editor,
|
||||
'social_icons' => $config->get('social_icons', '{}'),
|
||||
'mail' => $mail,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveAjax()
|
||||
{
|
||||
$mailController = acym_get('controller.mails');
|
||||
|
||||
$isWellSaved = $mailController->store(true);
|
||||
echo json_encode(['error' => $isWellSaved ? '' : acym_translation('ACYM_ERROR_SAVING'), 'data' => $isWellSaved]);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function saveStepEmail()
|
||||
{
|
||||
$mailController = acym_get('controller.mails');
|
||||
|
||||
$mailId = $mailController->store();
|
||||
|
||||
if (empty($mailId)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 10000);
|
||||
$this->passWalkThrough();
|
||||
} else {
|
||||
$this->_saveWalkthrough(['step' => 'stepList', 'mail_id' => $mailId]);
|
||||
$this->stepList();
|
||||
}
|
||||
}
|
||||
|
||||
public function stepList()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
$listClass = acym_get('class.list');
|
||||
$config = acym_config();
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
|
||||
$users = empty($walkthroughParams['list_id']) ? [] : $listClass->getSubscribersByListId($walkthroughParams['list_id']);
|
||||
$usersReturn = [];
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$usersReturn[] = $user->email;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($usersReturn)) $usersReturn[] = acym_currentUserEmail();
|
||||
|
||||
$data = [
|
||||
'step' => 'list',
|
||||
'users' => $usersReturn,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepList()
|
||||
{
|
||||
$config = acym_config();
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
if (empty($walkthroughParams['list_id'])) {
|
||||
$testingList = new stdClass();
|
||||
$testingList->name = acym_translation('ACYM_TESTING_LIST');
|
||||
$testingList->visible = 0;
|
||||
$testingList->active = 1;
|
||||
$testingList->color = '#94d4a6';
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$listId = $listClass->save($testingList);
|
||||
} else {
|
||||
$listId = $walkthroughParams['list_id'];
|
||||
}
|
||||
|
||||
if (empty($listId)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVE_LIST'), 'error', 5000);
|
||||
$this->passWalkThrough();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$addresses = acym_getVar('array', 'addresses', []);
|
||||
$addresses = array_unique($addresses);
|
||||
$wrongAddresses = [];
|
||||
foreach ($addresses as $oneAddress) {
|
||||
if (!acym_isValidEmail($oneAddress)) {
|
||||
$wrongAddresses[] = $oneAddress;
|
||||
continue;
|
||||
}
|
||||
|
||||
$existing = $userClass->getOneByEmail($oneAddress);
|
||||
if (empty($existing)) {
|
||||
$newUser = new stdClass();
|
||||
$newUser->email = $oneAddress;
|
||||
$newUser->confirmed = 1;
|
||||
|
||||
$userId = $userClass->save($newUser);
|
||||
} else {
|
||||
$userId = $existing->id;
|
||||
}
|
||||
|
||||
$userClass->subscribe($userId, $listId);
|
||||
}
|
||||
|
||||
if (!empty($wrongAddresses)) acym_enqueueNotification(acym_translation_sprintf('ACYM_WRONG_ADDRESSES', implode(', ', $wrongAddresses)), 'warning', 5000);
|
||||
|
||||
$nextStep = acym_isLocalWebsite() ? 'stepGmail' : 'stepPhpmail';
|
||||
|
||||
$this->_saveWalkthrough(['step' => $nextStep, 'list_id' => $listId]);
|
||||
$this->$nextStep();
|
||||
}
|
||||
|
||||
public function stepPhpmail()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'phpmail',
|
||||
'userEmail' => acym_currentUserEmail(),
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepPhpmail()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
|
||||
if (!$this->_saveFrom()) {
|
||||
$this->stepPhpmail();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$mailerMethod = ['mailer_method' => 'phpmail'];
|
||||
if (false === $config->save($mailerMethod)) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_ERROR_SAVING', 'error'));
|
||||
$this->stepPhpmail();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (false === $this->_sendFirstEmail()) {
|
||||
$this->stepPhpmail();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_saveWalkthrough(['step' => 'stepResult']);
|
||||
$this->stepResult();
|
||||
}
|
||||
|
||||
public function stepGmail()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'gmail',
|
||||
'userEmail' => acym_currentUserEmail(),
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepGmail()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
if (!$this->_saveFrom() || !$this->_saveGmailInformation()) {
|
||||
$this->stepGmail();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_sendFirstEmail();
|
||||
|
||||
$this->_saveWalkthrough(['step' => 'stepResult']);
|
||||
$this->stepResult();
|
||||
}
|
||||
|
||||
public function stepResult()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'result',
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepResult()
|
||||
{
|
||||
$config = acym_config();
|
||||
$result = acym_getVar('boolean', 'result');
|
||||
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
|
||||
$stepFail = acym_isLocalWebsite() || !empty($walkthroughParams['step_fail']) ? 'stepFaillocal' : 'stepFail';
|
||||
|
||||
$nextStep = $result ? 'stepSuccess' : $stepFail;
|
||||
$this->_saveWalkthrough(['step' => $nextStep]);
|
||||
|
||||
$this->$nextStep();
|
||||
}
|
||||
|
||||
public function stepSuccess()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'success',
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepSuccess()
|
||||
{
|
||||
$this->passWalkThrough();
|
||||
}
|
||||
|
||||
public function stepFaillocal()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
$data = [
|
||||
'step' => 'faillocal',
|
||||
'email' => acym_currentUserEmail(),
|
||||
];
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepFaillocal()
|
||||
{
|
||||
$this->_handleContactMe('stepFaillocal');
|
||||
}
|
||||
|
||||
public function stepFail()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'fail',
|
||||
'email' => acym_currentUserEmail(),
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepFail()
|
||||
{
|
||||
$choice = acym_getVar('cmd', 'choice', 'gmail');
|
||||
if ('gmail' === $choice) {
|
||||
$this->_saveGmailInformation();
|
||||
$this->_sendFirstEmail();
|
||||
$this->_saveWalkthrough(['step' => 'stepResult', 'step_fail' => true]);
|
||||
$this->stepResult();
|
||||
} else {
|
||||
$this->_handleContactMe('stepFail');
|
||||
}
|
||||
}
|
||||
|
||||
private function _handleContactMe($fromFunction)
|
||||
{
|
||||
$email = acym_getVar('string', 'email');
|
||||
if (empty($email) || !acym_isValidEmail($email)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_ADD_YOUR_EMAIL'), 'error', 10000);
|
||||
$this->$fromFunction();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
$handle = curl_init();
|
||||
$url = ACYM_UPDATEMEURL.'contact&task=contactme&email='.urlencode($email).'&version='.$config->get('version', '6').'&cms='.ACYM_CMS;
|
||||
curl_setopt($handle, CURLOPT_URL, $url);
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
||||
$output = curl_exec($handle);
|
||||
curl_close($handle);
|
||||
$output = json_decode($output, true);
|
||||
if (!empty($output['error'])) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_SOMETHING_WENT_WRONG_CONTACT_ON_ACYBA'), 'error');
|
||||
$this->passWalkThrough();
|
||||
} else {
|
||||
$this->_saveWalkthrough(['step' => 'stepSupport']);
|
||||
$this->stepSupport();
|
||||
}
|
||||
}
|
||||
|
||||
public function stepSupport()
|
||||
{
|
||||
acym_setVar('layout', 'walk_through');
|
||||
|
||||
$data = [
|
||||
'step' => 'support',
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function saveStepSupport()
|
||||
{
|
||||
$this->passWalkThrough();
|
||||
}
|
||||
|
||||
public function passWalkThrough()
|
||||
{
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->walk_through = 0;
|
||||
|
||||
if ($config->get('templates_installed') == 0) {
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installTemplate();
|
||||
$newConfig->templates_installed = 1;
|
||||
}
|
||||
$config->save($newConfig);
|
||||
|
||||
acym_redirect(acym_completeLink('users&task=import', false, true));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function preMigration()
|
||||
{
|
||||
$elementToMigrate = acym_getVar("string", "element");
|
||||
$helperMigration = acym_get('helper.migration');
|
||||
|
||||
$result = $helperMigration->preMigration($elementToMigrate);
|
||||
|
||||
if (!empty($result["isOk"])) {
|
||||
echo $result["count"];
|
||||
} else {
|
||||
echo "ERROR : ";
|
||||
if (!empty($result["errorInsert"])) {
|
||||
echo strtoupper(acym_translation("ACYM_INSERT_ERROR"));
|
||||
}
|
||||
if (!empty($result["errorClean"])) {
|
||||
echo strtoupper(acym_translation("ACYM_CLEAN_ERROR"));
|
||||
}
|
||||
|
||||
if (!empty($result["errors"])) {
|
||||
echo "<br>";
|
||||
|
||||
foreach ($result["errors"] as $key => $oneError) {
|
||||
echo "<br>".$key." : ".$oneError;
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public function migrate()
|
||||
{
|
||||
$elementToMigrate = acym_getVar("string", "element");
|
||||
$helperMigration = acym_get('helper.migration');
|
||||
$functionName = "do".ucfirst($elementToMigrate)."Migration";
|
||||
|
||||
$result = $helperMigration->$functionName($elementToMigrate);
|
||||
|
||||
if (!empty($result["isOk"])) {
|
||||
echo json_encode($result);
|
||||
} else {
|
||||
echo "ERROR : ";
|
||||
if (!empty($result["errorInsert"])) {
|
||||
echo strtoupper(acym_translation("ACYM_INSERT_ERROR"));
|
||||
}
|
||||
if (!empty($result["errorClean"])) {
|
||||
echo strtoupper(acym_translation("ACYM_CLEAN_ERROR"));
|
||||
}
|
||||
|
||||
if (!empty($result["errors"])) {
|
||||
echo "<br>";
|
||||
|
||||
foreach ($result["errors"] as $key => $oneError) {
|
||||
echo "<br>".$key." : ".$oneError;
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public function migrationDone()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->migration = "1";
|
||||
$config->save($newConfig);
|
||||
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installNotifications();
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
private function acym_existsAcyMailing59()
|
||||
{
|
||||
$allTables = acym_getTables();
|
||||
|
||||
if (in_array(acym_getPrefix().'acymailing_config', $allTables)) {
|
||||
$queryVersion = 'SELECT `value` FROM #__acymailing_config WHERE `namekey` LIKE "version"';
|
||||
|
||||
$version = acym_loadResult($queryVersion);
|
||||
|
||||
if (version_compare($version, '5.9.0') >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function upgrade()
|
||||
{
|
||||
acym_setVar('layout', 'upgrade');
|
||||
|
||||
$version = acym_getVar('string', 'version', 'enterprise');
|
||||
|
||||
$data = ['version' => $version];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function feedback()
|
||||
{
|
||||
acym_setVar('layout', 'feedback');
|
||||
|
||||
parent::display();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function _saveFrom()
|
||||
{
|
||||
$fromName = acym_getVar('string', 'from_name', 'Test');
|
||||
$fromAddress = acym_getVar('string', 'from_address', 'test@test.com');
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$updateHelper = acym_get('helper.update');
|
||||
|
||||
$firstMail = $mailClass->getOneByName(acym_translation($updateHelper::FIRST_EMAIL_NAME_KEY));
|
||||
|
||||
if (empty($firstMail)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_REINSTALL_ACYMAILING'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$firstMail->from_name = $fromName;
|
||||
$firstMail->from_email = $fromAddress;
|
||||
|
||||
$statusSaveMail = $mailClass->save($firstMail);
|
||||
|
||||
if (empty($statusSaveMail)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _saveGmailInformation()
|
||||
{
|
||||
$gmailAddress = acym_getVar('string', 'gmail_address', '');
|
||||
$gmailPassword = acym_getVar('string', 'gmail_password', '');
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
if (empty($gmailAddress) || empty($gmailPassword)) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_EMPTY_ADDRESS_OR_PASSWORD'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$newSmtpConfiguration = [
|
||||
'smtp_auth' => '1',
|
||||
'smtp_host' => 'smtp.gmail.com',
|
||||
'smtp_keepalive' => '1',
|
||||
'smtp_port' => '465',
|
||||
'smtp_secured' => 'ssl',
|
||||
'smtp_username' => $gmailAddress,
|
||||
'smtp_password' => $gmailPassword,
|
||||
'mailer_method' => 'smtp',
|
||||
];
|
||||
|
||||
if (false === $config->save($newSmtpConfiguration)) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_ERROR_SAVING', 'error'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _sendFirstEmail()
|
||||
{
|
||||
$config = acym_config();
|
||||
$walkthroughParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
$listClass = acym_get('class.list');
|
||||
$mailClass = acym_get('class.mail');
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
|
||||
$testingList = empty($walkthroughParams['list_id']) ? $listClass->getOneByName(acym_translation('ACYM_TESTING_LIST')) : $listClass->getOneById($walkthroughParams['list_id']);
|
||||
$firstMail = empty($walkthroughParams['mail_id']) ? $mailClass->getOneByName(acym_translation($updateHelper::FIRST_EMAIL_NAME_KEY)) : $mailClass->getOneById($walkthroughParams['mail_id']);
|
||||
|
||||
if (empty($testingList)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_CANT_RETRIEVE_TESTING_LIST'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($firstMail)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_CANT_RETRIEVE_TEST_EMAIL'), 'error');
|
||||
}
|
||||
|
||||
$subscribersTestingListIds = $listClass->getSubscribersIdsById($testingList->id);
|
||||
|
||||
$nbSent = 0;
|
||||
foreach ($subscribersTestingListIds as $subscriberId) {
|
||||
if ($mailerHelper->sendOne($firstMail->id, $subscriberId, true)) $nbSent++;
|
||||
}
|
||||
|
||||
if ($nbSent === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _saveWalkthrough($params)
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
$newParams = json_decode($config->get('walkthrough_params', '[]'), true);
|
||||
foreach ($params as $key => $value) {
|
||||
$newParams[$key] = $value;
|
||||
}
|
||||
$config->save(['walkthrough_params' => json_encode($newParams)]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 DynamicsController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setDefaultTask('popup');
|
||||
}
|
||||
|
||||
public function popup()
|
||||
{
|
||||
$plugins = acym_trigger('dynamicText');
|
||||
$isAutomation = acym_getVar('string', 'automation');
|
||||
|
||||
$js = 'function setTag(tagvalue, element){
|
||||
var $allRows = jQuery(".acym__listing__row__popup");
|
||||
$allRows.removeClass("selected_row");
|
||||
element.addClass("selected_row");
|
||||
window.document.getElementById(\'dtextcode\').value = tagvalue;
|
||||
}';
|
||||
$js .= 'try{window.parent.previousSelection = window.parent.getPreviousSelection(); }catch(err){window.parent.previousSelection=false; }';
|
||||
|
||||
acym_addScript(true, $js);
|
||||
|
||||
$tab = acym_get('helper.tab');
|
||||
|
||||
$data = [
|
||||
"type" => acym_getVar('string', 'type', 'news'),
|
||||
"plugins" => $plugins,
|
||||
"tab" => $tab,
|
||||
"automation" => $isAutomation,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function replaceDummy()
|
||||
{
|
||||
$mailId = acym_getVar('int', 'mailId', 0);
|
||||
if (!empty($mailId)) {
|
||||
$mailClass = acym_get('class.mail');
|
||||
$email = $mailClass->getOneById($mailId);
|
||||
}
|
||||
|
||||
if (empty($email)) {
|
||||
$email = new stdClass();
|
||||
$email->id = 0;
|
||||
$email->name = '';
|
||||
$email->subject = '';
|
||||
$email->from_name = '';
|
||||
$email->from_email = '';
|
||||
$email->reply_to_name = '';
|
||||
$email->reply_to_email = '';
|
||||
$email->bcc = '';
|
||||
}
|
||||
|
||||
$email->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
$email->creator_id = acym_currentUserId();
|
||||
$email->thumbnail = '';
|
||||
$email->drag_editor = '1';
|
||||
$email->library = '0';
|
||||
$email->type = 'standard';
|
||||
$email->template = '0';
|
||||
$email->settings = '';
|
||||
$email->stylesheet = '';
|
||||
$email->attachments = '';
|
||||
|
||||
$email->body = acym_getVar('string', 'code', '');
|
||||
|
||||
|
||||
acym_trigger('replaceContent', [&$email]);
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$userEmail = acym_currentUserEmail();
|
||||
$user = $userClass->getOneByEmail($userEmail);
|
||||
|
||||
if (empty($user)) {
|
||||
$user = new stdClass();
|
||||
$user->email = acym_currentUserEmail();
|
||||
$user->name = acym_currentUserName();
|
||||
$user->cms_id = acym_currentUserId();
|
||||
$user->confirmed = 0;
|
||||
$user->source = ACYM_CMS;
|
||||
|
||||
$userClass->checkVisitor = false;
|
||||
$user->id = $userClass->save($user);
|
||||
}
|
||||
|
||||
acym_trigger('replaceUserInformation', [&$email, &$user, false]);
|
||||
|
||||
echo $email->body;
|
||||
exit;
|
||||
}
|
||||
|
||||
function trigger()
|
||||
{
|
||||
$plugin = acym_getVar('cmd', 'plugin', '');
|
||||
$trigger = acym_getVar('cmd', 'trigger', '');
|
||||
if (empty($plugin) || empty($trigger)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
acym_trigger($trigger, [], $plugin);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 FieldsController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_CUSTOM_FIELDS')] = acym_completeLink('fields');
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
|
||||
if (!acym_level(2)) {
|
||||
acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
|
||||
}
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
acym_setVar('layout', 'edit');
|
||||
$id = acym_getVar('int', 'id');
|
||||
$fieldClass = acym_get('class.field');
|
||||
|
||||
if (empty($id)) {
|
||||
$field = new stdClass();
|
||||
$field->id = 0;
|
||||
$field->name = '';
|
||||
$field->active = 1;
|
||||
$field->type = 'text';
|
||||
$field->value = '';
|
||||
$field->option = '';
|
||||
$field->default_value = '';
|
||||
$field->required = 0;
|
||||
$field->backend_profile = 1;
|
||||
$field->backend_listing = 0;
|
||||
$field->backend_filter = 1;
|
||||
$field->frontend_form = 1;
|
||||
$field->frontend_profile = 1;
|
||||
$field->frontend_filter = 1;
|
||||
$field->access = 1;
|
||||
$field->fieldDB = new stdClass();
|
||||
} else {
|
||||
$field = $fieldClass->getOneFieldByID($id);
|
||||
$field->option = json_decode($field->option);
|
||||
$field->value = json_decode($field->value);
|
||||
$field->fieldDB = empty($field->option->fieldDB) ? new stdClass() : json_decode($field->option->fieldDB);
|
||||
if (!in_array($id, [1, 2]) && !empty($field->fieldDB->table)) {
|
||||
$tables = acym_loadResultArray('SHOW TABLES FROM `'.acym_secureDBColumn($field->fieldDB->database).'`');
|
||||
$field->fieldDB->tables = [];
|
||||
foreach ($tables as $one) {
|
||||
$field->fieldDB->tables[$one] = $one;
|
||||
}
|
||||
$columns = empty($field->fieldDB->table) ? [] : acym_loadResultArray('SHOW COLUMNS FROM '.acym_secureDBColumn($field->fieldDB->table).' FROM '.acym_secureDBColumn($field->fieldDB->database));
|
||||
$field->fieldDB->columns = [];
|
||||
foreach ($columns as $one) {
|
||||
$field->fieldDB->columns[$one] = $one;
|
||||
}
|
||||
array_unshift($field->fieldDB->columns, acym_translation('ACYM_CHOOSE_COLUMN'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
$this->breadcrumb[acym_escape(acym_translation($field->name))] = acym_completeLink('fields&task=edit&id='.$id);
|
||||
} else {
|
||||
$this->breadcrumb[acym_translation('ACYM_NEW_CUSTOM_FIELD')] = acym_completeLink('fields&task=edit');
|
||||
}
|
||||
|
||||
$allDatabases = acym_loadResultArray('SHOW DATABASES');
|
||||
$databases = [];
|
||||
foreach ($allDatabases as $database) {
|
||||
$databases[$database] = $database;
|
||||
}
|
||||
|
||||
$allFields = $fieldClass->getAllfields();
|
||||
|
||||
$allFieldsName = [];
|
||||
foreach ($allFields as $one) {
|
||||
$allFieldsName[$one->id] = $one->name;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'field' => $field,
|
||||
'database' => $databases,
|
||||
'allFields' => $allFieldsName,
|
||||
];
|
||||
|
||||
$data['fieldType'] = [
|
||||
'text' => acym_translation('ACYM_TEXT'),
|
||||
'textarea' => acym_translation('ACYM_TEXTAREA'),
|
||||
'radio' => acym_translation('ACYM_RADIO'),
|
||||
'checkbox' => acym_translation('ACYM_CHECKBOX'),
|
||||
'single_dropdown' => acym_translation('ACYM_SINGLE_DROPDOWN'),
|
||||
'multiple_dropdown' => acym_translation('ACYM_MULTIPLE_DROPDOWN'),
|
||||
'date' => acym_translation('ACYM_DATE'),
|
||||
'file' => acym_translation('ACYM_FILE'),
|
||||
'phone' => acym_translation('ACYM_PHONE'),
|
||||
'custom_text' => acym_translation('ACYM_CUSTOM_TEXT'),
|
||||
];
|
||||
|
||||
return parent::display($data);
|
||||
}
|
||||
|
||||
public function getTables()
|
||||
{
|
||||
$database = acym_getVar('string', 'database');
|
||||
$allTables = acym_loadResultArray('SHOW TABLES FROM '.$database);
|
||||
echo json_encode($allTables);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function setColumns()
|
||||
{
|
||||
$table = acym_getVar('string', 'table');
|
||||
$database = acym_getVar('string', 'database');
|
||||
$query = 'SHOW COLUMNS FROM '.$table.' FROM '.$database;
|
||||
$columns = acym_loadResultArray($query);
|
||||
array_unshift($columns, 'ACYM_CHOOSE_COLUMN');
|
||||
echo json_encode($columns);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function apply()
|
||||
{
|
||||
$fieldClass = acym_get('class.field');
|
||||
$newField = $this->setFieldToSave();
|
||||
$id = $fieldClass->save($newField);
|
||||
if (!empty($id)) {
|
||||
acym_setVar('id', $id);
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 5000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 5000);
|
||||
}
|
||||
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$fieldClass = acym_get('class.field');
|
||||
$newField = $this->setFieldToSave();
|
||||
$id = $fieldClass->save($newField);
|
||||
if (!empty($id)) {
|
||||
acym_setVar('id', $id);
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 5000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 5000);
|
||||
}
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
private function setFieldToSave()
|
||||
{
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = acym_getVar('array', 'field');
|
||||
$fieldDB = json_encode(acym_getVar('array', 'fieldDB'));
|
||||
$id = acym_getVar('int', 'id');
|
||||
if ($id == 2) {
|
||||
$field['required'] = 1;
|
||||
}
|
||||
if (empty($field['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$value = [];
|
||||
|
||||
$fieldValues = $field['value'];
|
||||
$field['type'] = in_array($id, [1, 2]) ? 'text' : $field['type'];
|
||||
|
||||
$i = 0;
|
||||
foreach ($fieldValues['value'] as $one) {
|
||||
if (empty($one) && $one != '0' && ($i != 0 || !in_array($field['type'], ['single_dropdown', 'multiple_dropdown']))) {
|
||||
$i++;
|
||||
continue;
|
||||
} else {
|
||||
$value[$i] = [
|
||||
'value' => $one,
|
||||
'title' => $fieldValues['title'][$i],
|
||||
'disabled' => $fieldValues['disabled'][$i],
|
||||
];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$field['namekey'] = empty($field['namekey']) ? $fieldClass->generateNamekey($field['name']) : $field['namekey'];
|
||||
$field['option']['format'] = ($field['type'] == 'date' && empty($field['option']['format'])) ? '%d%m%y' : strtolower($field['option']['format']);
|
||||
$field['option']['rows'] = ($field['type'] == 'textarea' && empty($field['option']['rows'])) ? '5' : $field['option']['rows'];
|
||||
$field['option']['columns'] = ($field['type'] == 'textarea' && empty($field['option']['columns'])) ? '30' : $field['option']['columns'];
|
||||
|
||||
$field['value'] = json_encode($value);
|
||||
$field['option']['fieldDB'] = $fieldDB;
|
||||
$field['option']['format'] = !empty($field['option']['format']) ? preg_replace('/[^a-zA-Z\%]/', '', $field['option']['format']) : $field['option']['format'];
|
||||
$newField = new stdClass();
|
||||
$newField->name = $field['name'];
|
||||
$newField->active = $field['active'];
|
||||
$newField->namekey = $field['namekey'];
|
||||
$newField->type = in_array($id, [1, 2]) ? 'text' : $field['type'];
|
||||
$newField->required = $field['required'];
|
||||
$newField->option = json_encode($field['option']);
|
||||
$newField->value = $field['value'];
|
||||
$newField->default_value = $field['default_value'];
|
||||
$newField->frontend_form = $field['frontend_form'];
|
||||
$newField->frontend_profile = $field['frontend_profile'];
|
||||
$newField->backend_profile = $field['backend_profile'];
|
||||
$newField->backend_listing = $field['backend_listing'];
|
||||
$newField->backend_filter = 1;
|
||||
$newField->frontend_filter = 1;
|
||||
$newField->access = 'all';
|
||||
if (empty($id)) {
|
||||
$newField->ordering = $fieldClass->getOrdering()->ordering_number + 1;
|
||||
} else {
|
||||
$newField->id = $id;
|
||||
}
|
||||
|
||||
return $newField;
|
||||
}
|
||||
|
||||
public function setOrdering()
|
||||
{
|
||||
$order = json_decode(acym_getVar('string', 'order'));
|
||||
$i = 1;
|
||||
$error = false;
|
||||
foreach ($order as $field) {
|
||||
$query = 'UPDATE #__acym_field SET `ordering` = '.intval($i).' WHERE `id` = '.intval($field);
|
||||
$error = acym_query($query) >= 0 ? false : true;
|
||||
$i++;
|
||||
}
|
||||
if ($error) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'updated';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$ids = acym_getVar('cmd', 'elements_checked');
|
||||
if (in_array('1', $ids) || in_array('2', $ids)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_CANT_DELETE'), 'error', 5000);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return parent::delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 FileController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setDefaultTask('select');
|
||||
}
|
||||
|
||||
public function select()
|
||||
{
|
||||
$config = acym_config();
|
||||
$uploadFolders = $config->get('uploadfolder', ACYM_UPLOAD_FOLDER);
|
||||
$uploadFolder = acym_getVar('string', 'currentFolder', $uploadFolders);
|
||||
$uploadPath = acym_cleanPath(ACYM_ROOT.trim(str_replace('/', DS, trim($uploadFolder)), DS));
|
||||
$map = acym_getVar('string', 'id');
|
||||
acym_setVar('layout', 'select');
|
||||
|
||||
$folders = acym_generateArborescence([$uploadFolders]);
|
||||
|
||||
|
||||
$uploadedFile = acym_getVar('array', 'uploadedFile', [], 'files');
|
||||
if (!empty($uploadedFile) && !empty($uploadedFile['name'])) {
|
||||
$uploaded = acym_importFile($uploadedFile, $uploadPath, false);
|
||||
if ($uploaded) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$allowedExtensions = explode(',', $config->get('allowed_files'));
|
||||
$imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'ico', 'bmp', 'svg'];
|
||||
$displayType = acym_getVar('string', 'displayType', 'icons');
|
||||
|
||||
$files = [];
|
||||
if (file_exists($uploadPath)) {
|
||||
$files = acym_getFiles($uploadPath);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'files' => $files,
|
||||
'uploadFolder' => $uploadFolder,
|
||||
'map' => $map,
|
||||
'displayType' => $displayType,
|
||||
'imageExtensions' => $imageExtensions,
|
||||
'allowedExtensions' => $allowedExtensions,
|
||||
'folders' => $folders,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 LanguageController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function saveLanguage($fromShare = false)
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$code = acym_getVar('cmd', 'code');
|
||||
acym_setVar('code', $code);
|
||||
|
||||
$content = acym_getVar('string', 'content', '', '', ACYM_ALLOWHTML);
|
||||
$content = str_replace('</textarea>', '', $content);
|
||||
|
||||
if (empty($code) || empty($content)) {
|
||||
return $this->displayLanguage();
|
||||
}
|
||||
|
||||
$customcontent = acym_getVar('string', 'customcontent', '', '', ACYM_ALLOWHTML);
|
||||
$customcontent = str_replace('</textarea>', '', $customcontent);
|
||||
|
||||
$path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
|
||||
$result = acym_writeFile($path, $content);
|
||||
if ($result) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
|
||||
acym_addScript(true, "window.top.document.getElementById('image$code').innerHTML = 'edit'");
|
||||
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installBackLanguages($code);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FAIL_SAVE', $path), 'error');
|
||||
}
|
||||
|
||||
$custompath = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
|
||||
$customresult = acym_writeFile($custompath, $customcontent);
|
||||
if (!$customresult) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FAIL_SAVE', $custompath), 'error');
|
||||
}
|
||||
|
||||
if ($code == acym_getLanguageTag()) {
|
||||
acym_loadLanguage();
|
||||
}
|
||||
|
||||
$updateHelper = acym_get('helper.update');
|
||||
$updateHelper->installBackLanguages();
|
||||
|
||||
if ($fromShare) {
|
||||
return $result;
|
||||
} else {
|
||||
return $this->displayLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
public function latest()
|
||||
{
|
||||
$this->displayLanguage();
|
||||
}
|
||||
|
||||
public function share()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
if ($this->saveLanguage(true)) {
|
||||
acym_setVar('layout', 'share');
|
||||
|
||||
$file = new stdClass();
|
||||
$file->name = acym_getVar('cmd', 'code');
|
||||
|
||||
return parent::display(['file' => $file]);
|
||||
} else {
|
||||
return $this->displayLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$bodyEmail = acym_getVar('string', 'mailbody');
|
||||
$code = acym_getVar('cmd', 'code');
|
||||
acym_setVar('code', $code);
|
||||
|
||||
if (empty($code)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
$mailer = acym_get('helper.mailer');
|
||||
$mailer->Subject = '[ACYMAILING LANGUAGE FILE] '.$code;
|
||||
$mailer->Body = 'The website '.ACYM_LIVE.' using AcyMailing '.$config->get('level').' '.$config->get('version').' sent a language file : '.$code;
|
||||
$mailer->Body .= "\n\n\n".$bodyEmail;
|
||||
|
||||
$file = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
|
||||
if (!file_exists($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$translation = acym_fileGetContent($file);
|
||||
|
||||
$customFile = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
|
||||
|
||||
if (file_exists($customFile)) {
|
||||
$customTranslation = acym_fileGetContent($customFile);
|
||||
|
||||
if (!empty($customTranslation)) {
|
||||
$newKeys = [];
|
||||
$customKeys = [];
|
||||
preg_match_all('#([0-9A-Z_]+)="((?:[^"]|"_QQ_")+)"#is', $customTranslation, $customKeys);
|
||||
|
||||
if (!empty($customKeys)) {
|
||||
$mainKeys = [];
|
||||
preg_match_all('#([0-9A-Z_]+)="((?:[^"]|"_QQ_")+)"#is', $translation, $mainKeys);
|
||||
|
||||
foreach ($customKeys[1] as $index => $oneKey) {
|
||||
$position = array_search($oneKey, $mainKeys[1]);
|
||||
if ($position !== false) {
|
||||
$translation = str_replace($mainKeys[0][$position], $customKeys[0][$index], $translation);
|
||||
} else {
|
||||
$newKeys[] = $customKeys[0][$index];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($newKeys)) {
|
||||
$mailer->Body .= "\n\n\nCustom content:\n".implode("\n", $newKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mailer->addStringAttachment($translation, $code.'.com_acym.ini');
|
||||
|
||||
$mailer->AddAddress(acym_currentUserEmail(), acym_currentUserName());
|
||||
$mailer->AddAddress('translate@acyba.com', 'Acyba Translation Team');
|
||||
$mailer->report = false;
|
||||
|
||||
$result = $mailer->Send();
|
||||
|
||||
if ($result) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_THANK_YOU_SHARING').'<br>'.acym_translation('ACYM_MESSAGE_SENT'), 'success');
|
||||
} else {
|
||||
acym_enqueueNotification($mailer->reportMessage, 'error');
|
||||
}
|
||||
|
||||
$this->displayLanguage();
|
||||
}
|
||||
|
||||
public function displayLanguage()
|
||||
{
|
||||
acym_setVar("layout", "default");
|
||||
|
||||
$code = acym_getVar('string', 'code');
|
||||
if (empty($code)) {
|
||||
acym_display('Code not specified', 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$file = new stdClass();
|
||||
$file->name = $code;
|
||||
$path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
|
||||
$file->path = $path;
|
||||
$file->content = '';
|
||||
$file->customcontent = '';
|
||||
|
||||
|
||||
$showLatest = true;
|
||||
$loadLatest = false;
|
||||
|
||||
if (file_exists($path)) {
|
||||
$file->content = acym_fileGetContent($path);
|
||||
if (empty($file->content)) {
|
||||
acym_display('File not found : '.$path, 'error');
|
||||
}
|
||||
} else {
|
||||
$loadLatest = true;
|
||||
acym_enqueueMessage(acym_translation('ACYM_LOAD_ENGLISH_1').'<br />'.acym_translation('ACYM_LOAD_ENGLISH_2').'<br />'.acym_translation('ACYM_LOAD_ENGLISH_3'), 'info');
|
||||
$file->content = acym_fileGetContent(acym_getLanguagePath(ACYM_ROOT, ACYM_DEFAULT_LANGUAGE).DS.ACYM_DEFAULT_LANGUAGE.'.com_acym.ini');
|
||||
}
|
||||
|
||||
$custompath = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
|
||||
if (file_exists($custompath)) {
|
||||
$file->customcontent = acym_fileGetContent($custompath);
|
||||
}
|
||||
|
||||
if ($loadLatest || acym_getVar('cmd', 'task') == 'latest') {
|
||||
if (file_exists(acym_getLanguagePath(ACYM_ROOT, $code))) {
|
||||
acym_addScript(false, ACYM_UPDATEMEURL.'update&component=acym&task=languageload&code='.acym_getVar('cmd', 'code'));
|
||||
} else {
|
||||
acym_enqueueMessage('The specified language "'.acym_escape($code).'" is not installed on your site', 'warning');
|
||||
}
|
||||
$showLatest = false;
|
||||
} elseif (acym_getVar('cmd', 'task') == 'save') {
|
||||
$showLatest = false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'showLatest' => $showLatest,
|
||||
'file' => $file,
|
||||
];
|
||||
|
||||
return parent::display($data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,550 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 ListsController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_LISTS')] = acym_completeLink('lists');
|
||||
$this->edition = acym_getVar('int', 'edition', 0);
|
||||
$this->listClass = acym_get('class.list');
|
||||
$this->loadScripts = [
|
||||
'edit' => ['colorpicker'],
|
||||
'save' => ['colorpicker'],
|
||||
];
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar("layout", "listing");
|
||||
|
||||
$searchFilter = acym_getVar('string', 'lists_search', '');
|
||||
$tagFilter = acym_getVar('string', 'lists_tag', '');
|
||||
$ordering = acym_getVar('string', 'lists_ordering', 'id');
|
||||
$status = acym_getVar('string', 'lists_status', '');
|
||||
$format = acym_getVar('string', 'global_listingformat', 'list');
|
||||
$orderingSortOrder = acym_getVar('string', 'lists_ordering_sort_order', 'desc');
|
||||
|
||||
$listsPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'lists_pagination_page', 1);
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$matchingLists = $listClass->getMatchingLists(
|
||||
[
|
||||
'ordering' => $ordering,
|
||||
'search' => $searchFilter,
|
||||
'listsPerPage' => $listsPerPage,
|
||||
'offset' => ($page - 1) * $listsPerPage,
|
||||
'tag' => $tagFilter,
|
||||
'status' => $status,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingLists['total'], $page, $listsPerPage);
|
||||
|
||||
$data = [
|
||||
"lists" => $matchingLists['lists'],
|
||||
"tags" => acym_get('class.tag')->getAllTagsByType('list'),
|
||||
"pagination" => $pagination,
|
||||
"search" => $searchFilter,
|
||||
"tag" => $tagFilter,
|
||||
"ordering" => $ordering,
|
||||
"listNumberPerStatus" => $matchingLists["status"],
|
||||
"status" => $status,
|
||||
"format" => $format,
|
||||
"orderingSortOrder" => $orderingSortOrder,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function subscribers()
|
||||
{
|
||||
acym_setVar("layout", "subscribers");
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
|
||||
if (!$listId) {
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$searchFilter = acym_getVar('string', 'subscribers_search', '');
|
||||
$status = acym_getVar('string', 'subscribers_status', '');
|
||||
|
||||
$usersPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'subscribers_pagination_page', 1);
|
||||
|
||||
$listData = [];
|
||||
$listData['listInformation'] = $this->listClass->getOneById($listId);
|
||||
|
||||
$link = $this->edition ? acym_completeLink('lists&task=edit&step=subscribers&edition=1&id=').$listId : '';
|
||||
$this->breadcrumb[acym_escape($listData['listInformation']->name)] = $link;
|
||||
|
||||
if (is_null($listData['listInformation'])) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_LIST_DOESNT_EXIST"), 'error', 0);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$matchingUsers = $this->listClass->getMatchingSubscribersByListId(
|
||||
[
|
||||
'search' => $searchFilter,
|
||||
'usersPerPage' => $usersPerPage,
|
||||
'offset' => ($page - 1) * $usersPerPage,
|
||||
'status' => $status,
|
||||
],
|
||||
$listId
|
||||
);
|
||||
|
||||
$allSubscribedUsersId = $this->listClass->getSubscribersIdsById($listId);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingUsers['total'], $page, $usersPerPage);
|
||||
|
||||
$listData['listSubscribers'] = $matchingUsers['users'];
|
||||
$listData['pagination'] = $pagination;
|
||||
$listData['search'] = $searchFilter;
|
||||
$listData['userNumberPerStatus'] = $matchingUsers['status'];
|
||||
$listData['status'] = $status;
|
||||
$listData['subscribedUsersId'] = json_encode($allSubscribedUsersId);
|
||||
|
||||
parent::display($listData);
|
||||
}
|
||||
|
||||
public function unsubscribeUser()
|
||||
{
|
||||
acym_checkToken();
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
$userId = acym_getVar("int", "userid", 0);
|
||||
|
||||
if (!empty($listId) && !empty($userId)) {
|
||||
$userClass = acym_get('class.user');
|
||||
if ($userClass->unsubscribe($userId, $listId)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_THE_USER_HAS_BEEN_UNSUBSCRIBED"), 'success', 8000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_THE_USER_CANT_BE_UNSUBSCRIBED"), 'error', 0);
|
||||
}
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_THE_USER_CANT_BE_UNSUBSCRIBED"), 'error', 0);
|
||||
}
|
||||
$this->subscribers();
|
||||
}
|
||||
|
||||
public function unsubscribeUsers()
|
||||
{
|
||||
acym_checkToken();
|
||||
$ids = acym_getVar('array', 'elements_checked', []);
|
||||
$userClass = acym_get('class.user');
|
||||
foreach ($ids as $id) {
|
||||
if (!empty($id)) {
|
||||
$userClass->unsubscribe($id, acym_getVar('int', 'id', 0));
|
||||
}
|
||||
}
|
||||
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function unsubscribeSelected()
|
||||
{
|
||||
acym_checkToken();
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
$selectedUsers = acym_getVar("array", "elements_checked", []);
|
||||
|
||||
|
||||
if (!empty($selectedUsers) && !empty($listId)) {
|
||||
$userClass = acym_get('class.user');
|
||||
if ($userClass->unsubscribe($selectedUsers, $listId)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_SUCCESSFULLY_UNSUBSCRIBED"), 'success', 8000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_ERROR_DURING_UNSUBSCRIBE"), 'error', 0);
|
||||
}
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_THE_USER_CANT_BE_UNSUBSCRIBED"), 'error', 0);
|
||||
}
|
||||
|
||||
acym_setVar('search', acym_getVar('string', 'subscribers_search', ''));
|
||||
acym_setVar('status', acym_getVar('string', 'subscribers_status', ''));
|
||||
acym_setVar('list_limit', acym_getCMSConfig('list_limit', 20));
|
||||
acym_setVar('pagination_page', acym_getVar('int', 'subscribers_pagination_page', ''));
|
||||
|
||||
$this->subscribers();
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
acym_setVar("layout", "settings");
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
$listTagsName = [];
|
||||
|
||||
$randColor = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
|
||||
if (!$listId) {
|
||||
$listInformation = new stdClass();
|
||||
$listInformation->id = "";
|
||||
$listInformation->name = "";
|
||||
$listInformation->active = 1;
|
||||
$listInformation->from_name = "";
|
||||
$listInformation->from_email = "";
|
||||
$listInformation->reply_to_name = "";
|
||||
$listInformation->reply_to_email = "";
|
||||
$listInformation->color = '#'.$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)].$randColor[rand(0, 15)];
|
||||
|
||||
$this->breadcrumb[acym_translation('ACYM_NEW_LIST')] = acym_completeLink('lists&task=edit&step=settings');
|
||||
} else {
|
||||
|
||||
$listsTags = acym_get('class.tag')->getAllTagsByElementId('list', $listId);
|
||||
|
||||
foreach ($listsTags as $oneTag) {
|
||||
$listTagsName[] = $oneTag;
|
||||
}
|
||||
|
||||
$listInformation = $this->listClass->getOneById($listId);
|
||||
if (is_null($listInformation)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_LIST_DOESNT_EXIST"), 'error', 0);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->breadcrumb[acym_escape($listInformation->name)] = acym_completeLink('lists&task=edit&step=settings&id=').$listId;
|
||||
acym_setVar('edition', '1');
|
||||
}
|
||||
|
||||
$listData = [
|
||||
"listInformation" => $listInformation,
|
||||
"allTags" => acym_get('class.tag')->getAllTagsByType('list'),
|
||||
"listTagsName" => $listTagsName,
|
||||
];
|
||||
|
||||
parent::display($listData);
|
||||
}
|
||||
|
||||
private function selectEmail($type)
|
||||
{
|
||||
acym_setVar("layout", $type);
|
||||
$listId = acym_getVar("int", "id");
|
||||
if (empty($listId)) {
|
||||
return $this->listing();
|
||||
}
|
||||
|
||||
$searchFilter = acym_getVar('string', $type.'_search', '');
|
||||
|
||||
$mailsPerPage = 12;
|
||||
$page = acym_getVar('int', $type.'_pagination_page', 1);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mails = $mailClass->getMailsByType(
|
||||
$type,
|
||||
[
|
||||
'mailsPerPage' => $mailsPerPage,
|
||||
'offset' => ($page - 1) * $mailsPerPage,
|
||||
'search' => $searchFilter,
|
||||
]
|
||||
);
|
||||
|
||||
$currentList = $this->listClass->getOneById($listId);
|
||||
$columnId = $type.'_id';
|
||||
$selectedTemplate = !empty($currentList->$columnId) ? $currentList->$columnId : '';
|
||||
$this->breadcrumb[acym_escape($currentList->name)] = acym_completeLink('lists&task=edit&step='.$type.'&id=').$listId.($this->edition ? '&edition=1' : '');
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($mails['total'], $page, $mailsPerPage);
|
||||
|
||||
foreach ($mails['mails'] as $oneMail) {
|
||||
if (empty($oneMail->thumbnail)) {
|
||||
$oneMail->thumbnail = ACYM_IMAGES.'default_template_thumbnail.png';
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
$type.'Mails' => $mails['mails'],
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'selected'.ucfirst($type) => $selectedTemplate,
|
||||
'listId' => $listId,
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function welcome()
|
||||
{
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
$listInformation = $this->listClass->getOneById($listId);
|
||||
|
||||
if (is_null($listInformation)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_LIST_DOESNT_EXIST"), 'error', 0);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->selectEmail('welcome');
|
||||
}
|
||||
|
||||
public function unsubscribe()
|
||||
{
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
$listInformation = $this->listClass->getOneById($listId);
|
||||
|
||||
if (is_null($listInformation)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_LIST_DOESNT_EXIST"), 'error', 0);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->selectEmail('unsubscribe');
|
||||
}
|
||||
|
||||
public function addSubscribers()
|
||||
{
|
||||
acym_checkToken();
|
||||
$idsNewSubscribers = json_decode(acym_getVar('string', 'users_selected', ""));
|
||||
$listId = acym_getVar('int', 'id', 0);
|
||||
|
||||
if (!empty($idsNewSubscribers) && is_array($idsNewSubscribers) && !empty($listId)) {
|
||||
$userClass = acym_get('class.user');
|
||||
$userClass->subscribe($idsNewSubscribers, $listId);
|
||||
acym_enqueueNotification(acym_translation('ACYM_USERS_SUBSCRIBED'), "success", "5000");
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation('ACYM_NO_USERS_HAVE_BEEN_SUBSCRIBED'), "notice", "5000");
|
||||
}
|
||||
|
||||
$this->subscribers();
|
||||
}
|
||||
|
||||
public function saveSettings()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$listUseSameReplyTo = acym_getVar("boolean", "list_use_same_reply-to");
|
||||
$formData = (object)acym_getVar("array", "list", []);
|
||||
|
||||
$listId = acym_getVar('int', 'id', 0);
|
||||
if (!empty($listId)) {
|
||||
$formData->id = $listId;
|
||||
}
|
||||
|
||||
$allowedFields = acym_getColumns('list');
|
||||
$listInformation = new stdClass();
|
||||
foreach ($formData as $name => $data) {
|
||||
if (!in_array($name, $allowedFields)) {
|
||||
continue;
|
||||
}
|
||||
$listInformation->{$name} = $data;
|
||||
}
|
||||
|
||||
$listInformation->tags = acym_getVar("array", "list_tags", []);
|
||||
|
||||
if ($listUseSameReplyTo) {
|
||||
$listInformation->reply_to_name = $listInformation->from_name;
|
||||
$listInformation->reply_to_email = $listInformation->from_email;
|
||||
}
|
||||
|
||||
$listId = $this->listClass->save($listInformation);
|
||||
|
||||
if (!empty($listId)) {
|
||||
acym_setVar('id', $listId);
|
||||
acym_enqueueNotification(acym_translation_sprintf("ACYM_LIST_IS_SAVED", $listInformation->name), 'success', 8000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_ERROR_SAVING"), 'error', 0);
|
||||
if (!empty($this->listClass->errors)) {
|
||||
acym_enqueueNotification($this->listClass->errors, 'error', 0);
|
||||
}
|
||||
acym_setVar('nextstep', 'listing');
|
||||
}
|
||||
|
||||
return $this->edit();
|
||||
}
|
||||
|
||||
public function saveSubscribers()
|
||||
{
|
||||
acym_checkToken();
|
||||
$listId = acym_getVar("int", "id", 0);
|
||||
acym_setVar('id', $listId);
|
||||
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function saveWelcome()
|
||||
{
|
||||
$this->saveMail();
|
||||
}
|
||||
|
||||
public function saveUnsubscribe()
|
||||
{
|
||||
$this->saveMail();
|
||||
}
|
||||
|
||||
private function saveMail()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$listId = acym_getVar('int', "id");
|
||||
$mail = acym_getVar('int', 'mailSelected') == 0 ? null : acym_getVar('int', 'mailSelected');
|
||||
$typeMail = acym_getVar('string', 'typeMail');
|
||||
|
||||
$listData = new stdClass();
|
||||
$listData->id = $listId;
|
||||
|
||||
if ($typeMail == 'welcome') {
|
||||
$listData->welcome_id = $mail;
|
||||
} else {
|
||||
$listData->unsubscribe_id = $mail;
|
||||
}
|
||||
|
||||
$listId = $this->listClass->save($listData);
|
||||
|
||||
if (empty($listId)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING_LIST_TEMPLATE'), 'error', 0);
|
||||
if (!empty($this->listClass->errors)) {
|
||||
acym_enqueueNotification($this->listClass->errors, 'error', 0);
|
||||
}
|
||||
acym_setVar('nextstep', 'listing');
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_SUCCESSFULLY_SAVED"), 'success', 8000);
|
||||
}
|
||||
|
||||
return $this->edit();
|
||||
}
|
||||
|
||||
public function setVisible()
|
||||
{
|
||||
acym_checkToken();
|
||||
$ids = acym_getVar('array', 'elements_checked', []);
|
||||
|
||||
if (!empty($ids)) {
|
||||
$this->listClass->setVisible($ids, 1);
|
||||
}
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function setInvisible()
|
||||
{
|
||||
acym_checkToken();
|
||||
$ids = acym_getVar('array', 'elements_checked', []);
|
||||
|
||||
if (!empty($ids)) {
|
||||
$this->listClass->setVisible($ids, 0);
|
||||
}
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function setAjaxListing()
|
||||
{
|
||||
$showSelected = acym_getVar('string', 'show_selected');
|
||||
$matchingListsData = new stdClass();
|
||||
$matchingListsData->ordering = 'name';
|
||||
$matchingListsData->searchFilter = acym_getVar('string', 'search_lists');
|
||||
$matchingListsData->listsPerPage = acym_getVar('string', 'listsPerPage');
|
||||
$matchingListsData->idsSelected = json_decode(acym_getVar('string', 'selectedLists'));
|
||||
$matchingListsData->idsAlready = json_decode(acym_getVar('string', 'alreadyLists'));
|
||||
$matchingListsData->page = acym_getVar('int', 'pagination_page_ajax');
|
||||
$matchingListsData->needDisplaySub = acym_getVar('int', 'needDisplaySub');
|
||||
$matchingListsData->displayNonActive = acym_getVar('int', 'nonActive');
|
||||
if (empty($matchingListsData->page)) {
|
||||
$matchingListsData->page = 1;
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
'ordering' => $matchingListsData->ordering,
|
||||
'search' => $matchingListsData->searchFilter,
|
||||
'listsPerPage' => $matchingListsData->listsPerPage,
|
||||
'offset' => ($matchingListsData->page - 1) * $matchingListsData->listsPerPage,
|
||||
'already' => $matchingListsData->idsAlready,
|
||||
];
|
||||
|
||||
if ($showSelected == 'true') {
|
||||
$params['ids'] = $matchingListsData->idsSelected;
|
||||
}
|
||||
|
||||
$lists = $this->listClass->getListsWithIdNameCount($params);
|
||||
|
||||
$return = '';
|
||||
|
||||
if (empty($lists['lists'])) {
|
||||
$return .= '<h1 class="cell acym__listing__empty__search__modal text-center">'.acym_translation('ACYM_NO_RESULTS_FOUND').'</h1>';
|
||||
}
|
||||
|
||||
foreach ($lists['lists'] as $list) {
|
||||
if (!empty($matchingListsData->displayNonActive) && $list->active == 0) {
|
||||
continue;
|
||||
}
|
||||
$return .= '<div class="grid-x modal__pagination__listing__lists__in-form__list cell">';
|
||||
|
||||
$return .= '<div class="cell shrink"><input type="checkbox" id="modal__pagination__listing__lists__list'.acym_escape($list->id).'" value="'.acym_escape($list->id).'" class="modal__pagination__listing__lists__list--checkbox" name="lists_checked[]"';
|
||||
|
||||
if (!empty($matchingListsData->idsSelected) && in_array($list->id, $matchingListsData->idsSelected)) {
|
||||
$return .= 'checked';
|
||||
}
|
||||
|
||||
$return .= '></div><i class="cell shrink fa fa-circle" style="color:'.acym_escape($list->color).'"></i><label class="cell auto" for="modal__pagination__listing__lists__list'.acym_escape($list->id).'"> ';
|
||||
|
||||
$return .= '<span class="modal__pagination__listing__lists__list-name">'.acym_escape($list->name).'</span>';
|
||||
|
||||
if (!empty($matchingListsData->needDisplaySub)) {
|
||||
$return .= '<span class="modal__pagination__listing__lists__list-subscribers">('.acym_escape($list->subscribers).')</span>';
|
||||
}
|
||||
|
||||
$return .= '</label></div>';
|
||||
}
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($lists['total'], $matchingListsData->page, $matchingListsData->listsPerPage);
|
||||
|
||||
$return .= $pagination->displayAjax();
|
||||
|
||||
echo $return;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function ajaxGetLists()
|
||||
{
|
||||
$subscribedListsIds = acym_getVar('string', 'ids');
|
||||
$echo = '';
|
||||
|
||||
$subscribedListsIds = explode(',', $subscribedListsIds);
|
||||
|
||||
$allLists = $this->listClass->getListsByIds($subscribedListsIds);
|
||||
|
||||
foreach ($allLists as $list) {
|
||||
$echo .= '<div class="grid-x cell acym__listing__row">
|
||||
<div class="grid-x medium-5 cell acym__users__display__list__name">
|
||||
<i class="cell shrink fa fa-circle" style="color:'.$list->color.'"></i>
|
||||
<h6 class="cell auto">'.$list->name.'</h6>
|
||||
</div>
|
||||
<div class="medium-2 hide-for-small-only cell text-center acym__users__display__subscriptions__opening"></div>
|
||||
<div class="medium-2 hide-for-small-only cell text-center acym__users__display__subscriptions__clicking"></div>
|
||||
<div id="'.$list->id.'" class="medium-3 cell acym__users__display__list--action acym__user__action--remove">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
<span>'.acym_translation('ACYM_REMOVE').'</span>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
$return = [];
|
||||
$return['html'] = $echo;
|
||||
$return['notif'] = acym_translation_sprintf('ACYM_X_CONFIRMATION_SUBSCRIPTION_ADDED_AND_CLICK_TO_SAVE', count($allLists));
|
||||
$return = json_encode($return);
|
||||
echo $return;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,620 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 MailsController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$type = acym_getVar('string', 'type');
|
||||
$this->breadcrumb[acym_translation('automation' != $type ? 'ACYM_TEMPLATES' : 'ACYM_AUTOMATION')] = acym_completeLink('automation' != $type ? 'mails' : 'automation');
|
||||
$this->loadScripts = [
|
||||
'edit' => ['colorpicker', 'datepicker', 'editor', 'thumbnail', 'foundation-email', 'parse-css'],
|
||||
'apply' => ['colorpicker', 'datepicker', 'editor', 'thumbnail', 'foundation-email', 'parse-css'],
|
||||
'test' => ['colorpicker', 'datepicker', 'editor', 'thumbnail', 'foundation-email', 'parse-css'],
|
||||
];
|
||||
header('X-XSS-Protection:0');
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar('layout', 'listing');
|
||||
|
||||
$searchFilter = acym_getVar('string', 'mails_search', '');
|
||||
$tagFilter = acym_getVar('string', 'mails_tag', '');
|
||||
$ordering = acym_getVar('string', 'mails_ordering', 'id');
|
||||
$status = acym_getVar('string', 'mails_status', 'standard');
|
||||
$orderingSortOrder = acym_getVar('string', 'mails_ordering_sort_order', 'desc');
|
||||
|
||||
$mailsPerPage = 12;
|
||||
$page = acym_getVar('int', 'mails_pagination_page', 1);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$matchingMails = $mailClass->getMatchingMails(
|
||||
[
|
||||
'ordering' => $ordering,
|
||||
'search' => $searchFilter,
|
||||
'mailsPerPage' => $mailsPerPage,
|
||||
'offset' => ($page - 1) * $mailsPerPage,
|
||||
'tag' => $tagFilter,
|
||||
'status' => $status,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
]
|
||||
);
|
||||
|
||||
$matchingMailsNb = count($matchingMails['mails']);
|
||||
|
||||
if (empty($matchingMailsNb)) {
|
||||
if ($page > 1) {
|
||||
acym_setVar('mails_pagination_page', 1);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
} elseif (!empty($status)) {
|
||||
acym_setVar('mails_status', '');
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingMails['total'], $page, $mailsPerPage);
|
||||
|
||||
foreach ($matchingMails['mails'] as $oneTemplate) {
|
||||
if (empty($oneTemplate->thumbnail)) {
|
||||
$oneTemplate->thumbnail = ACYM_IMAGES.'default_template_thumbnail.png';
|
||||
}
|
||||
}
|
||||
|
||||
$mailsData = [
|
||||
'allMails' => $matchingMails['mails'],
|
||||
'allTags' => acym_get('class.tag')->getAllTagsByType('mail'),
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'ordering' => $ordering,
|
||||
'status' => $status,
|
||||
'mailNumberPerStatus' => $matchingMails['status'],
|
||||
'orderingSortOrder' => $orderingSortOrder,
|
||||
];
|
||||
parent::display($mailsData);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function choose()
|
||||
{
|
||||
acym_setVar("layout", "choose");
|
||||
|
||||
$this->breadcrumb[acym_translation('ACYM_CREATE')] = "";
|
||||
|
||||
$searchFilter = acym_getVar('string', 'mailchoose_search', '');
|
||||
$tagFilter = acym_getVar('string', 'mailchoose_tag', 0);
|
||||
$ordering = acym_getVar('string', 'mailchoose_ordering', 'creation_date');
|
||||
$orderingSortOrder = acym_getVar('string', 'mailchoose_ordering_sort_order', 'DESC');
|
||||
$type = acym_getVar('string', 'mailchoose_type', 'custom');
|
||||
|
||||
$mailsPerPage = 12;
|
||||
$page = acym_getVar('int', 'mailchoose_pagination_page', 1);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$matchingMails = $mailClass->getMatchingMails(
|
||||
[
|
||||
'ordering' => $ordering,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
'search' => $searchFilter,
|
||||
'mailsPerPage' => $mailsPerPage,
|
||||
'offset' => ($page - 1) * $mailsPerPage,
|
||||
'tag' => $tagFilter,
|
||||
'type' => $type,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingMails['total'], $page, $mailsPerPage);
|
||||
|
||||
foreach ($matchingMails['mails'] as $oneTemplate) {
|
||||
if (empty($oneTemplate->thumbnail)) {
|
||||
$oneTemplate->thumbnail = ACYM_IMAGES.'default_template_thumbnail.png';
|
||||
}
|
||||
}
|
||||
|
||||
$mailsData = [
|
||||
'allMails' => $matchingMails['mails'],
|
||||
'allTags' => acym_get('class.tag')->getAllTagsByType('mail'),
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'ordering' => $ordering,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
|
||||
parent::display($mailsData);
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$tempId = acym_getVar("int", "id");
|
||||
$mailClass = acym_get('class.mail');
|
||||
$typeEditor = acym_getVar('string', 'type_editor');
|
||||
$notification = acym_getVar("cmd", "notification");
|
||||
$return = acym_getVar('string', 'return', '');
|
||||
$return = empty($return) ? '' : urldecode($return);
|
||||
$type = acym_getVar('string', 'type');
|
||||
|
||||
if (!empty($notification)) {
|
||||
$mail = $mailClass->getOneByName($notification);
|
||||
if (!empty($mail->id)) {
|
||||
$tempId = $mail->id;
|
||||
}
|
||||
}
|
||||
|
||||
$isAutomationAdmin = false;
|
||||
|
||||
if (strpos($type, 'automation') !== false || empty($tempId)) {
|
||||
$fromId = acym_getVar("int", "from");
|
||||
if ($type == 'automation_admin') {
|
||||
$type = 'automation';
|
||||
$isAutomationAdmin = true;
|
||||
}
|
||||
|
||||
if (empty($fromId)) {
|
||||
$mail = new stdClass();
|
||||
$mail->name = '';
|
||||
$mail->subject = '';
|
||||
$mail->preheader = '';
|
||||
$mail->tags = [];
|
||||
$mail->type = '';
|
||||
$mail->body = '';
|
||||
$mail->editor = 'automation' == $type ? 'acyEditor' : $typeEditor;
|
||||
$mail->headers = '';
|
||||
$mail->thumbnail = null;
|
||||
} else {
|
||||
$mail = $mailClass->getOneById($fromId);
|
||||
if (0 == $mail->drag_editor) {
|
||||
$mail->editor = 'html';
|
||||
} else {
|
||||
$mail->editor = !empty($typeEditor) ? $typeEditor : 'acyEditor';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($type)) $mail->type = $type;
|
||||
|
||||
if ('automation' != $type || empty($fromId)) $mail->id = 0;
|
||||
$this->breadcrumb[acym_translation('automation' != $type ? 'ACYM_CREATE_TEMPLATE' : 'ACYM_NEW_EMAIL')] = acym_completeLink('mails&task=edit&type_editor='.$typeEditor.(!empty($fromId) ? '&from='.$fromId : '').'&type='.$type.(!empty($return) ? '&return='.urlencode($return) : ''));
|
||||
} else {
|
||||
$mail = $mailClass->getOneById($tempId);
|
||||
$mail->editor = $mail->drag_editor == 0 ? 'html' : 'acyEditor';
|
||||
if (!empty($typeEditor)) $mail->editor = $typeEditor;
|
||||
|
||||
if (empty($notification)) {
|
||||
$this->breadcrumb[acym_escape($mail->name)] = acym_completeLink('mails&task=edit&id='.$mail->id);
|
||||
} else {
|
||||
if (empty($return)) {
|
||||
$return = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
$notifName = acym_translation('ACYM_NOTIFICATIION_'.strtoupper(substr($mail->name, 4)));
|
||||
if (strpos($notifName, 'ACYM_NOTIFICATIION_') !== false) {
|
||||
$notifName = $mail->name;
|
||||
}
|
||||
$this->breadcrumb[acym_escape($notifName)] = acym_completeLink('mails&task=edit¬ification='.$mail->name.'&return='.urlencode($return));
|
||||
}
|
||||
|
||||
|
||||
if (strpos($mail->stylesheet, '[class="') !== false) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_WARNING_STYLESHEET_NOT_CORRECT'), 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
$data = [
|
||||
"mail" => $mail,
|
||||
'allTags' => acym_get('class.tag')->getAllTagsByType('mail'),
|
||||
'config' => acym_config(),
|
||||
'isAutomationAdmin' => $isAutomationAdmin,
|
||||
'social_icons' => $config->get('social_icons', '{}'),
|
||||
];
|
||||
|
||||
if (!empty($return)) $data['return'] = $return;
|
||||
|
||||
acym_setVar("layout", "edit");
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function editor_wysid()
|
||||
{
|
||||
acym_setVar("layout", "editor_wysid");
|
||||
|
||||
parent::display();
|
||||
}
|
||||
|
||||
public function store($ajax = false)
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$formData = acym_getVar('array', 'mail', []);
|
||||
$mail = new stdClass();
|
||||
$allowedFields = acym_getColumns('mail');
|
||||
$return = acym_getVar('string', 'return');
|
||||
$fromAutomation = false;
|
||||
if (!empty($return) && strpos($return, 'automation') !== false) $fromAutomation = true;
|
||||
foreach ($formData as $name => $data) {
|
||||
if (!in_array($name, $allowedFields)) {
|
||||
continue;
|
||||
}
|
||||
$mail->{$name} = $data;
|
||||
}
|
||||
|
||||
if ($fromAutomation) {
|
||||
acym_setVar('from', $mail->id);
|
||||
acym_setVar('type', 'automation');
|
||||
acym_setVar('type_editor', 'acyEditor');
|
||||
}
|
||||
|
||||
if (empty($mail->subject) && !empty($mail->type) && $mail->type != 'standard') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mail->tags = acym_getVar("array", "template_tags", []);
|
||||
$mail->body = acym_getVar('string', 'editor_content', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
$mail->settings = acym_getVar('string', 'editor_settings', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
$mail->stylesheet = acym_getVar('string', 'editor_stylesheet', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
$mail->headers = acym_getVar('string', 'editor_headers', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
$mail->thumbnail = $fromAutomation ? '' : acym_getVar('string', 'editor_thumbnail', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
$mail->template = $fromAutomation ? 2 : 1;
|
||||
$mail->library = 0;
|
||||
$mail->drag_editor = strpos($mail->body, 'acym__wysid__template') === false ? 0 : 1;
|
||||
if ($fromAutomation) $mail->type = 'automation';
|
||||
if (empty($mail->id)) {
|
||||
$mail->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
}
|
||||
$mailID = $mailClass->save($mail);
|
||||
if (!empty($mailID)) {
|
||||
if (!$ajax) acym_enqueueNotification(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success', 8000);
|
||||
if ($fromAutomation) {
|
||||
acym_setVar('from', $mailID);
|
||||
acym_setVar('type', 'automation');
|
||||
acym_setVar('type_editor', 'acyEditor');
|
||||
} else {
|
||||
acym_setVar('mailID', $mailID);
|
||||
}
|
||||
|
||||
return $mailID;
|
||||
} else {
|
||||
if (!$ajax) acym_enqueueNotification(acym_translation('ACYM_ERROR_SAVING'), 'error', 0);
|
||||
if (!empty($mailClass->errors)) {
|
||||
if (!$ajax) acym_enqueueNotification($mailClass->errors, 'error', 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function apply()
|
||||
{
|
||||
$this->store();
|
||||
$mailId = acym_getVar('int', 'mailID', 0);
|
||||
acym_setVar('id', $mailId);
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$mailid = $this->store();
|
||||
|
||||
$return = str_replace('{mailid}', empty($mailid) ? '' : $mailid, acym_getVar('string', 'return'));
|
||||
if (empty($return)) {
|
||||
$this->listing();
|
||||
} else {
|
||||
acym_redirect($return);
|
||||
}
|
||||
}
|
||||
|
||||
public function autoSave()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = new stdClass();
|
||||
|
||||
$mail->id = acym_getVar('int', 'mailId', 0);
|
||||
$mail->autosave = acym_getVar('string', 'autoSave', '', 'REQUEST', ACYM_ALLOWRAW);
|
||||
|
||||
if (empty($mail->id) || !$mailClass->autoSave($mail)) {
|
||||
echo 'error';
|
||||
} else {
|
||||
echo 'saved';
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getTemplateAjax()
|
||||
{
|
||||
$searchFilter = acym_getVar('string', 'search', '');
|
||||
$tagFilter = acym_getVar('string', 'tag', 0);
|
||||
$ordering = 'creation_date';
|
||||
$orderingSortOrder = 'DESC';
|
||||
$type = acym_getVar('string', 'type', 'custom');
|
||||
$editor = acym_getVar('string', 'editor');
|
||||
$automation = acym_getVar('string', 'automation');
|
||||
|
||||
$mailsPerPage = 12;
|
||||
$page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$page != 'undefined' ? : $page = '1';
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$matchingMails = $mailClass->getMatchingMails(
|
||||
[
|
||||
'ordering' => $ordering,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
'search' => $searchFilter,
|
||||
'mailsPerPage' => $mailsPerPage,
|
||||
'offset' => ($page - 1) * $mailsPerPage,
|
||||
'tag' => $tagFilter,
|
||||
'type' => $type,
|
||||
'editor' => $editor,
|
||||
'automation' => $automation,
|
||||
]
|
||||
);
|
||||
|
||||
$return = '<div class="grid-x grid-padding-x grid-padding-y grid-margin-x grid-margin-y xxlarge-up-6 large-up-4 medium-up-3 small-up-1 cell acym__template__choose__list">';
|
||||
|
||||
foreach ($matchingMails['mails'] as $oneTemplate) {
|
||||
if (empty($oneTemplate->thumbnail)) {
|
||||
$oneTemplate->thumbnail = ACYM_IMAGES.'default_template_thumbnail.png';
|
||||
}
|
||||
|
||||
$return .= '<div class="cell grid-x acym__templates__oneTpl acym__listing__block" id="'.acym_escape($oneTemplate->id).'">
|
||||
<div class="cell acym__templates__pic text-center">';
|
||||
|
||||
$thumbnail = $oneTemplate->thumbnail;
|
||||
if (strpos($oneTemplate->thumbnail, 'default_template') === false) {
|
||||
$thumbnail = ACYM_TEMPLATE_THUMBNAILS.$oneTemplate->thumbnail;
|
||||
}
|
||||
|
||||
$url = acym_getVar('cmd', 'ctrl').'&task=edit&step=editEmail&from='.intval($oneTemplate->id);
|
||||
if (!empty($this->data['campaignInformation'])) $url .= '&id='.intval($this->data['campaignInformation']);
|
||||
$return .= '<a href="'.acym_completeLink($url, false, false, true).'">';
|
||||
|
||||
|
||||
$return .= '<img src="'.acym_escape($thumbnail).'" alt="template thumbnail"/>';
|
||||
$return .= '</a>';
|
||||
if ($oneTemplate->drag_editor) {
|
||||
$return .= '<div class="acym__templates__choose__ribbon ribbon">
|
||||
<div class="acym__templates__choose__ribbon__label acym__color__white acym__background-color__blue">AcyEditor</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (strlen($oneTemplate->name) > 55) {
|
||||
$oneTemplate->name = substr($oneTemplate->name, 0, 50).'...';
|
||||
}
|
||||
$return .= '</div>
|
||||
<div class="cell grid-x acym__templates__footer text-center">
|
||||
<div class="cell acym__templates__footer__title" title="'.acym_escape($oneTemplate->name).'">'.acym_escape($oneTemplate->name).'</div>
|
||||
<div class="cell">'.acym_date($oneTemplate->creation_date, 'M. j, Y').'</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$return .= '</div>';
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingMails['total'], $page, $mailsPerPage);
|
||||
|
||||
$return .= $pagination->displayAjax();
|
||||
|
||||
echo $return;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getMailContent()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$from = acym_getVar('string', 'from', '');
|
||||
|
||||
if (empty($from)) {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
$echo = $mailClass->getOneById($from);
|
||||
|
||||
if ($echo->drag_editor == 0) {
|
||||
echo 'no_new_editor';
|
||||
exit;
|
||||
}
|
||||
|
||||
$echo = ['mailSettings' => $echo->settings, 'content' => $echo->body, 'stylesheet' => $echo->stylesheet];
|
||||
|
||||
$echo = json_encode($echo);
|
||||
|
||||
echo $echo;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->store();
|
||||
$mailId = acym_getVar('int', 'mailID', 0);
|
||||
acym_setVar('id', $mailId);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = $mailClass->getOneById($mailId);
|
||||
|
||||
if (empty($mail)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_CAMPAIGN_NOT_FOUND'), 'error', 5000);
|
||||
$this->edit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$mailerHelper = acym_get('helper.mailer');
|
||||
$mailerHelper->autoAddUser = true;
|
||||
$mailerHelper->checkConfirmField = false;
|
||||
$mailerHelper->report = false;
|
||||
|
||||
$currentEmail = acym_currentUserEmail();
|
||||
if ($mailerHelper->sendOne($mailId, $currentEmail)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_SEND_SUCCESS', $mail->name, $currentEmail), 'info', 5000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_SEND_ERROR', $mail->name, $currentEmail), 'error', 5000);
|
||||
}
|
||||
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function setNewThumbnail()
|
||||
{
|
||||
acym_checkToken();
|
||||
$contentThumbnail = acym_getVar('string', 'content', '');
|
||||
$file = acym_getVar('string', 'thumbnail', '');
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
if (empty($file) || strpos($file, 'http') === 0) {
|
||||
$thumbNb = $config->get('numberThumbnail', 2);
|
||||
$file = 'thumbnail_'.($thumbNb + 1).'.png';
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->numberThumbnail = $thumbNb + 1;
|
||||
$config->save($newConfig);
|
||||
}
|
||||
|
||||
$extension = acym_fileGetExt($file);
|
||||
if (strpos($file, 'thumbnail_') === false || !in_array($extension, ['png', 'jpeg', 'jpg', 'gif'])) exit;
|
||||
|
||||
acym_createFolder(ACYM_UPLOAD_FOLDER_THUMBNAIL);
|
||||
file_put_contents(ACYM_UPLOAD_FOLDER_THUMBNAIL.$file, base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $contentThumbnail)));
|
||||
echo $file;
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function loadCSS()
|
||||
{
|
||||
$idMail = acym_getVar('int', 'id', 0);
|
||||
if (empty($idMail)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = $mailClass->getOneById($idMail);
|
||||
|
||||
echo $mailClass->buildCSS($mail->stylesheet);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function doUploadTemplate()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailClass->doupload();
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function setNewIconShare()
|
||||
{
|
||||
$socialName = acym_getVar('string', 'social', '');
|
||||
$extension = pathinfo($_FILES['file']['name']);
|
||||
$newPath = ACYM_UPLOAD_FOLDER.'socials'.DS.$socialName.'.'.$extension['extension'];
|
||||
|
||||
if (!acym_uploadFile($_FILES['file']['tmp_name'], ACYM_ROOT.$newPath) || empty($socialName)) {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->social_icons = json_decode($config->get('social_icons', '{}'), true);
|
||||
|
||||
$newImg = acym_rootURI().$newPath;
|
||||
|
||||
$newConfig->social_icons[$socialName] = $newImg;
|
||||
$newConfig->social_icons = json_encode($newConfig->social_icons);
|
||||
$config->save($newConfig);
|
||||
|
||||
echo $newImg;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function deleteMailAutomation()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailId = acym_getVar('int', 'id', 0);
|
||||
|
||||
if (!empty($mailId)) $mailClass->delete($mailId);
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function duplicateMailAutomation()
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailId = acym_getVar('int', 'id', 0);
|
||||
$prevMail = acym_getVar('int', 'previousId');
|
||||
|
||||
if (!empty($prevMail)) $mailClass->delete($prevMail);
|
||||
|
||||
if (empty($mailId)) {
|
||||
echo json_encode(['error' => acym_translation_sprintf('ACYM_NOT_FOUND', acym_translation('ACYM_ID'))]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$mail = $mailClass->getOneById($mailId);
|
||||
|
||||
if (empty($mail)) {
|
||||
echo json_encode(['error' => acym_translation_sprintf('ACYM_NOT_FOUND', acym_translation('ACYM_EMAIL'))]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$newMail = new stdClass();
|
||||
$newMail->name = $mail->name.'_copy';
|
||||
$newMail->thumbnail = '';
|
||||
$newMail->type = 'automation';
|
||||
$newMail->drag_editor = $mail->drag_editor;
|
||||
$newMail->library = 0;
|
||||
$newMail->body = $mail->body;
|
||||
$newMail->subject = $mail->subject;
|
||||
$newMail->template = 2;
|
||||
$newMail->from_name = $mail->from_name;
|
||||
$newMail->from_email = $mail->from_email;
|
||||
$newMail->reply_to_name = $mail->reply_to_name;
|
||||
$newMail->reply_to_email = $mail->reply_to_email;
|
||||
$newMail->bcc = $mail->bcc;
|
||||
$newMail->settings = $mail->settings;
|
||||
$newMail->stylesheet = $mail->stylesheet;
|
||||
$newMail->attachments = $mail->attachments;
|
||||
$newMail->headers = $mail->headers;
|
||||
|
||||
$newMail->id = $mailClass->save($newMail);
|
||||
|
||||
if (empty($newMail->id)) {
|
||||
echo json_encode(['error' => acym_translation('ACYM_COULD_NOT_DUPLICATE_EMAIL')]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($newMail);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function saveAjax()
|
||||
{
|
||||
$return = $this->store(true);
|
||||
echo json_encode(['error' => !$return ? acym_translation('ACYM_ERROR_SAVING') : '', 'data' => $return]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 QueueController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_QUEUE')] = acym_completeLink('queue');
|
||||
$this->setDefaultTask('campaigns');
|
||||
}
|
||||
|
||||
public function campaigns()
|
||||
{
|
||||
acym_setVar('layout', 'campaigns');
|
||||
|
||||
$config = acym_config();
|
||||
if (acym_level(1) && $config->get('cron_last', 0) < (time() - 43200)){
|
||||
acym_enqueueMessage(acym_translation('ACYM_CREATE_CRON_REMINDER').' <a id="acym__queue__configure-cron" href="'.acym_completeLink('configuration&tab=queue').'">'.acym_translation('ACYM_GOTO_CONFIG').'</a>', 'warning');
|
||||
}
|
||||
|
||||
$searchFilter = acym_getVar('string', 'cqueue_search', '');
|
||||
$tagFilter = acym_getVar('string', 'cqueue_tag', '');
|
||||
$status = acym_getVar('string', 'cqueue_status', '');
|
||||
|
||||
$campaignsPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'cqueue_pagination_page', 1);
|
||||
|
||||
$queueClass = acym_get('class.queue');
|
||||
$matchingElements = $queueClass->getMatchingCampaigns(
|
||||
[
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'status' => $status,
|
||||
'campaignsPerPage' => $campaignsPerPage,
|
||||
'offset' => ($page - 1) * $campaignsPerPage,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingElements['total'], $page, $campaignsPerPage);
|
||||
|
||||
$viewData = [
|
||||
'allElements' => $matchingElements['elements'],
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'tags' => acym_get('class.tag')->getAllTagsByType('mail'),
|
||||
'numberPerStatus' => $matchingElements['status'],
|
||||
'status' => $status,
|
||||
];
|
||||
|
||||
$this->breadcrumb[acym_translation('ACYM_CAMPAIGNS')] = acym_completeLink('queue');
|
||||
parent::display($viewData);
|
||||
}
|
||||
|
||||
public function automated()
|
||||
{
|
||||
}
|
||||
|
||||
public function detailed()
|
||||
{
|
||||
acym_setVar("layout", "detailed");
|
||||
|
||||
$searchFilter = acym_getVar('string', 'dqueue_search', '');
|
||||
$tagFilter = acym_getVar('string', 'dqueue_tag', '');
|
||||
|
||||
$elementsPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'dqueue_pagination_page', 1);
|
||||
|
||||
$queueClass = acym_get('class.queue');
|
||||
$matchingElements = $queueClass->getMatchingResults(
|
||||
[
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'elementsPerPage' => $elementsPerPage,
|
||||
'offset' => ($page - 1) * $elementsPerPage,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingElements['total'], $page, $elementsPerPage);
|
||||
|
||||
$viewData = [
|
||||
'allElements' => $matchingElements['elements'],
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'tag' => $tagFilter,
|
||||
'tags' => acym_get('class.tag')->getAllTagsByType('mail'),
|
||||
];
|
||||
|
||||
$this->breadcrumb[acym_translation('ACYM_QUEUE_DETAILED')] = acym_completeLink('queue&task=detailed');
|
||||
parent::display($viewData);
|
||||
}
|
||||
|
||||
public function scheduleReady()
|
||||
{
|
||||
$queueClass = acym_get('class.queue');
|
||||
$queueClass->scheduleReady();
|
||||
}
|
||||
|
||||
public function continuesend()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
if ($config->get('queue_type') == 'onlyauto') {
|
||||
acym_setNoTemplate();
|
||||
acym_display(acym_translation('ACYM_ONLYAUTOPROCESS'), 'warning');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$newcrontime = time() + 120;
|
||||
if ($config->get('cron_next') < $newcrontime) {
|
||||
$newValue = new stdClass();
|
||||
$newValue->cron_next = $newcrontime;
|
||||
$config->save($newValue);
|
||||
}
|
||||
|
||||
$mailid = acym_getCID('id');
|
||||
|
||||
$totalSend = acym_getVar('int', 'totalsend', 0);
|
||||
if (empty($totalSend)) {
|
||||
$query = 'SELECT COUNT(queue.user_id) FROM #__acym_queue AS queue LEFT JOIN #__acym_campaign AS campaign ON queue.mail_id = campaign.mail_id WHERE (campaign.id IS NULL OR campaign.active = 1) AND queue.sending_date < '.acym_escapeDB(acym_date('now', 'Y-m-d H:i:s', false));
|
||||
if (!empty($mailid)) {
|
||||
$query .= ' AND queue.mail_id = '.intval($mailid);
|
||||
}
|
||||
$totalSend = acym_loadResult($query);
|
||||
}
|
||||
|
||||
$alreadySent = acym_getVar('int', 'alreadysent', 0);
|
||||
|
||||
$helperQueue = acym_get('helper.queue');
|
||||
$helperQueue->id = $mailid;
|
||||
$helperQueue->report = true;
|
||||
$helperQueue->total = $totalSend;
|
||||
$helperQueue->start = $alreadySent;
|
||||
$helperQueue->pause = $config->get('queue_pause');
|
||||
$helperQueue->process();
|
||||
|
||||
acym_setNoTemplate();
|
||||
exit;
|
||||
}
|
||||
|
||||
public function cancelSending()
|
||||
{
|
||||
$mailId = acym_getVar('int', 'acym__queue__cancel__mail_id');
|
||||
|
||||
if (!empty($mailId)) {
|
||||
$hasStat = acym_loadResult("SELECT COUNT(*) FROM #__acym_user_stat WHERE mail_id = ".intval($mailId));
|
||||
|
||||
$result = [];
|
||||
|
||||
$result[] = acym_query('DELETE FROM #__acym_queue WHERE mail_id = '.intval($mailId));
|
||||
if (empty($hasStat)) {
|
||||
$result[] = acym_query('UPDATE #__acym_campaign SET draft = "1", sent = "0", sending_date = NULL WHERE mail_id = '.intval($mailId));
|
||||
$result[] = acym_query('DELETE FROM #__acym_mail_stat WHERE mail_id = '.intval($mailId));
|
||||
}
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_ERROR_QUEUE_CANCEL_CAMPAIGN"), "error", 10000);
|
||||
}
|
||||
$this->campaigns();
|
||||
}
|
||||
|
||||
public function playPauseSending()
|
||||
{
|
||||
$active = acym_getVar("int", "acym__queue__play_pause__active__new_value");
|
||||
$campaignId = acym_getVar("int", "acym__queue__play_pause__campaign_id");
|
||||
|
||||
if (!empty($campaignId)) {
|
||||
$queueClass = acym_get('class.queue');
|
||||
$queueClass->unpauseCampaign($campaignId, $active);
|
||||
} else {
|
||||
if (!empty($active)) {
|
||||
acym_enqueueNotification(acym_translation("ACYM_ERROR_QUEUE_RESUME"), "error", 10000);
|
||||
} else {
|
||||
acym_enqueueNotification(acym_translation("ACYM_ERROR_QUEUE_PAUSE"), "error", 10000);
|
||||
}
|
||||
}
|
||||
|
||||
$this->campaigns();
|
||||
}
|
||||
|
||||
public function emptyQueue()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$queueClass = acym_get('class.queue');
|
||||
$deleted = $queueClass->emptyQueue();
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_EMAILS_REMOVED_QUEUE', $deleted));
|
||||
|
||||
$this->campaigns();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,379 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 StatsController extends acymController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_STATISTICS')] = acym_completeLink('stats');
|
||||
$this->loadScripts = [
|
||||
'all' => ['datepicker'],
|
||||
];
|
||||
}
|
||||
|
||||
public function saveSendingStatUser($userId, $mailId, $sendDate = null)
|
||||
{
|
||||
$userStatClass = acym_get('class.userstat');
|
||||
|
||||
if ($sendDate == null) {
|
||||
$sendDate = acym_date();
|
||||
}
|
||||
|
||||
$userStat = new stdClass();
|
||||
$userStat->mail_id = $mailId;
|
||||
$userStat->user_id = $userId;
|
||||
$userStat->send_date = $sendDate;
|
||||
|
||||
$userStatClass->save($userStat);
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar("layout", "listing");
|
||||
|
||||
$selectedMail = acym_getVar('int', 'mail_id');
|
||||
$data = [];
|
||||
$campaignClass = acym_get('class.campaign');
|
||||
$mailStatsClass = acym_get('class.mailstat');
|
||||
$userStatClass = acym_get('class.userstat');
|
||||
$urlClickClass = acym_get('class.urlclick');
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mails = $mailStatsClass->getAllMailsForStats();
|
||||
$tab = acym_get('helper.tab');
|
||||
|
||||
$data['tab'] = $tab;
|
||||
|
||||
$ordering = acym_getVar('string', 'detailed_stats_ordering', 'send_date');
|
||||
$orderingSortOrder = acym_getVar('string', 'detailed_stats_ordering_sort_order', 'desc');
|
||||
$search = acym_getVar('string', 'detailed_stats_search', '');
|
||||
|
||||
$detailedStatsPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'detailed_stats_pagination_page', 1);
|
||||
|
||||
$matchingDetailedStats = $userStatClass->getDetailedStats(
|
||||
[
|
||||
'ordering' => $ordering,
|
||||
'search' => $search,
|
||||
'detailedStatsPerPage' => $detailedStatsPerPage,
|
||||
'offset' => ($page - 1) * $detailedStatsPerPage,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
'mail_id' => $selectedMail,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingDetailedStats['total'], $page, $detailedStatsPerPage);
|
||||
|
||||
$data['pagination'] = $pagination;
|
||||
$data['detailed_stats'] = $matchingDetailedStats['detailed_stats'];
|
||||
$data['search'] = $search;
|
||||
$data['ordering'] = $ordering;
|
||||
$data['orderingSortOrder'] = $orderingSortOrder;
|
||||
$data['selectedCampaingDetailedStats'] = $selectedMail;
|
||||
|
||||
if (empty($mails)) {
|
||||
$data['emptyGlobal'] = empty($selectedMail) ? 'campaigns' : 'stats';
|
||||
}
|
||||
|
||||
if (empty($matchingDetailedStats['detailed_stats'])) {
|
||||
$data['emptyDetailed'] = empty($selectedMail) ? 'campaigns' : 'stats';
|
||||
}
|
||||
|
||||
$data['mails'] = [];
|
||||
|
||||
foreach ($mails as $mail) {
|
||||
if ((empty($mail->name) || empty($mail->id) && $mail->sent != 1)) {
|
||||
continue;
|
||||
}
|
||||
$newMail = new stdClass();
|
||||
$newMail->name = $mail->name;
|
||||
$newMail->value = $mail->id;
|
||||
$data['mails'][] = $newMail;
|
||||
}
|
||||
$data['selectedMailid'] = empty($selectedMail) ? '' : $selectedMail;
|
||||
|
||||
if (!empty($selectedMail)) {
|
||||
$data['selectedMailid'] = $selectedMail;
|
||||
$allClickInfo = $urlClickClass->getAllLinkFromEmail($selectedMail);
|
||||
$data['url_click'] = [];
|
||||
$allPercentage = [];
|
||||
foreach ($allClickInfo['urls_click'] as $url) {
|
||||
$percentage = 0;
|
||||
if (empty($url->click)) {
|
||||
$data['url_click'][$url->name] = ['percentage' => $percentage, 'numberClick' => '0'];
|
||||
} else {
|
||||
$percentage = intval(($url->click * 100) / $allClickInfo['allClick']);
|
||||
$data['url_click'][$url->name] = ['percentage' => $percentage, 'numberClick' => $url->click];
|
||||
}
|
||||
$allPercentage[] = $percentage;
|
||||
}
|
||||
$data['mailInformation'] = $mailClass->getOneById($selectedMail);
|
||||
$data['mailInformation']->body = $this->_replaceLink($data['mailInformation']->body);
|
||||
$data['url_click']['allClick'] = $allClickInfo['allClick'];
|
||||
if (!empty($allPercentage)) {
|
||||
$maxPercentage = max($allPercentage);
|
||||
|
||||
foreach ($data['url_click'] as $name => $val) {
|
||||
if ($name === 'allClick') continue;
|
||||
$percentageRecalc = intval(($val['percentage'] * 100) / $maxPercentage);
|
||||
if ($percentageRecalc <= 33) {
|
||||
$data['url_click'][$name]['color'] = '0, 164, 255';
|
||||
} elseif ($percentageRecalc <= 66) {
|
||||
$data['url_click'][$name]['color'] = '248, 31, 255';
|
||||
} else {
|
||||
$data['url_click'][$name]['color'] = '255, 82, 89';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['url_click'] = acym_escape(json_encode($data['url_click']));
|
||||
}
|
||||
|
||||
$statsMailSelected = $mailStatsClass->getOneByMailId($data['selectedMailid']);
|
||||
|
||||
if (empty($statsMailSelected)) {
|
||||
$data['empty'] = empty($data['selectedMailid']) ? 'campaigns' : 'stats';
|
||||
}
|
||||
|
||||
if (empty($statsMailSelected->sent)) {
|
||||
$data['empty'] = 'stats';
|
||||
}
|
||||
|
||||
$statsMailSelected->totalMail = $statsMailSelected->sent + $statsMailSelected->fail;
|
||||
$statsMailSelected->pourcentageSent = empty($statsMailSelected->totalMail) ? 0 : intval(($statsMailSelected->sent * 100) / $statsMailSelected->totalMail);
|
||||
$statsMailSelected->allSent = empty($statsMailSelected->totalMail) ? acym_translation_sprintf('ACYM_X_MAIL_SUCCESSFULLY_SENT_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_SUCCESSFULLY_SENT_OF_X', $statsMailSelected->sent, $statsMailSelected->totalMail);
|
||||
|
||||
$openRateCampaign = empty($data['selectedMailid']) ? $campaignClass->getOpenRateAllCampaign() : $campaignClass->getOpenRateOneCampaign($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageOpen = empty($openRateCampaign->sent) ? 0 : intval(($openRateCampaign->open_unique * 100) / $openRateCampaign->sent);
|
||||
$statsMailSelected->allOpen = empty($openRateCampaign->sent) ? acym_translation_sprintf('ACYM_X_MAIL_OPENED_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_OPENED_OF_X', $openRateCampaign->open_unique, $openRateCampaign->sent);
|
||||
|
||||
$clickRateCampaign = $urlClickClass->getClickRate($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageClick = empty($statsMailSelected->sent) ? 0 : intval(($clickRateCampaign->click * 100) / $statsMailSelected->sent);
|
||||
$statsMailSelected->allClick = empty($statsMailSelected->sent) ? acym_translation_sprintf('ACYM_X_MAIL_CLICKED_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_MAIL_CLICKED_OF_X', $clickRateCampaign->click, $statsMailSelected->sent);
|
||||
|
||||
$bounceRateCampaign = empty($data['selectedMailid']) ? $campaignClass->getBounceRateAllCampaign() : $campaignClass->getBounceRateOneCampaign($data['selectedMailid']);
|
||||
$statsMailSelected->pourcentageBounce = empty($statsMailSelected->sent) ? 0 : intval(($bounceRateCampaign->bounce_unique * 100) / $statsMailSelected->sent);
|
||||
$statsMailSelected->allBounce = empty($statsMailSelected->sent) ? acym_translation_sprintf('ACYM_X_BOUNCE_OF_X', 0, 0) : acym_translation_sprintf('ACYM_X_BOUNCE_OF_X', $bounceRateCampaign->bounce_unique, $statsMailSelected->sent);
|
||||
|
||||
$this->_timeData($statsMailSelected, $data['selectedMailid']);
|
||||
|
||||
if ($statsMailSelected->empty) {
|
||||
$data['stats_mail_1'] = $statsMailSelected;
|
||||
|
||||
parent::display($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$allHour = array_keys($statsMailSelected->hour);
|
||||
|
||||
$statsMailSelected->startEndDateHour = [];
|
||||
$statsMailSelected->startEndDateHour['start'] = $allHour[0];
|
||||
$statsMailSelected->startEndDateHour['end'] = end($allHour);
|
||||
|
||||
$data['stats_mail_1'] = $statsMailSelected;
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
private function _replaceLink($body)
|
||||
{
|
||||
$urlClass = acym_get('class.url');
|
||||
|
||||
if ($urlClass === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$urls = [];
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
preg_match_all('#href[ ]*=[ ]*"(?!mailto:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:|tel:)([^"]+)"#Ui', $body, $results);
|
||||
|
||||
if (empty($results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$countLinks = array_count_values($results[1]);
|
||||
if (array_product($countLinks) != 1) {
|
||||
foreach ($results[1] as $key => $url) {
|
||||
if ($countLinks[$url] == 1) {
|
||||
continue;
|
||||
}
|
||||
$countLinks[$url]--;
|
||||
|
||||
$toAddUrl = (strpos($url, '?') === false ? '?' : '&').'idU='.$countLinks[$url];
|
||||
|
||||
$posHash = strpos($url, '#');
|
||||
if ($posHash !== false) {
|
||||
$newURL = substr($url, 0, $posHash).$toAddUrl.substr($url, $posHash);
|
||||
} else {
|
||||
$newURL = $url.$toAddUrl;
|
||||
}
|
||||
|
||||
$body = preg_replace('#href="('.preg_quote($url, '#').')"#Uis', 'href="'.$newURL.'"', $body, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function setDataForChartLine()
|
||||
{
|
||||
$newStart = acym_date(acym_getVar('string', 'start'), 'Y-m-d H:i:s');
|
||||
$newEnd = acym_date(acym_getVar('string', 'end'), 'Y-m-d H:i:s');
|
||||
$mailIdOfCampaign = acym_getVar('int', 'id');
|
||||
|
||||
if ($newStart >= $newEnd) {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
|
||||
$statsCampaignSelected = new stdClass();
|
||||
|
||||
$this->_timeData($statsCampaignSelected, $mailIdOfCampaign, $newStart, $newEnd);
|
||||
|
||||
echo acym_line_chart('', $statsCampaignSelected->month, $statsCampaignSelected->day, $statsCampaignSelected->hour);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
private function _timeData(&$statsCampaignSelected, $mailIdOfCampaign, $newStart = '', $newEnd = '')
|
||||
{
|
||||
$urlClickClass = acym_get('class.urlclick');
|
||||
$campaignClass = acym_get('class.campaign');
|
||||
$statsCampaignSelected->empty = false;
|
||||
|
||||
|
||||
$campaignOpenByMonth = $campaignClass->getOpenByMonth($mailIdOfCampaign, $newStart, $newEnd);
|
||||
$campaignOpenByDay = $campaignClass->getOpenByDay($mailIdOfCampaign, $newStart, $newEnd);
|
||||
$campaignOpenByHour = $campaignClass->getOpenByHour($mailIdOfCampaign, $newStart, $newEnd);
|
||||
|
||||
$campaignClickByMonth = $urlClickClass->getAllClickByMailMonth($mailIdOfCampaign, $newStart, $newEnd);
|
||||
$campaignClickByDay = $urlClickClass->getAllClickByMailDay($mailIdOfCampaign, $newStart, $newEnd);
|
||||
$campaignClickByHour = $urlClickClass->getAllClickByMailHour($mailIdOfCampaign, $newStart, $newEnd);
|
||||
|
||||
if (empty($campaignOpenByMonth) || empty($campaignOpenByDay) || empty($campaignOpenByHour)) {
|
||||
$statsCampaignSelected->empty = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#To get all the month between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByMonth) ? $campaignOpenByMonth[0]->open_date : min([$campaignOpenByMonth[0]->open_date, $campaignClickByMonth[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByMonth) ? end($campaignOpenByMonth)->open_date : max([end($campaignOpenByMonth)->open_date, end($campaignClickByMonth)->date_click]));
|
||||
|
||||
$end->modify('+1 day');
|
||||
|
||||
$interval = new DateInterval('P1M');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeMonth = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeMonth[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
#To get all the day between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByDay) ? $campaignOpenByDay[0]->open_date : min([$campaignOpenByDay[0]->open_date, $campaignClickByDay[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByDay) ? end($campaignOpenByDay)->open_date : max([end($campaignOpenByDay)->open_date, end($campaignClickByDay)->date_click]));
|
||||
|
||||
$end->modify('+1 hour');
|
||||
|
||||
$interval = new DateInterval('P1D');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeDay = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeDay[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
|
||||
#To get all the hour between the first open date and the last
|
||||
$begin = new DateTime(empty($campaignClickByHour) ? $campaignOpenByHour[0]->open_date : min([$campaignOpenByHour[0]->open_date, $campaignClickByHour[0]->date_click]));
|
||||
$end = new DateTime(empty($campaignClickByHour) ? end($campaignOpenByHour)->open_date : max([end($campaignOpenByHour)->open_date, end($campaignClickByHour)->date_click]));
|
||||
|
||||
$end->modify('+1 min');
|
||||
|
||||
$interval = new DateInterval('PT1H');
|
||||
$daterange = new DatePeriod($begin, $interval, $end);
|
||||
|
||||
$rangeHour = [];
|
||||
|
||||
foreach ($daterange as $date) {
|
||||
$rangeHour[] = acym_getTime($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$openMonthArray = [];
|
||||
$openDayArray = [];
|
||||
$openHourArray = [];
|
||||
|
||||
foreach ($campaignOpenByMonth as $one) {
|
||||
$openMonthArray[acym_date(acym_getTime($one->open_date), 'M Y')] = $one->open;
|
||||
}
|
||||
|
||||
foreach ($campaignOpenByDay as $one) {
|
||||
$openDayArray[acym_date(acym_getTime($one->open_date), 'd M Y')] = $one->open;
|
||||
}
|
||||
|
||||
foreach ($campaignOpenByHour as $one) {
|
||||
$openHourArray[acym_date(acym_getTime($one->open_date), 'd M Y H')] = $one->open;
|
||||
}
|
||||
|
||||
$clickMonthArray = [];
|
||||
$clickDayArray = [];
|
||||
$clickHourArray = [];
|
||||
|
||||
foreach ($campaignClickByMonth as $one) {
|
||||
$clickMonthArray[acym_date(acym_getTime($one->date_click), 'M Y')] = $one->click;
|
||||
}
|
||||
|
||||
foreach ($campaignClickByDay as $one) {
|
||||
$clickDayArray[acym_date(acym_getTime($one->date_click), 'd M Y')] = $one->click;
|
||||
}
|
||||
|
||||
foreach ($campaignClickByHour as $one) {
|
||||
$clickHourArray[acym_date(acym_getTime($one->date_click), 'd M Y H')] = $one->click;
|
||||
}
|
||||
|
||||
$statsCampaignSelected->month = [];
|
||||
foreach ($rangeMonth as $one) {
|
||||
$one = acym_date($one, 'M Y');
|
||||
$currentMonth = [];
|
||||
$currentMonth['open'] = empty($openMonthArray[$one]) ? 0 : $openMonthArray[$one];
|
||||
$currentMonth['click'] = empty($clickMonthArray[$one]) ? 0 : $clickMonthArray[$one];
|
||||
$statsCampaignSelected->month[$one] = $currentMonth;
|
||||
}
|
||||
|
||||
$statsCampaignSelected->day = [];
|
||||
foreach ($rangeDay as $one) {
|
||||
$one = acym_date($one, 'd M Y');
|
||||
$currentDay = [];
|
||||
$currentDay['open'] = empty($openDayArray[$one]) ? 0 : $openDayArray[$one];
|
||||
$currentDay['click'] = empty($clickDayArray[$one]) ? 0 : $clickDayArray[$one];
|
||||
$statsCampaignSelected->day[$one] = $currentDay;
|
||||
}
|
||||
|
||||
$statsCampaignSelected->hour = [];
|
||||
foreach ($rangeHour as $one) {
|
||||
$one = acym_date($one, 'd M Y H');
|
||||
$currentHour = [];
|
||||
$currentHour['open'] = empty($openHourArray[$one]) ? 0 : $openHourArray[$one];
|
||||
$currentHour['click'] = empty($clickHourArray[$one]) ? 0 : $clickHourArray[$one];
|
||||
$statsCampaignSelected->hour[$one.':00'] = $currentHour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 ToggleController extends acymController
|
||||
{
|
||||
var $toggleableColumns = [];
|
||||
var $icons = [];
|
||||
var $deletableRows = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->defaulttask = 'toggle';
|
||||
|
||||
$this->toggleableColumns['automation'] = ['active' => 'id'];
|
||||
$this->toggleableColumns['campaign'] = ['active' => 'id'];
|
||||
$this->toggleableColumns['field'] = ['active' => 'id', 'required' => 'id', 'backend_profile' => 'id', 'backend_listing' => 'id', 'frontend_profile' => 'id', 'frontend_listing' => 'id'];
|
||||
$this->toggleableColumns['list'] = ['active' => 'id', 'visible' => 'id'];
|
||||
$this->toggleableColumns['rule'] = ['active' => 'id'];
|
||||
$this->toggleableColumns['user'] = ['active' => 'id', 'confirmed' => 'id'];
|
||||
|
||||
$this->icons['automation']['active'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['automation']['active'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['campaign']['active'][0] = 'fa fa-play-circle-o';
|
||||
$this->icons['campaign']['active'][1] = 'fa fa-pause-circle-o';
|
||||
$this->icons['field']['active'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['active'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['field']['required'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['required'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['field']['backend_profile'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['backend_profile'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['field']['backend_listing'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['backend_listing'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['field']['frontend_profile'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['frontend_profile'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['field']['frontend_listing'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['field']['frontend_listing'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['list']['active'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['list']['active'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['list']['visible'][1] = 'fa fa-eye';
|
||||
$this->icons['list']['visible'][0] = 'fa fa-eye-slash acym__color__dark-gray';
|
||||
$this->icons['rule']['active'][0] = 'fa fa-times-circle acym__color__red';
|
||||
$this->icons['rule']['active'][1] = 'fa fa-check-circle acym__color__green';
|
||||
$this->icons['user']['active'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['user']['active'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
$this->icons['user']['confirmed'][1] = 'fa fa-check-circle-o acym__color__green';
|
||||
$this->icons['user']['confirmed'][0] = 'fa fa-times-circle-o acym__color__red';
|
||||
|
||||
$this->deletableRows[] = 'list';
|
||||
$this->deletableRows[] = 'mail';
|
||||
$this->deletableRows[] = 'queue';
|
||||
|
||||
acym_noCache();
|
||||
}
|
||||
|
||||
public function toggle()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
|
||||
$table = acym_getVar('word', 'table', '');
|
||||
$field = acym_getVar('cmd', 'field', '');
|
||||
$id = acym_getVar('int', 'id', 0);
|
||||
$newValue = acym_getVar('int', 'value', 0);
|
||||
if (!empty($newValue)) {
|
||||
$newValue = 1;
|
||||
}
|
||||
|
||||
|
||||
if (empty($table) || empty($field) || empty($id) || empty($this->toggleableColumns[$table][$field])) {
|
||||
exit;
|
||||
}
|
||||
$pkey = $this->toggleableColumns[$table][$field];
|
||||
|
||||
$function = $table.$field;
|
||||
if (method_exists($this, $function)) {
|
||||
$this->$function($id, $newValue);
|
||||
} else {
|
||||
acym_query('UPDATE '.acym_secureDBColumn(ACYM_DBPREFIX.$table).' SET `'.acym_secureDBColumn($field).'` = '.intval($newValue).' WHERE `'.acym_secureDBColumn($pkey).'` = '.intval($id).' LIMIT 1');
|
||||
}
|
||||
|
||||
acym_trigger('onAcymToggle'.ucfirst($table).ucfirst($field), [&$id, &$newValue]);
|
||||
|
||||
|
||||
if (empty($this->icons[$table][$field][$newValue])) {
|
||||
echo 'test';
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$result['value'] = 1 - $newValue;
|
||||
$result['classes'] = 'acym_toggleable '.$this->icons[$table][$field][$newValue];
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$table = acym_getVar('word', 'table', '');
|
||||
$id = acym_getVar('cmd', 'id', 0);
|
||||
$method = acym_getVar('word', 'method', 'delete');
|
||||
|
||||
if (empty($table) || !in_array($table, $this->deletableRows) || empty($id)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$elementClass = acym_get('class.'.$table);
|
||||
$elementClass->$method($id);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getIntroJSConfig()
|
||||
{
|
||||
$config = acym_config();
|
||||
echo $config->get('introjs', '[]');
|
||||
exit;
|
||||
}
|
||||
|
||||
public function toggleIntroJS()
|
||||
{
|
||||
$config = acym_config();
|
||||
$toggleElement = acym_getVar('string', 'where');
|
||||
$intro = json_decode($config->get('introjs', '[]'), true);
|
||||
$intro[$toggleElement] = 1;
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->introjs = json_encode($intro);
|
||||
$config->save($newConfig);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function setDoNotRemindMe()
|
||||
{
|
||||
$newValue = acym_getVar('string', 'value');
|
||||
|
||||
$return = [];
|
||||
$return['error'] = '';
|
||||
|
||||
if (empty($newValue)) {
|
||||
$return['error'] = acym_translation('ACYM_ERROR_SAVING');
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
|
||||
$newConfig->remindme = json_decode($config->get('remindme', '[]'));
|
||||
if (!in_array($newValue, $newConfig->remindme)) array_push($newConfig->remindme, $newValue);
|
||||
$newConfig->remindme = json_encode($newConfig->remindme);
|
||||
|
||||
if ($config->save($newConfig)) {
|
||||
$return['message'] = acym_translation('ACYM_THANKS');
|
||||
} else {
|
||||
$return['error'] = acym_translation('ACYM_ERROR_SAVING');
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 updateController extends acymController
|
||||
{
|
||||
public function checkForNewVersion()
|
||||
{
|
||||
$lastlicensecheck = acym_checkVersion(true);
|
||||
|
||||
$headerHelper = acym_get('helper.header');
|
||||
$myAcyArea = $headerHelper->checkVersionArea();
|
||||
|
||||
echo json_encode(['content' => $myAcyArea, 'lastcheck' => acym_date($lastlicensecheck, 'Y/m/d H:i')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,730 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 UsersController extends acymController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->breadcrumb[acym_translation('ACYM_USERS')] = acym_completeLink('users');
|
||||
$this->loadScripts = [
|
||||
'edit' => ['datepicker'],
|
||||
];
|
||||
}
|
||||
|
||||
public function listing()
|
||||
{
|
||||
acym_setVar("layout", "listing");
|
||||
|
||||
$searchFilter = acym_getVar('string', 'users_search', '');
|
||||
$status = acym_getVar('string', 'users_status', '');
|
||||
$ordering = acym_getVar('string', 'users_ordering', 'id');
|
||||
$orderingSortOrder = acym_getVar('string', 'users_ordering_sort_order', 'desc');
|
||||
|
||||
$usersPerPage = acym_getCMSConfig('list_limit', 20);
|
||||
$page = acym_getVar('int', 'users_pagination_page', 1);
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$matchingUsers = $userClass->getMatchingUsers(
|
||||
[
|
||||
'search' => $searchFilter,
|
||||
'usersPerPage' => $usersPerPage,
|
||||
'offset' => ($page - 1) * $usersPerPage,
|
||||
'status' => $status,
|
||||
'ordering' => $ordering,
|
||||
'ordering_sort_order' => $orderingSortOrder,
|
||||
]
|
||||
);
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($matchingUsers['total'], $page, $usersPerPage);
|
||||
|
||||
if (!empty($matchingUsers['users'])) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$fieldsToDisplay = $fieldClass->getAllFieldsBackendListing();
|
||||
if (!empty($fieldsToDisplay['ids'])) {
|
||||
$userIds = [];
|
||||
foreach ($matchingUsers['users'] as $user) {
|
||||
$userIds[] = $user->id;
|
||||
}
|
||||
$fieldValue = $fieldClass->getAllfieldBackEndListingByUserIds($userIds, $fieldsToDisplay['ids']);
|
||||
foreach ($matchingUsers['users'] as $user) {
|
||||
$user->fields = [];
|
||||
foreach ($fieldsToDisplay['ids'] as $fieldId) {
|
||||
$user->fields[$fieldId] = empty($fieldValue[$fieldId.$user->id]) ? '' : $fieldValue[$fieldId.$user->id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$usersData = [
|
||||
'require_confirmation' => acym_config()->get('require_confirmation', '0'),
|
||||
'allUsers' => $matchingUsers['users'],
|
||||
'pagination' => $pagination,
|
||||
'search' => $searchFilter,
|
||||
'userNumberPerStatus' => $matchingUsers['status'],
|
||||
'status' => $status,
|
||||
'usersSubscriptions' => $this->getUsersSubscriptionsByIds($matchingUsers['users']),
|
||||
'orderingSortOrder' => $orderingSortOrder,
|
||||
'ordering' => $ordering,
|
||||
'fields' => empty($fieldsToDisplay['names']) ? '' : $fieldsToDisplay['names'],
|
||||
];
|
||||
|
||||
parent::display($usersData);
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
acym_setVar("layout", "edit");
|
||||
$userId = acym_getVar("int", "id", 0);
|
||||
$userClass = acym_get('class.user');
|
||||
$userStatClass = acym_get('class.userstat');
|
||||
$fieldClass = acym_get('class.field');
|
||||
$historyClass = acym_get('class.history');
|
||||
|
||||
$userData = [];
|
||||
$allFields = $fieldClass->getMatchingFields();
|
||||
$userData['allFields'] = [];
|
||||
$userData['pourcentageOpen'] = 0;
|
||||
$userData['pourcentageClick'] = 0;
|
||||
|
||||
if (!empty($userId)) {
|
||||
$fieldsValues = $fieldClass->getFieldsValueByUserId($userId);
|
||||
$userData['fieldsValues'] = [];
|
||||
foreach ($fieldsValues as $one) {
|
||||
$userData['fieldsValues'][$one->field_id] = $one->value;
|
||||
}
|
||||
$userData['user-information'] = $userClass->getOneById($userId);
|
||||
|
||||
if (empty($userData['user-information'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_USER_NOT_FOUND'), 'error', 0);
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$userData['allSubscriptions'] = $userClass->getUserSubscriptionById($userId);
|
||||
|
||||
$userData['subscriptions'] = [];
|
||||
$userData['unsubscribe'] = [];
|
||||
|
||||
foreach ($userData['allSubscriptions'] as $sub) {
|
||||
if ($sub->status == 1) {
|
||||
$userData['subscriptions'][] = $sub;
|
||||
} else {
|
||||
$userData['unsubscribe'][] = $sub;
|
||||
}
|
||||
}
|
||||
|
||||
$userData['subscriptionsIds'] = [];
|
||||
|
||||
if (!empty($userData['subscriptions'])) {
|
||||
$userData['subscriptionsIds'] = [];
|
||||
foreach ($userData['subscriptions'] as $list) {
|
||||
$userData['subscriptionsIds'][] = $list->id;
|
||||
}
|
||||
}
|
||||
|
||||
$userStatFromDB = $userStatClass->getAllUserStatByUserId($userId);
|
||||
|
||||
if (!empty($userStatFromDB)) {
|
||||
$userStat = new stdClass();
|
||||
$userStat->totalSent = 0;
|
||||
$userStat->open = 0;
|
||||
|
||||
foreach ($userStatFromDB as $oneStat) {
|
||||
if ($oneStat->sent > 0) {
|
||||
$userStat->totalSent++;
|
||||
}
|
||||
if ($oneStat->open > 0) {
|
||||
$userStat->open++;
|
||||
}
|
||||
}
|
||||
|
||||
$userStat->pourcentageOpen = empty($userStat->open) ? 0 : intval(($userStat->open * 100) / $userStat->totalSent);
|
||||
|
||||
$userData['pourcentageOpen'] = $userStat->pourcentageOpen;
|
||||
$userData['pourcentageClick'] = $userStat->pourcentageOpen;
|
||||
}
|
||||
|
||||
$this->breadcrumb[acym_escape($userData['user-information']->email)] = acym_completeLink('users&task=edit&id='.$userId);
|
||||
|
||||
$userHistory = $historyClass->getHistoryOfOneById($userId);
|
||||
$this->prepareHistoryContent($userHistory);
|
||||
$userData['userHistory'] = $userHistory;
|
||||
} else {
|
||||
$userData['user-information'] = new stdClass();
|
||||
$userData['user-information']->name = '';
|
||||
$userData['user-information']->email = '';
|
||||
$userData['user-information']->active = '1';
|
||||
$userData['user-information']->confirmed = '1';
|
||||
$userData['user-information']->cms_id = null;
|
||||
$userData['subscriptions'] = [];
|
||||
$userData['subscriptionsIds'] = [];
|
||||
$userData['subscriptions'] = [];
|
||||
$userData['unsubscribe'] = [];
|
||||
|
||||
$this->breadcrumb[acym_escape(acym_translation('ACYM_NEW_USER'))] = acym_completeLink('users&task=edit');
|
||||
}
|
||||
|
||||
foreach ($allFields as $one) {
|
||||
$one->option = json_decode($one->option);
|
||||
$one->value = empty($one->value) ? '' : json_decode($one->value);
|
||||
$fieldDB = empty($one->option->fieldDB) ? '' : json_decode($one->option->fieldDB);
|
||||
$displayIf = empty($one->option->display) ? '' : 'data-display-optional=\''.$one->option->display.'\'';
|
||||
|
||||
$valuesArray = [];
|
||||
if (!empty($one->value)) {
|
||||
foreach ($one->value as $value) {
|
||||
$valueTmp = new stdClass();
|
||||
$valueTmp->text = $value->title;
|
||||
$valueTmp->value = $value->value;
|
||||
if ($value->disabled == 'y') $valueTmp->disable = true;
|
||||
$valuesArray[$value->value] = $valueTmp;
|
||||
}
|
||||
}
|
||||
if (!empty($fieldDB) && !empty($fieldDB->value)) {
|
||||
$fromDB = $fieldClass->getValueFromDB($fieldDB);
|
||||
foreach ($fromDB as $value) {
|
||||
$valuesArray[$value->value] = $value->title;
|
||||
}
|
||||
}
|
||||
|
||||
$one->display = empty($one->option->display) ? '' : json_decode($one->option->display);
|
||||
$userData['allFields'][$one->id] = $one;
|
||||
if ($one->id == 1) {
|
||||
$defaultValue = acym_escape(empty($userData['user-information']->id) ? '' : $userData['user-information']->name);
|
||||
} elseif ($one->id == 2) {
|
||||
$defaultValue = acym_escape(empty($userData['user-information']->id) ? '' : $userData['user-information']->email);
|
||||
} elseif (!empty($userData['fieldsValues'][$one->id])) {
|
||||
$defaultValue = is_null(json_decode($userData['fieldsValues'][$one->id])) ? $userData['fieldsValues'][$one->id] : json_decode($userData['fieldsValues'][$one->id]);
|
||||
} else {
|
||||
$defaultValue = $one->default_value;
|
||||
}
|
||||
$size = empty($one->option->size) ? '' : 'width:'.$one->option->size.'px';
|
||||
|
||||
$userData['allFields'][$one->id]->html = $fieldClass->displayField($one, $defaultValue, $size, $valuesArray, true, false, null, $one->backend_profile);
|
||||
}
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
|
||||
$userData['tab'] = $tabHelper;
|
||||
|
||||
parent::display($userData);
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
acym_setVar("layout", "import");
|
||||
|
||||
$tab = acym_get('helper.tab');
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$nbUsersAcymailing = $userClass->getCountTotalUsers();
|
||||
$nbUsersCMS = acym_loadResult('SELECT count('.$this->cmsUserVars->id.') FROM '.$this->cmsUserVars->table);
|
||||
|
||||
$tables = acym_getTables();
|
||||
$arrayTables = [];
|
||||
foreach ($tables as $key => $tableName) {
|
||||
$arrayTables[$tableName] = $tableName;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'tab' => $tab,
|
||||
'nbUsersAcymailing' => $nbUsersAcymailing,
|
||||
'nbUsersCMS' => $nbUsersCMS,
|
||||
'tables' => $arrayTables,
|
||||
];
|
||||
|
||||
$this->breadcrumb[acym_translation('ACYM_IMPORT')] = acym_completeLink('users&task=import');
|
||||
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function ajaxEncoding()
|
||||
{
|
||||
acym_setVar('layout', 'ajaxencoding');
|
||||
parent::display();
|
||||
exit;
|
||||
}
|
||||
|
||||
public function doImport()
|
||||
{
|
||||
acym_checkToken();
|
||||
|
||||
$function = acym_getVar('cmd', 'import_from');
|
||||
$importHelper = acym_get('helper.import');
|
||||
|
||||
if (empty($function) || !$importHelper->$function()) {
|
||||
return $this->import();
|
||||
}
|
||||
|
||||
if ($function == 'textarea' || $function == 'file') {
|
||||
if (file_exists(ACYM_MEDIA.'import'.DS.acym_getVar('cmd', 'filename'))) {
|
||||
$importContent = file_get_contents(ACYM_MEDIA.'import'.DS.acym_getVar('cmd', 'filename'));
|
||||
}
|
||||
if (empty($importContent)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_EMPTY_TEXTAREA'), 'error', 5000);
|
||||
$this->import();
|
||||
} else {
|
||||
acym_setVar('layout', 'genericimport');
|
||||
$this->breadcrumb[acym_translation('ACYM_IMPORT')] = acym_completeLink('users&task=import');
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
} else {
|
||||
$this->listing();
|
||||
}
|
||||
}
|
||||
|
||||
public function finalizeImport()
|
||||
{
|
||||
$importHelper = acym_get('helper.import');
|
||||
$importHelper->finalizeImport();
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
function downloadImport()
|
||||
{
|
||||
$filename = acym_getVar('cmd', 'filename');
|
||||
if (!file_exists(ACYM_MEDIA.'import'.DS.$filename.'.csv')) {
|
||||
return;
|
||||
}
|
||||
acym_noTemplate();
|
||||
$exportHelper = acym_get('helper.export');
|
||||
$exportHelper->setDownloadHeaders($filename);
|
||||
echo file_get_contents(ACYM_MEDIA.'import'.DS.$filename.'.csv');
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
return $userClass->getAll();
|
||||
}
|
||||
|
||||
public function getUsersSubscriptionsByIds($usersData)
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
$usersId = [];
|
||||
foreach ($usersData as $oneUser) {
|
||||
$usersId[] = $oneUser->id;
|
||||
}
|
||||
|
||||
$subscriptions = [];
|
||||
|
||||
if (!empty($usersId)) {
|
||||
$subscriptionsArray = $userClass->getUsersSubscriptionsByIds($usersId);
|
||||
|
||||
foreach ($subscriptionsArray as $oneSubscription) {
|
||||
$subscriptions[$oneSubscription->user_id][$oneSubscription->id] = $oneSubscription;
|
||||
}
|
||||
}
|
||||
|
||||
return $subscriptions;
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
acym_setVar("layout", "export");
|
||||
$this->breadcrumb[acym_translation('ACYM_EXPORT_USERS')] = acym_completeLink('users&task=export');
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$lists = $listClass->getAll();
|
||||
|
||||
$checkedUsers = acym_getVar('array', 'elements_checked', []);
|
||||
|
||||
$fields = acym_getColumns('user');
|
||||
|
||||
$fieldClass = acym_get('class.field');
|
||||
$customFields = $fieldClass->getAllfields();
|
||||
|
||||
$data = [
|
||||
'lists' => $lists,
|
||||
'checkedUsers' => $checkedUsers,
|
||||
'fields' => $fields,
|
||||
'customfields' => $customFields,
|
||||
'config' => acym_config(),
|
||||
];
|
||||
|
||||
parent::display($data);
|
||||
}
|
||||
|
||||
public function doexport()
|
||||
{
|
||||
acym_checkToken();
|
||||
acym_increasePerf();
|
||||
|
||||
$usersToExport = acym_getVar('string', 'export_users-to-export', 'all');
|
||||
$listsToExport = json_decode(acym_getVar('string', 'lists_selected'));
|
||||
if ($usersToExport == "list" && empty($listsToExport)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_EXPORT_SELECT_LIST'), 'error', 5000);
|
||||
|
||||
return $this->exportError(acym_translation('ACYM_EXPORT_SELECT_LIST'));
|
||||
}
|
||||
acym_arrayToInteger($listsToExport);
|
||||
|
||||
$exportUsersType = 'all';
|
||||
if ($usersToExport == 'list') {
|
||||
$exportUsersType = acym_getVar('string', 'export_list', 'all');
|
||||
}
|
||||
|
||||
$selectedUsers = acym_getVar('string', 'selected_users', null);
|
||||
|
||||
if (!empty($selectedUsers)) {
|
||||
$selectedUsersArray = explode(',', $selectedUsers);
|
||||
acym_arrayToInteger($selectedUsersArray);
|
||||
}
|
||||
|
||||
$fieldsToExport = acym_getVar('array', 'export_fields', []);
|
||||
if (empty($fieldsToExport)) {
|
||||
if (!empty($selectedUsersArray)) {
|
||||
acym_setVar('elements_checked', $selectedUsersArray);
|
||||
} else {
|
||||
acym_setVar('elements_checked', []);
|
||||
}
|
||||
|
||||
return $this->exportError(acym_translation('ACYM_EXPORT_SELECT_FIELD'));
|
||||
}
|
||||
|
||||
$tableFields = acym_getColumns('user');
|
||||
$fieldClass = acym_get('class.field');
|
||||
$customFields = $fieldClass->getAllfields();
|
||||
|
||||
$customFieldsToExport = [];
|
||||
|
||||
foreach ($fieldsToExport as $i => $oneField) {
|
||||
if (empty($customFields[$oneField])) continue;
|
||||
$customFieldsToExport[$oneField] = acym_translation($customFields[$oneField]->name, true);
|
||||
unset($fieldsToExport[$i]);
|
||||
}
|
||||
|
||||
$notAllowedFields = array_diff($fieldsToExport, $tableFields);
|
||||
if (in_array('id', $fieldsToExport)) $notAllowedFields[] = 'id';
|
||||
if (!empty($notAllowedFields)) {
|
||||
return $this->exportError(acym_translation_sprintf('ACYM_NOT_ALLOWED_FIELDS', implode(', ', $notAllowedFields), implode(', ', $tableFields)));
|
||||
}
|
||||
|
||||
$charset = acym_getVar('string', 'export_charset', 'UTF-8');
|
||||
$excelsecurity = acym_getVar('string', 'export_excelsecurity', 0);
|
||||
$separator = acym_getVar('string', 'export_separator', ',');
|
||||
if (!in_array($separator, [',', ';'])) {
|
||||
$separator = ',';
|
||||
}
|
||||
|
||||
|
||||
$config = acym_config();
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->export_separator = $separator;
|
||||
$newConfig->export_charset = $charset;
|
||||
$newConfig->export_excelsecurity = $excelsecurity;
|
||||
$newConfig->export_fields = implode(',', array_merge($fieldsToExport, array_keys($customFieldsToExport)));
|
||||
if (empty($selectedUsers)) {
|
||||
$newConfig->export_lists = implode(',', $listsToExport);
|
||||
}
|
||||
$config->save($newConfig);
|
||||
|
||||
foreach ($fieldsToExport as $oneField) {
|
||||
acym_secureDBColumn($oneField);
|
||||
}
|
||||
$query = 'SELECT DISTINCT user.`id`, user.`'.implode('`, user.`', $fieldsToExport).'` FROM #__acym_user AS user';
|
||||
|
||||
$where = [];
|
||||
|
||||
if (!empty($selectedUsersArray)) {
|
||||
acym_arrayToInteger($selectedUsersArray);
|
||||
$where[] = 'user.id IN ('.implode(',', $selectedUsersArray).')';
|
||||
} elseif ($usersToExport == "list" && !empty($listsToExport)) {
|
||||
$query .= ' JOIN #__acym_user_has_list AS userlist ON userlist.user_id = user.id';
|
||||
acym_arrayToInteger($listsToExport);
|
||||
$where[] = 'userlist.list_id IN ('.implode(',', $listsToExport).')';
|
||||
|
||||
if ($exportUsersType == 'sub') $where[] = 'userlist.status = 1';
|
||||
if ($exportUsersType == 'unsub') $where[] = 'userlist.status = 0';
|
||||
}
|
||||
|
||||
if (!empty($where)) $query .= ' WHERE ('.implode(') AND (', $where).')';
|
||||
|
||||
$exportHelper = acym_get('helper.export');
|
||||
$exportHelper->exportCSV($query, $fieldsToExport, $customFieldsToExport, $separator, $charset);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
private function exportError($message)
|
||||
{
|
||||
acym_enqueueMessage($message, 'error', 0);
|
||||
acym_setNoTemplate(false);
|
||||
|
||||
return acym_redirect(acym_completeLink('users&task=export', false, true));
|
||||
}
|
||||
|
||||
public function unsubscribe()
|
||||
{
|
||||
$userId = acym_getVar('int', 'id');
|
||||
|
||||
if (empty($userId)) {
|
||||
$this->listing();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$lists = json_decode(acym_getVar('string', 'lists_selected'));
|
||||
if (!is_array($lists)) {
|
||||
$lists = (array)$lists;
|
||||
}
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$userClass->unsubscribe($userId, $lists);
|
||||
|
||||
$this->edit();
|
||||
}
|
||||
|
||||
public function subscribe($listing = false)
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
$userId = acym_getVar('int', 'id');
|
||||
$lists = json_decode(acym_getVar('string', 'lists_selected'));
|
||||
|
||||
if (empty($userId)) {
|
||||
$userId = $userClass->save();
|
||||
}
|
||||
|
||||
if (!is_array($lists)) {
|
||||
$lists = (array)$lists;
|
||||
}
|
||||
|
||||
$userClass->subscribe($userId, $lists);
|
||||
|
||||
if (!$listing) {
|
||||
$this->edit();
|
||||
} else {
|
||||
$this->listing();
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->apply(true);
|
||||
}
|
||||
|
||||
public function apply($listing = false)
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$userInformation = acym_getVar('array', 'user');
|
||||
$userId = acym_getVar('int', 'id');
|
||||
$listsToAdd = json_decode(acym_getVar('string', 'lists_selected'));
|
||||
$user = new stdClass();
|
||||
$user->name = $userInformation['name'];
|
||||
$user->email = $userInformation['email'];
|
||||
$user->active = $userInformation['active'];
|
||||
$user->confirmed = $userInformation['confirmed'];
|
||||
$customFields = acym_getVar('array', 'customField');
|
||||
|
||||
preg_match('/'.acym_getEmailRegex().'/i', $user->email, $matches);
|
||||
|
||||
if (empty($matches)) {
|
||||
$this->edit();
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_VALID_EMAIL', $user->email), 'error', 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($userId)) {
|
||||
$existingUser = $userClass->getOneByEmail($user->email);
|
||||
if (!empty($existingUser)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_X_ALREADY_EXIST', $user->email), 'error', 0);
|
||||
|
||||
$this->edit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
|
||||
$userId = $userClass->save($user, $customFields);
|
||||
acym_setVar('id', $userId);
|
||||
} else {
|
||||
$user->id = $userId;
|
||||
$userClass->save($user, $customFields);
|
||||
}
|
||||
|
||||
if (!empty($listsToAdd)) {
|
||||
$this->subscribe($listing);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($listing) {
|
||||
$this->listing();
|
||||
} else {
|
||||
$this->edit();
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteOne()
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$userId = acym_getVar('int', 'id');
|
||||
|
||||
$userClass->delete($userId);
|
||||
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function getColumnsFromTable()
|
||||
{
|
||||
$tableName = acym_secureDBColumn(acym_getVar('string', 'tablename', ''));
|
||||
if (empty($tableName)) {
|
||||
exit;
|
||||
}
|
||||
$columns = acym_getColumns($tableName, false, false);
|
||||
$allColumnsSelect = '<option value=""></option>';
|
||||
foreach ($columns as $oneColumn) {
|
||||
$allColumnsSelect .= '<option value="'.$oneColumn.'">'.$oneColumn.'</option>';
|
||||
}
|
||||
|
||||
echo $allColumnsSelect;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function addToList()
|
||||
{
|
||||
$listsSelected = json_decode(acym_getVar('string', 'lists_selected', ''));
|
||||
$userSelected = acym_getVar('array', 'elements_checked');
|
||||
$userClass = acym_get('class.user');
|
||||
foreach ($userSelected as $user) {
|
||||
$userClass->subscribe($user, $listsSelected);
|
||||
}
|
||||
$this->listing();
|
||||
}
|
||||
|
||||
public function setAjaxListing()
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$showSelected = acym_getVar('string', 'showSelected');
|
||||
$matchingUsersData = new stdClass();
|
||||
$matchingUsersData->ordering = 'name';
|
||||
$matchingUsersData->searchFilter = acym_getVar('string', 'searchUsers');
|
||||
$matchingUsersData->usersPerPage = acym_getVar('string', 'usersPerPage');
|
||||
$matchingUsersData->idsSelected = json_decode(acym_getVar('string', 'selectedUsers'));
|
||||
$matchingUsersData->idsHidden = json_decode(acym_getVar('string', 'hiddenUsers'));
|
||||
$matchingUsersData->page = acym_getVar('int', 'pagination_page_ajax');
|
||||
if (empty($matchingUsersData->page)) {
|
||||
$matchingUsersData->page = 1;
|
||||
}
|
||||
|
||||
$options = [
|
||||
'ordering' => $matchingUsersData->ordering,
|
||||
'search' => $matchingUsersData->searchFilter,
|
||||
'usersPerPage' => $matchingUsersData->usersPerPage,
|
||||
'offset' => ($matchingUsersData->page - 1) * $matchingUsersData->usersPerPage,
|
||||
'hiddenUsers' => $matchingUsersData->idsHidden,
|
||||
];
|
||||
|
||||
if ($showSelected == 'true') {
|
||||
$options['selectedUsers'] = $matchingUsersData->idsSelected;
|
||||
$options['showOnlySelected'] = true;
|
||||
}
|
||||
|
||||
$users = $userClass->getMatchingUsers($options);
|
||||
|
||||
$return = '';
|
||||
|
||||
if (empty($users['users'])) {
|
||||
$return .= '<h1 class="cell acym__listing__empty__search__modal text-center">'.acym_translation('ACYM_NO_RESULTS_FOUND').'</h1>';
|
||||
}
|
||||
|
||||
foreach ($users['users'] as $user) {
|
||||
$return .= '<div class="grid-x modal__pagination__users__listing__in-form__user cell">';
|
||||
|
||||
$return .= '<div class="cell shrink"><input type="checkbox" id="modal__pagination__users__listing__user'.$user->id.'" value="'.$user->id.'" class="modal__pagination__users__listing__user--checkbox" name="users_checked[]"';
|
||||
|
||||
if (!empty($matchingUsersData->idsSelected) && in_array($user->id, $matchingUsersData->idsSelected)) {
|
||||
$return .= 'checked';
|
||||
}
|
||||
|
||||
$return .= '></div><label class="cell auto" for="modal__pagination__users__listing__user'.$user->id.'"';
|
||||
|
||||
$return .= '> <span class="modal__pagination__users__listing__user-name ">'.$user->email.'</span></label></div>';
|
||||
}
|
||||
|
||||
$pagination = acym_get('helper.pagination');
|
||||
$pagination->setStatus($users['total'], $matchingUsersData->page, $matchingUsersData->usersPerPage);
|
||||
|
||||
$return .= $pagination->displayAjax();
|
||||
|
||||
echo $return;
|
||||
exit;
|
||||
}
|
||||
|
||||
private function prepareHistoryContent(&$userHistory)
|
||||
{
|
||||
foreach ($userHistory as &$oneHistory) {
|
||||
if (!empty($oneHistory->data)) {
|
||||
$historyData = explode("\n", $oneHistory->data);
|
||||
$details = '<div><h5>'.acym_translation('ACYM_DETAILS').'</h5><br />';
|
||||
if (!empty($oneHistory->mail_id)) {
|
||||
$details .= '<b>'.acym_translation('NEWSLETTER').' : </b>';
|
||||
$details .= acym_escape($oneHistory->subject).' ( '.acym_translation('ACYM_ID').' : '.$oneHistory->mail_id.' )<br />';
|
||||
}
|
||||
|
||||
foreach ($historyData as $value) {
|
||||
if (!strpos($value, '::')) {
|
||||
$details .= $value.'<br />';
|
||||
continue;
|
||||
}
|
||||
list($part1, $part2) = explode("::", $value);
|
||||
if (preg_match('#^[A-Z_]*$#', $part2)) $part2 = acym_translation($part2);
|
||||
$details .= '<b>'.acym_escape(acym_translation($part1)).' : </b>'.acym_escape($part2).'<br />';
|
||||
}
|
||||
$details .= '</div>';
|
||||
|
||||
$oneHistory->data = acym_modal(
|
||||
acym_translation('ACYM_VIEW_DETAILS'),
|
||||
$details,
|
||||
null,
|
||||
'style="word-break: break-word;"',
|
||||
'class="history_details"',
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($oneHistory->source)) {
|
||||
$source = explode("\n", $oneHistory->source);
|
||||
$details = '<div><h5>'.acym_translation('ACYM_SOURCE').'</h5><br />';
|
||||
foreach ($source as $value) {
|
||||
if (!strpos($value, '::')) continue;
|
||||
list($part1, $part2) = explode("::", $value);
|
||||
$details .= '<b>'.acym_escape($part1).' : </b>'.acym_escape($part2).'<br />';
|
||||
}
|
||||
$details .= '</div>';
|
||||
|
||||
$oneHistory->source = acym_modal(
|
||||
acym_translation('ACYM_VIEW_SOURCE'),
|
||||
$details,
|
||||
null,
|
||||
'style="word-break: break-word;"',
|
||||
'class="history_details"'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,350 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymArticle extends acymPlugin
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
$this->name = 'article';
|
||||
}
|
||||
|
||||
public function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = acym_translation('ACYM_ARTICLE');
|
||||
$plugin->icon = '<i class="cell fa fa-joomla"></i>';
|
||||
$plugin->icontype = 'raw';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
public function contentPopup()
|
||||
{
|
||||
$this->categories = acym_loadObjectList(
|
||||
'SELECT id, parent_id, title
|
||||
FROM `#__categories`
|
||||
WHERE extension = "com_content"'
|
||||
);
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
$tabHelper->startTab(acym_translation('ACYM_ONE_BY_ONE'));
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display',
|
||||
'options' => [
|
||||
'title' => ['ACYM_TITLE', true],
|
||||
'content' => ['ACYM_CONTENT', true],
|
||||
'cat' => ['ACYM_CATEGORY', false],
|
||||
'readmore' => ['ACYM_READ_MORE', false],
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TRUNCATE',
|
||||
'type' => 'intextfield',
|
||||
'name' => 'wrap',
|
||||
'text' => 'ACYM_TRUNCATE_AFTER',
|
||||
'default' => 0,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone();
|
||||
|
||||
$this->displayListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
$tabHelper->startTab(acym_translation('ACYM_BY_CATEGORY'));
|
||||
|
||||
$catOptions = [
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'id' => 'ACYM_ID',
|
||||
'publish_up' => 'ACYM_PUBLISHING_DATE',
|
||||
'modified' => 'ACYM_MODIFICATION_DATE',
|
||||
'title' => 'ACYM_TITLE',
|
||||
'rand' => 'ACYM_RANDOM',
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'number',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'number',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
];
|
||||
|
||||
$displayOptions = array_merge($displayOptions, $catOptions);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'auto'.$this->name, 'grouped');
|
||||
|
||||
echo $this->getCategoryListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
|
||||
public function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT article.id, article.title, article.publish_up ';
|
||||
$query = 'FROM #__content AS article ';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'article.id';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['article.id', 'article.title'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(' LIKE '.acym_escapeDB($searchVal).' OR ', $searchFields).' LIKE '.acym_escapeDB($searchVal);
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->filter_cat)) {
|
||||
$filters[] = "article.catid = ".intval($this->pageInfo->filter_cat);
|
||||
}
|
||||
|
||||
$filters[] = 'article.state = 1';
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
if (!empty($this->pageInfo->order)) $query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'title' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '7',
|
||||
],
|
||||
'publish_up' => [
|
||||
'label' => 'ACYM_PUBLISHING_DATE',
|
||||
'size' => '4',
|
||||
'type' => 'date',
|
||||
],
|
||||
'id' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'id',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
public function replaceContent(&$email)
|
||||
{
|
||||
$this->replaceAuto($email);
|
||||
$this->replaceOne($email);
|
||||
}
|
||||
|
||||
private function replaceAuto(&$email)
|
||||
{
|
||||
$this->generateByCategory($email);
|
||||
if (empty($this->tags)) return;
|
||||
$this->acympluginHelper->replaceTags($email, $this->tags, true);
|
||||
}
|
||||
|
||||
private function generateByCategory(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'auto'.$this->name);
|
||||
$return = new stdClass();
|
||||
$return->status = true;
|
||||
$return->message = '';
|
||||
$this->tags = [];
|
||||
$time = time();
|
||||
|
||||
if (empty($tags)) return $return;
|
||||
|
||||
foreach ($tags as $oneTag => $parameter) {
|
||||
if (isset($this->tags[$oneTag])) continue;
|
||||
|
||||
$allcats = explode('-', $parameter->id);
|
||||
$selectedArea = [];
|
||||
foreach ($allcats as $oneCat) {
|
||||
if (empty($oneCat)) continue;
|
||||
|
||||
$selectedArea[] = intval($oneCat);
|
||||
}
|
||||
|
||||
$query = 'SELECT DISTINCT article.`id` FROM #__content AS article ';
|
||||
|
||||
$where = [];
|
||||
|
||||
if (!empty($selectedArea)) {
|
||||
$where[] = 'article.catid IN ('.implode(',', $selectedArea).')';
|
||||
}
|
||||
|
||||
$where[] = 'article.state = 1';
|
||||
$where[] = '`publish_up` < '.acym_escapeDB(date('Y-m-d H:i:s', $time - date('Z')));
|
||||
$where[] = '`publish_down` > '.acym_escapeDB(date('Y-m-d H:i:s', $time - date('Z'))).' OR `publish_down` = 0';
|
||||
|
||||
$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 article.`'.acym_secureDBColumn(trim($ordering[0])).'` '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($parameter->max)) $parameter->max = 20;
|
||||
$query .= ' LIMIT '.intval($parameter->max);
|
||||
|
||||
$allArticles = acym_loadResultArray($query);
|
||||
|
||||
$this->tags[$oneTag] = $this->finalizeCategoryFormat($this->name, $allArticles, $parameter);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
require_once JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php';
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $oneTag) {
|
||||
if (isset($tagsReplaced[$i])) continue;
|
||||
|
||||
$tagsReplaced[$i] = $this->replaceIndividualContent($oneTag);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
private function replaceIndividualContent($tag)
|
||||
{
|
||||
$query = 'SELECT article.*
|
||||
FROM #__content AS article
|
||||
WHERE article.state = 1
|
||||
AND article.id = '.intval($tag->id);
|
||||
|
||||
$element = acym_loadObject($query);
|
||||
|
||||
if (empty($element)) {
|
||||
if (acym_isAdmin()) {
|
||||
acym_enqueueMessage('The article "'.$tag->id.'" could not be found', 'notice');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($tag->display)) {
|
||||
$tag->display = [];
|
||||
} else {
|
||||
$tag->display = explode(',', $tag->display);
|
||||
}
|
||||
|
||||
$varFields = [];
|
||||
$varFields['{picthtml}'] = '';
|
||||
foreach ($element as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$completeId = $element->id;
|
||||
if (!empty($element->alias)) $completeId .= ':'.$element->alias;
|
||||
|
||||
$link = ContentHelperRoute::getArticleRoute($completeId, $element->catid);
|
||||
$link = acym_frontendLink($link, false);
|
||||
$varFields['{link}'] = $link;
|
||||
|
||||
$title = $element->title;
|
||||
|
||||
$afterTitle = '';
|
||||
$afterArticle = '';
|
||||
|
||||
$imagePath = '';
|
||||
if (!empty($tag->pict) && !empty($element->images)) {
|
||||
$images = json_decode($element->images);
|
||||
$pictVar = empty($images->image_fulltext) ? 'image_intro' : 'image_fulltext';
|
||||
if (!empty($images->$pictVar)) {
|
||||
$imagePath = acym_rootURI().$images->$pictVar;
|
||||
$varFields['{picthtml}'] = '<img alt="" src="'.acym_escape($imagePath).'" />';
|
||||
}
|
||||
}
|
||||
|
||||
$contentText = '';
|
||||
if (in_array('content', $tag->display)) $contentText .= $element->introtext.$element->fulltext;
|
||||
|
||||
$customFields = [];
|
||||
if (in_array('cat', $tag->display)) {
|
||||
$category = acym_loadResult('SELECT title FROM #__categories WHERE id = '.intval($element->catid));
|
||||
$customFields[] = [
|
||||
'<a href="index.php?option=com_content&view=category&id='.$element->catid.'" target="_blank">'.acym_escape($category).'</a>',
|
||||
acym_translation('ACYM_CATEGORY'),
|
||||
];
|
||||
}
|
||||
|
||||
$readMoreText = empty($tag->readmore) ? acym_translation('ACYM_READ_MORE') : $tag->readmore;
|
||||
$varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.acym_escape($readMoreText).'</span></a>';
|
||||
if (in_array('readmore', $tag->display)) $afterArticle .= $varFields['{readmore}'];
|
||||
|
||||
$format = new stdClass();
|
||||
$format->tag = $tag;
|
||||
$format->title = $title;
|
||||
$format->afterTitle = $afterTitle;
|
||||
$format->afterArticle = $afterArticle;
|
||||
$format->imagePath = $imagePath;
|
||||
$format->description = $contentText;
|
||||
$format->link = empty($tag->clickable) ? '' : $link;
|
||||
$format->cols = empty($tag->nbcols) ? 1 : intval($tag->nbcols);
|
||||
$format->customFields = $customFields;
|
||||
$result = '<div class="acymailing_content">'.$this->acympluginHelper->getStandardDisplay($format).'</div>';
|
||||
|
||||
return $this->finalizeElementFormat($this->name, $result, $tag, $varFields);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymCbuilder extends acymPlugin
|
||||
{
|
||||
var $sendervalues = [];
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_comprofiler'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
}
|
||||
|
||||
function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = 'Community Builder';
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->type = 'joomla';
|
||||
$onePlugin->help = 'plugin-cbuilder';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
function textPopup()
|
||||
{
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
function applyCB(tagname, element) {
|
||||
var string = '{cbtag:' + tagname + '|info:' + jQuery('input[name="typeinfo"]:checked').val() + '}';
|
||||
setTag(string, jQuery(element));
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$text = '<div class="grid-x acym__popup__listing">';
|
||||
|
||||
$typeinfo = [];
|
||||
$typeinfo[] = acym_selectOption('receiver', 'ACYM_RECEIVER_INFORMATION');
|
||||
$typeinfo[] = acym_selectOption('sender', 'ACYM_SENDER_INFORMATION');
|
||||
$text .= acym_radio($typeinfo, 'typeinfo', 'receiver');
|
||||
|
||||
$fieldType = acym_loadObjectList('SELECT name, type FROM #__comprofiler_fields', 'name');
|
||||
|
||||
$text .= '<div class="cell acym__listing__row acym__listing__row__popup" onclick="applyCB(\'thumb\');" >Thumb Avatar</div>';
|
||||
|
||||
$fields = acym_getColumns('comprofiler', false);
|
||||
foreach ($fields as $fieldname) {
|
||||
$type = '';
|
||||
if (strpos(strtolower($fieldname), 'date') !== false) {
|
||||
$type = '| type:date';
|
||||
}
|
||||
if (!empty($fieldType[$fieldname]) && $fieldType[$fieldname]->type == 'image') {
|
||||
$type = '| type:image';
|
||||
}
|
||||
$text .= '<div class="cell acym__listing__row acym__listing__row__popup" onclick="applyCB(\''.$fieldname.$type.'\', this);" >'.$fieldname.'</div>';
|
||||
}
|
||||
|
||||
$otherFields = acym_loadObjectList("SELECT * FROM #__comprofiler_fields WHERE tablecolumns = '' AND published = 1");
|
||||
foreach ($otherFields as $oneField) {
|
||||
$text .= '<div class="cell acym__listing__row acym__listing__row__popup" onclick="applyCB(\'cbapi_'.$oneField->name.'\');" >'.$oneField->name.'</div>';
|
||||
}
|
||||
|
||||
$text .= '</div>';
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$extractedTags = $this->acympluginHelper->extractTags($email, 'cbtag');
|
||||
if (empty($extractedTags)) return;
|
||||
|
||||
$uservalues = null;
|
||||
if (!empty($user->cms_id)) {
|
||||
$uservalues = acym_loadObject('SELECT * FROM #__comprofiler WHERE user_id = '.intval($user->cms_id).' LIMIT 1');
|
||||
}
|
||||
|
||||
$fieldObjects = acym_loadObjectList('SELECT fieldid, `table`, name, type, params FROM #__comprofiler_fields', 'name');
|
||||
|
||||
if (!include_once ACYM_ROOT.'administrator'.DS.'components'.DS.'com_comprofiler'.DS.'plugin.foundation.php') return;
|
||||
cbimport('cb.database');
|
||||
$currentCBUser = null;
|
||||
|
||||
$tags = [];
|
||||
foreach ($extractedTags as $i => $oneTag) {
|
||||
if (isset($tags[$i])) continue;
|
||||
|
||||
$field = $oneTag->id;
|
||||
$values = new stdClass();
|
||||
|
||||
if (!empty($oneTag->info) && $oneTag->info == 'sender') {
|
||||
if (empty($this->sendervalues[$email->id]) && !empty($email->creator_id)) {
|
||||
$this->sendervalues[$email->id] = acym_loadObject('SELECT * FROM #__comprofiler WHERE user_id = '.intval($email->creator_id).' LIMIT 1');
|
||||
}
|
||||
if (!empty($this->sendervalues[$email->id])) {
|
||||
$values = $this->sendervalues[$email->id];
|
||||
}
|
||||
} else {
|
||||
$values = $uservalues;
|
||||
}
|
||||
|
||||
if (substr($field, 0, 6) == 'cbapi_') {
|
||||
if (!empty($oneTag->info) && $oneTag->info == 'sender') {
|
||||
if (empty($this->sendervalues[$email->id]->$field) && !empty($email->creator_id)) {
|
||||
$currentSender = CBuser::getInstance($email->creator_id);
|
||||
$values->$field = $currentSender->getField(substr($field, 6), $oneTag->default, 'html', 'none', 'profile', 0, true);
|
||||
$this->sendervalues[$email->id]->$field = $values->$field;
|
||||
} elseif (!empty($this->sendervalues[$email->id]->$field)) {
|
||||
$values->$field = @$this->sendervalues[$email->id]->$field;
|
||||
}
|
||||
} elseif (!empty($user->cms_id)) {
|
||||
if (empty($currentCBUser)) {
|
||||
$currentCBUser = CBuser::getInstance($user->cms_id);
|
||||
}
|
||||
if (!empty($currentCBUser)) {
|
||||
$values->$field = $currentCBUser->getField(substr($field, 6), $oneTag->default, 'html', 'none', 'profile', 0, true);
|
||||
}
|
||||
|
||||
$fieldName = substr($field, 6);
|
||||
if (empty($values->$field) && !empty($fieldObjects[$fieldName]) && $fieldObjects[$fieldName]->type == 'progress') {
|
||||
$fieldObjects[$fieldName]->decodedParams = json_decode($fieldObjects[$fieldName]->params);
|
||||
if (!empty($fieldObjects[$fieldName]->decodedParams->prg_fields)) {
|
||||
$requiredFields = explode('|*|', $fieldObjects[$fieldName]->decodedParams->prg_fields);
|
||||
$filled_in = 0;
|
||||
foreach ($fieldObjects as $oneField) {
|
||||
if (!in_array($oneField->fieldid, $requiredFields) || !in_array($oneField->table, ['#__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 : $oneTag->default;
|
||||
if (!empty($oneTag->type)) {
|
||||
if ($oneTag->type == 'image' && !empty($replaceme)) {
|
||||
$url = 'images/comprofiler/'.$replaceme;
|
||||
$canvasUrl = str_replace('gallery/', 'gallery/canvas/', $url);
|
||||
if (!file_exists(ACYM_ROOT.$url) && file_exists(ACYM_ROOT.$canvasUrl)) $url = $canvasUrl;
|
||||
$replaceme = '<img src="'.ACYM_LIVE.$url.'" alt="'.acym_escape(@$user->name).'" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($field == 'thumb') {
|
||||
$replaceme = '<img src="'.ACYM_LIVE.'images/comprofiler/tn'.$values->avatar.'" alt="'.acym_escape(@$user->name).'" />';
|
||||
} elseif ($field == 'avatar') {
|
||||
$replaceme = '<img src="'.ACYM_LIVE.'images/comprofiler/'.$values->avatar.'" alt="'.acym_escape(@$user->name).'" />';
|
||||
}
|
||||
|
||||
$tags[$i] = $replaceme;
|
||||
$this->acympluginHelper->formatString($tags[$i], $oneTag);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
$languages = [];
|
||||
$langPath = JPATH_SITE.DS.'components'.DS.'com_comprofiler'.DS.'plugin'.DS.'language'.DS.'default_language'.DS;
|
||||
if (file_exists($langPath.'language.php')) {
|
||||
if (!defined('CBLIB')) include_once JPATH_SITE.DS.'libraries/CBLib/CB/Application/CBApplication.php';
|
||||
$languages = include_once $langPath.'language.php';
|
||||
} elseif (file_exists($langPath.'default_language.php')) {
|
||||
include_once $langPath.'default_language.php';
|
||||
}
|
||||
|
||||
$fieldTitles = acym_loadObjectList('SELECT `name`, `title` FROM #__comprofiler_fields WHERE `table` LIKE "#__comprofiler"', 'name');
|
||||
$fields = acym_getColumns('comprofiler', false);
|
||||
|
||||
$cbfields = [];
|
||||
foreach ($fields as $alias) {
|
||||
$text = $alias;
|
||||
|
||||
if (!empty($fieldTitles[$alias])) {
|
||||
if (empty($languages[$fieldTitles[$alias]->title])) {
|
||||
if (defined($fieldTitles[$alias]->title)) {
|
||||
$text = constant($fieldTitles[$alias]->title);
|
||||
} else {
|
||||
$text = $fieldTitles[$alias]->title;
|
||||
}
|
||||
} else {
|
||||
$text = $languages[$fieldTitles[$alias]->title];
|
||||
}
|
||||
}
|
||||
|
||||
$cbfields[] = acym_selectOption($alias, $text);
|
||||
}
|
||||
|
||||
usort($cbfields, [$this, 'sortFields']);
|
||||
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$conditions['user']['cbfield'] = new stdClass();
|
||||
$conditions['user']['cbfield']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'Community Builder', acym_translation('ACYM_FIELDS'));
|
||||
$conditions['user']['cbfield']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['cbfield']->option .= acym_select($cbfields, 'acym_condition[conditions][__numor__][__numand__][cbfield][field]', null, 'class="acym__select"');
|
||||
$conditions['user']['cbfield']->option .= '</div>';
|
||||
$conditions['user']['cbfield']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['cbfield']->option .= $operator->display('acym_condition[conditions][__numor__][__numand__][cbfield][operator]');
|
||||
$conditions['user']['cbfield']->option .= '</div>';
|
||||
$conditions['user']['cbfield']->option .= '<input class="intext_input_automation cell" type="text" name="acym_condition[conditions][__numor__][__numand__][cbfield][value]">';
|
||||
}
|
||||
|
||||
public function sortFields($a, $b)
|
||||
{
|
||||
return strcmp($a->text, $b->text);
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_cbfield(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_cbfield($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function processConditionFilter_cbfield(&$query, $options, $num)
|
||||
{
|
||||
if (empty($options['field'])) return;
|
||||
|
||||
$query->leftjoin['cbfield'.$num] = '#__comprofiler AS cbfield'.$num.' ON cbfield'.$num.'.id = user.cms_id';
|
||||
$query->where[] = $query->convertQuery('cbfield'.$num, $options['field'], $options['operator'], $options['value']);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
$this->summaryConditionFilters($automationCondition);
|
||||
}
|
||||
|
||||
public function summaryConditionFilters(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['cbfield'])) {
|
||||
$automationCondition = acym_translation_sprintf('ACYM_CONDITION_ACY_FIELD_SUMMARY', $automationCondition['cbfield']['field'], $automationCondition['cbfield']['operator'], $automationCondition['cbfield']['value']);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$newFilters = [];
|
||||
|
||||
$this->onAcymDeclareConditions($newFilters);
|
||||
foreach ($newFilters as $oneType) {
|
||||
foreach ($oneType as $oneFilterName => $oneFilter) {
|
||||
if (!empty($oneFilter->option)) $oneFilter->option = str_replace(['acym_condition', '[conditions]'], ['acym_action', '[filters]'], $oneFilter->option);
|
||||
$filters[$oneFilterName] = $oneFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_cbfield(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_cbfield($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_cbfield(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_cbfield($query, $options, $num);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
$this->summaryConditionFilters($automationFilter);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,824 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymEventbooking extends acymPlugin
|
||||
{
|
||||
var $imgFolder = '';
|
||||
var $useStdTime;
|
||||
var $eventbookingconfig;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_eventbooking'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
$this->name = 'eventbooking';
|
||||
$this->rootCategoryId = 0;
|
||||
}
|
||||
|
||||
public function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = 'Event Booking';
|
||||
$plugin->icon = ACYM_DYNAMICS_URL.basename(__DIR__).'/icon.png';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
public function contentPopup()
|
||||
{
|
||||
acym_loadLanguageFile('com_eventbooking', JPATH_SITE);
|
||||
$this->categories = acym_loadObjectList('SELECT `id`, `parent` AS `parent_id`, `name` AS `title` FROM `#__eb_categories` WHERE published = 1', 'id');
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
$tabHelper->startTab(acym_translation('ACYM_ONE_BY_ONE'));
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display',
|
||||
'options' => [
|
||||
'title' => ['ACYM_TITLE', true],
|
||||
'price' => ['ACYM_PRICE', true],
|
||||
'sdate' => ['ACYM_DATE', true],
|
||||
'edate' => ['EB_EVENT_END_DATE', true],
|
||||
'image' => ['ACYM_IMAGE', true],
|
||||
'short' => ['ACYM_SHORT_DESCRIPTION', true],
|
||||
'desc' => ['ACYM_DESCRIPTION', false],
|
||||
'cats' => ['ACYM_CATEGORIES', false],
|
||||
'location' => ['ACYM_LOCATION', true],
|
||||
'capacity' => ['EB_CAPACTIY', false],
|
||||
'regstart' => ['EB_REGISTRATION_START_DATE', false],
|
||||
'cut' => ['EB_CUT_OFF_DATE', false],
|
||||
'indiv' => ['EB_REGISTER_INDIVIDUAL', false],
|
||||
'group' => ['EB_REGISTER_GROUP', false],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (file_exists(JPATH_ROOT.DS.'components'.DS.'com_eventbooking'.DS.'fields.xml')) {
|
||||
$xml = JFactory::getXML(JPATH_ROOT.'/components/com_eventbooking/fields.xml');
|
||||
if (!empty($xml->fields)) {
|
||||
$fields = $xml->fields->fieldset->children();
|
||||
$customFields = [];
|
||||
foreach ($fields as $oneCustomField) {
|
||||
$name = $oneCustomField->attributes()->name;
|
||||
$label = acym_translation($oneCustomField->attributes()->label);
|
||||
$customFields["$name"] = [$label, false];
|
||||
}
|
||||
|
||||
$displayOptions[] = [
|
||||
'title' => 'ACYM_CUSTOM_FIELDS',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'custom',
|
||||
'options' => $customFields,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$displayOptions = array_merge(
|
||||
$displayOptions,
|
||||
[
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TRUNCATE',
|
||||
'type' => 'intextfield',
|
||||
'name' => 'wrap',
|
||||
'text' => 'ACYM_TRUNCATE_AFTER',
|
||||
'default' => 0,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_READ_MORE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'readmore',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone();
|
||||
|
||||
$this->displayListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
$tabHelper->startTab(acym_translation('ACYM_BY_CATEGORY'));
|
||||
|
||||
$catOptions = [
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'number',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'number',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_FROM',
|
||||
'type' => 'date',
|
||||
'name' => 'from',
|
||||
'default' => date('Y-m-d'),
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TO',
|
||||
'type' => 'date',
|
||||
'name' => 'to',
|
||||
'default' => '',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'id' => 'ACYM_ID',
|
||||
'event_date' => 'ACYM_DATE',
|
||||
'cut_off_date' => 'EB_CUT_OFF_DATE',
|
||||
'title' => 'ACYM_TITLE',
|
||||
'rand' => 'ACYM_RANDOM',
|
||||
],
|
||||
'default' => 'event_date',
|
||||
'defaultdir' => 'asc',
|
||||
],
|
||||
];
|
||||
|
||||
$displayOptions = array_merge($displayOptions, $catOptions);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'auto'.$this->name, 'grouped');
|
||||
|
||||
echo $this->getCategoryListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
|
||||
public function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT event.* ';
|
||||
$query = 'FROM `#__eb_events` AS event ';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'event.id';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['event.id', 'event.title'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(" LIKE ".acym_escapeDB($searchVal)." OR ", $searchFields)." LIKE ".acym_escapeDB($searchVal);
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->filter_cat)) {
|
||||
$query .= 'JOIN `#__eb_event_categories` AS cat ON event.id = cat.event_id ';
|
||||
$filters[] = 'cat.category_id = '.intval($this->pageInfo->filter_cat);
|
||||
}
|
||||
|
||||
$filters[] = 'event.published = 1';
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->order)) {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
}
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'title' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '8',
|
||||
],
|
||||
'event_date' => [
|
||||
'label' => 'ACYM_DATE',
|
||||
'size' => '3',
|
||||
'type' => 'date',
|
||||
],
|
||||
'id' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'id',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
public function replaceContent(&$email)
|
||||
{
|
||||
$this->_replaceAuto($email);
|
||||
$this->_replaceOne($email);
|
||||
}
|
||||
|
||||
public function _replaceAuto(&$email)
|
||||
{
|
||||
$this->generateByCategory($email);
|
||||
if (empty($this->tags)) return;
|
||||
$this->acympluginHelper->replaceTags($email, $this->tags, true);
|
||||
}
|
||||
|
||||
public function generateByCategory(&$email)
|
||||
{
|
||||
$time = time();
|
||||
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'auto'.$this->name);
|
||||
$return = new stdClass();
|
||||
$return->status = true;
|
||||
$return->message = '';
|
||||
$this->tags = [];
|
||||
|
||||
if (empty($tags)) return $return;
|
||||
|
||||
foreach ($tags as $oneTag => $parameter) {
|
||||
if (isset($this->tags[$oneTag])) continue;
|
||||
|
||||
$allcats = explode('-', $parameter->id);
|
||||
$selectedArea = [];
|
||||
foreach ($allcats as $oneCat) {
|
||||
if (empty($oneCat)) continue;
|
||||
|
||||
$selectedArea[] = intval($oneCat);
|
||||
}
|
||||
if (empty($parameter->from)) {
|
||||
$parameter->from = date('Y-m-d H:i:s', $time);
|
||||
} else {
|
||||
$parameter->from = acym_date(acym_replaceDate($parameter->from), 'Y-m-d H:i:s');
|
||||
}
|
||||
if (!empty($parameter->to)) $parameter->to = acym_date(acym_replaceDate($parameter->to), 'Y-m-d H:i:s');
|
||||
|
||||
$query = 'SELECT DISTINCT event.id FROM `#__eb_events` AS event ';
|
||||
|
||||
$where = [];
|
||||
$where[] = 'event.`published` = 1';
|
||||
|
||||
if (!empty($selectedArea)) {
|
||||
$query .= 'JOIN `#__eb_event_categories` AS cat ON event.id = cat.event_id ';
|
||||
$where[] = 'cat.category_id IN ('.implode(',', $selectedArea).')';
|
||||
}
|
||||
|
||||
if ((empty($parameter->mindelay) || substr($parameter->mindelay, 0, 1) != '-') && (empty($parameter->delay) || substr($parameter->delay, 0, 1) != '-')) {
|
||||
if (!empty($parameter->addcurrent)) {
|
||||
$where[] = 'event.`event_end_date` >= '.acym_escapeDB($parameter->from);
|
||||
} else {
|
||||
$where[] = 'event.`event_date` >= '.acym_escapeDB($parameter->from);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($parameter->todaysevent)) {
|
||||
$where[] = 'event.`event_date` <= '.acym_escapeDB(date('Y-m-d 23:59:59', $time));
|
||||
}
|
||||
|
||||
if (!empty($parameter->mindelay)) $where[] = 'event.`event_date` >= '.acym_escapeDB(date('Y-m-d H:i:s', $time + $parameter->mindelay));
|
||||
if (!empty($parameter->delay)) $where[] = 'event.`event_date` <= '.acym_escapeDB(date('Y-m-d H:i:s', $time + $parameter->delay));
|
||||
if (!empty($parameter->to)) $where[] = 'event.`event_date` <= '.acym_escapeDB($parameter->to);
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $where).')';
|
||||
|
||||
$ordering = explode(',', $parameter->order);
|
||||
if ($ordering[0] == 'rand') {
|
||||
$query .= ' ORDER BY rand()';
|
||||
} else {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn(trim($ordering[0])).' '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
|
||||
if (empty($parameter->max)) $parameter->max = 20;
|
||||
$query .= ' LIMIT '.intval($parameter->max);
|
||||
|
||||
$allArticles = acym_loadResultArray($query);
|
||||
|
||||
if (!empty($parameter->min) && count($allArticles) < $parameter->min) {
|
||||
$return->status = false;
|
||||
$return->message = 'Not enough events for the tag '.$oneTag.' : '.count($allArticles).' / '.$parameter->min;
|
||||
}
|
||||
|
||||
$this->tags[$oneTag] = $this->finalizeCategoryFormat($this->name, $allArticles, $parameter);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function _replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
acym_loadLanguageFile('com_eventbooking', JPATH_SITE);
|
||||
|
||||
if (!include_once JPATH_ROOT.'/components/com_eventbooking/helper/helper.php') {
|
||||
if (acym_isAdmin()) acym_enqueueMessage('Could not load the Event Booking helper', 'notice');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->eventbookingconfig = EventBookingHelper::getConfig();
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $params) {
|
||||
if (isset($tagsReplaced[$i])) continue;
|
||||
|
||||
$tagsReplaced[$i] = $this->_replaceContent($tags[$i]);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
public function _replaceContent(&$tag)
|
||||
{
|
||||
$query = 'SELECT event.*, location.name AS location_name FROM `#__eb_events` AS event ';
|
||||
$query .= 'LEFT JOIN `#__eb_locations` AS location ON event.location_id = location.id ';
|
||||
$query .= 'WHERE event.id = '.intval($tag->id);
|
||||
|
||||
$element = acym_loadObject($query);
|
||||
|
||||
if (empty($element)) {
|
||||
if (acym_isAdmin()) acym_enqueueMessage('The event "'.$tag->id.'" could not be loaded', 'notice');
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$varFields = [];
|
||||
foreach ($element as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$tag->display = empty($tag->display) ? [] : explode(',', $tag->display);
|
||||
$tag->custom = empty($tag->custom) ? [] : explode(',', $tag->custom);
|
||||
|
||||
$link = acym_frontendLink('index.php?option=com_eventbooking&view=event&id='.intval($tag->id), false);
|
||||
$varFields['{link}'] = $link;
|
||||
|
||||
$title = '';
|
||||
$afterTitle = '';
|
||||
$afterArticle = '';
|
||||
|
||||
$imagePath = '';
|
||||
$contentText = '';
|
||||
$customFields = [];
|
||||
|
||||
|
||||
if (in_array('title', $tag->display)) $title = $element->title;
|
||||
if (in_array('short', $tag->display)) $contentText .= $element->short_description;
|
||||
if (in_array('desc', $tag->display)) $contentText .= $element->description;
|
||||
|
||||
if (in_array('image', $tag->display) && !empty($element->image)) $imagePath = acym_frontendLink($element->image, false);
|
||||
|
||||
|
||||
if (in_array('sdate', $tag->display) && $element->event_date > '0001-00-00') {
|
||||
$customFields[] = [acym_date($element->event_date, $this->eventbookingconfig->event_date_format, null), acym_translation('EB_EVENT_DATE')];
|
||||
}
|
||||
|
||||
if (in_array('edate', $tag->display) && $element->event_end_date > '0001-00-00') {
|
||||
$customFields[] = [acym_date($element->event_end_date, $this->eventbookingconfig->event_date_format, null), acym_translation('EB_EVENT_END_DATE')];
|
||||
}
|
||||
|
||||
if (in_array('location', $tag->display) && !empty($element->location_id)) {
|
||||
$location = '<a href="index.php?option=com_eventbooking&view=map&format=html&location_id='.$element->location_id.'">'.$element->location_name.'</a>';
|
||||
$customFields[] = [$location, acym_translation('EB_LOCATION')];
|
||||
}
|
||||
|
||||
if (in_array('cats', $tag->display)) {
|
||||
$categories = acym_loadObjectList(
|
||||
'SELECT cat.id, cat.name
|
||||
FROM #__eb_categories AS cat
|
||||
JOIN #__eb_event_categories AS eventcats ON cat.id = eventcats.category_id
|
||||
WHERE eventcats.event_id = '.intval($tag->id).'
|
||||
ORDER BY cat.name ASC'
|
||||
);
|
||||
|
||||
foreach ($categories as $i => $oneCat) {
|
||||
$categories[$i] = '<a href="index.php?option=com_eventbooking&view=category&id='.$oneCat->id.'">'.acym_escape($oneCat->name).'</a>';
|
||||
}
|
||||
$customFields[] = [implode(', ', $categories), acym_translation('ACYM_CATEGORIES')];
|
||||
}
|
||||
|
||||
if (in_array('capacity', $tag->display)) {
|
||||
$capacity = empty($element->event_capacity) ? acym_translation('EB_UNLIMITED') : $element->event_capacity;
|
||||
$customFields[] = [$capacity, acym_translation('EB_CAPACTIY')];
|
||||
}
|
||||
|
||||
if (in_array('price', $tag->display)) {
|
||||
if ($element->individual_price > 0) {
|
||||
$price = @EventBookingHelper::formatCurrency($element->individual_price, $this->eventbookingconfig, $element->currency_symbol);
|
||||
} else {
|
||||
$price = acym_translation('EB_FREE');
|
||||
}
|
||||
|
||||
$customFields[] = [$price, acym_translation('EB_PRICE')];
|
||||
}
|
||||
|
||||
if (!empty($tag->custom) && !empty($element->custom_fields)) {
|
||||
$customFields = array_merge($customFields, $this->_handleCustomFields($element->custom_fields, $tag->custom));
|
||||
}
|
||||
|
||||
if (in_array('regstart', $tag->display) && $element->registration_start_date > '0001-00-00') {
|
||||
$customFields[] = [acym_date($element->registration_start_date, $this->eventbookingconfig->date_format, null), acym_translation('EB_REGISTRATION_START_DATE')];
|
||||
}
|
||||
|
||||
if (in_array('cut', $tag->display) && $element->cut_off_date > '0001-00-00') {
|
||||
$customFields[] = [acym_date($element->cut_off_date, $this->eventbookingconfig->date_format, null), acym_translation('EB_CUT_OFF_DATE')];
|
||||
}
|
||||
|
||||
if (in_array('indiv', $tag->display) || in_array('group', $tag->display)) {
|
||||
$value = [];
|
||||
|
||||
if (in_array('indiv', $tag->display)) {
|
||||
$reglink = acym_frontendLink('index.php?option=com_eventbooking&task=register.individual_registration&event_id='.$tag->id, false);
|
||||
$varFields['{individualregbutton}'] = '<a class="event_registration eb_indivreg" href="'.$reglink.'" target="_blank" >'.acym_translation('EB_REGISTER_INDIVIDUAL').'</a> ';
|
||||
$value[] = $varFields['{individualregbutton}'];
|
||||
}
|
||||
|
||||
if (in_array('group', $tag->display)) {
|
||||
$reglink = acym_frontendLink('index.php?option=com_eventbooking&task=register.group_registration&event_id='.$tag->id, false);
|
||||
$varFields['{groupregbutton}'] = '<a class="event_registration eb_groupreg" href="'.$reglink.'" target="_blank" >'.acym_translation('EB_REGISTER_GROUP').'</a> ';
|
||||
$value[] = $varFields['{groupregbutton}'];
|
||||
}
|
||||
|
||||
$customFields[] = [implode(' ', $value)];
|
||||
}
|
||||
|
||||
$varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.acym_translation('ACYM_READ_MORE').'</span></a>';
|
||||
if (!empty($tag->readmore)) {
|
||||
$afterArticle .= $varFields['{readmore}'];
|
||||
}
|
||||
|
||||
$format = new stdClass();
|
||||
$format->tag = $tag;
|
||||
$format->title = $title;
|
||||
$format->afterTitle = $afterTitle;
|
||||
$format->afterArticle = $afterArticle;
|
||||
$format->imagePath = $imagePath;
|
||||
$format->description = $contentText;
|
||||
$format->link = empty($tag->clickable) ? '' : $link;
|
||||
$format->cols = empty($tag->nbcols) ? 1 : intval($tag->nbcols);
|
||||
$format->customFields = $customFields;
|
||||
$result = '<div class="acymailing_content">'.$this->acympluginHelper->getStandardDisplay($format).'</div>';
|
||||
|
||||
return $this->finalizeElementFormat($this->name, $result, $tag, $varFields);
|
||||
}
|
||||
|
||||
private function _handleCustomFields($customFields, $selected)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if (!file_exists(JPATH_ROOT.DS.'components'.DS.'com_eventbooking'.DS.'fields.xml')) return $result;
|
||||
|
||||
$xml = JFactory::getXML(JPATH_ROOT.'/components/com_eventbooking/fields.xml');
|
||||
$fields = $xml->fields->fieldset->children();
|
||||
$params = new JRegistry();
|
||||
$params->loadString($customFields, 'INI');
|
||||
$decodedFields = json_decode($customFields);
|
||||
|
||||
foreach ($fields as $oneCustomField) {
|
||||
$name = $oneCustomField->attributes()->name;
|
||||
$label = acym_translation($oneCustomField->attributes()->label);
|
||||
$value = $params->get($name);
|
||||
$name = (string)$name;
|
||||
|
||||
if ($value === null && !empty($decodedFields) && !empty($decodedFields->$name)) {
|
||||
$value = $decodedFields->$name;
|
||||
}
|
||||
|
||||
if (empty($value) || !in_array($name, $selected)) continue;
|
||||
|
||||
$result[] = [$value, $label];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function searchEvent()
|
||||
{
|
||||
$id = acym_getVar('int', 'id');
|
||||
if (!empty($id)) {
|
||||
$subject = acym_loadResult('SELECT `title` FROM #__eb_events WHERE `id` = '.intval($id));
|
||||
if (empty($subject)) $subject = '';
|
||||
echo json_encode(['value' => $id.' - '.$subject]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$search = acym_getVar('cmd', 'search', '');
|
||||
$products = acym_loadObjectList('SELECT `id`, `title` FROM `#__eb_events` WHERE `title` LIKE '.acym_escapeDB('%'.$search.'%').' ORDER BY `title` ASC');
|
||||
|
||||
foreach ($products as $oneProduct) {
|
||||
$return[] = [$oneProduct->id, $oneProduct->id.' - '.$oneProduct->title];
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
acym_loadLanguageFile('com_eventbooking', JPATH_SITE);
|
||||
|
||||
$conditions['user']['ebregistration'] = new stdClass();
|
||||
$conditions['user']['ebregistration']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'Event Booking', acym_translation('EB_REGISTRANTS'));
|
||||
$conditions['user']['ebregistration']->option = '<div class="cell grid-x grid-margin-x">';
|
||||
|
||||
$conditions['user']['ebregistration']->option .= '<div class="intext_select_automation cell">';
|
||||
$ajaxParams = json_encode(
|
||||
[
|
||||
'plugin' => __CLASS__,
|
||||
'trigger' => 'searchEvent',
|
||||
]
|
||||
);
|
||||
$conditions['user']['ebregistration']->option .= acym_select(
|
||||
[],
|
||||
'acym_condition[conditions][__numor__][__numand__][ebregistration][event]',
|
||||
null,
|
||||
'class="acym__select acym_select2_ajax" data-placeholder="'.acym_translation('ACYM_ANY_EVENT', true).'" data-params="'.acym_escape($ajaxParams).'"'
|
||||
);
|
||||
$conditions['user']['ebregistration']->option .= '</div>';
|
||||
|
||||
$status = [];
|
||||
$status[] = acym_selectOption('-1', 'ACYM_STATUS');
|
||||
$status[] = acym_selectOption('0', 'EB_PENDING');
|
||||
$status[] = acym_selectOption('1', 'EB_PAID');
|
||||
$status[] = acym_selectOption('2', 'EB_CANCELLED');
|
||||
|
||||
$conditions['user']['ebregistration']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['ebregistration']->option .= acym_select($status, 'acym_condition[conditions][__numor__][__numand__][ebregistration][status]', '-1', 'class="acym__select"');
|
||||
$conditions['user']['ebregistration']->option .= '</div>';
|
||||
|
||||
$conditions['user']['ebregistration']->option .= '</div>';
|
||||
|
||||
$conditions['user']['ebregistration']->option .= '<div class="cell grid-x grid-margin-x">';
|
||||
$conditions['user']['ebregistration']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][ebregistration][datemin]', '', 'cell shrink');
|
||||
$conditions['user']['ebregistration']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink"><</span>';
|
||||
$conditions['user']['ebregistration']->option .= '<span class="acym_vcenter">'.acym_translation('EB_REGISTRATION_DATE').'</span>';
|
||||
$conditions['user']['ebregistration']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink"><</span>';
|
||||
$conditions['user']['ebregistration']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][ebregistration][datemax]', '', 'cell shrink');
|
||||
$conditions['user']['ebregistration']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_ebregistration(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_ebregistration($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
private function processConditionFilter_ebregistration(&$query, $options, $num)
|
||||
{
|
||||
$query->join['ebregistration'.$num] = '`#__eb_registrants` AS eventbooking'.$num.' ON (
|
||||
eventbooking'.$num.'.email = user.email
|
||||
OR (
|
||||
eventbooking'.$num.'.user_id != 0
|
||||
AND eventbooking'.$num.'.user_id = user.cms_id
|
||||
)
|
||||
)';
|
||||
|
||||
if (!empty($options['event'])) $query->where[] = 'eventbooking'.$num.'.event_id = '.intval($options['event']);
|
||||
if (!empty($options['status']) && $options['status'] != -1) $query->where[] = 'eventbooking'.$num.'.published = '.intval($options['status']);
|
||||
|
||||
if (!empty($options['datemin'])) {
|
||||
$options['datemin'] = acym_replaceDate($options['datemin']);
|
||||
if (!is_numeric($options['datemin'])) $options['datemin'] = strtotime($options['datemin']);
|
||||
if (!empty($options['datemin'])) {
|
||||
$query->where[] = 'eventbooking'.$num.'.register_date > '.acym_escapeDB(date('Y-m-d H:i:s', $options['datemin']));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($options['datemax'])) {
|
||||
$options['datemax'] = acym_replaceDate($options['datemax']);
|
||||
if (!is_numeric($options['datemax'])) $options['datemax'] = strtotime($options['datemax']);
|
||||
if (!empty($options['datemax'])) {
|
||||
$query->where[] = 'eventbooking'.$num.'.register_date < '.acym_escapeDB(date('Y-m-d H:i:s', $options['datemax']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
$this->summaryConditionFilters($automationCondition);
|
||||
}
|
||||
|
||||
private function summaryConditionFilters(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['ebregistration'])) {
|
||||
if (empty($automationCondition['ebregistration']['event'])) {
|
||||
$event = acym_translation('ACYM_ANY_EVENT');
|
||||
} else {
|
||||
$event = acym_loadResult('SELECT `title` FROM #__eb_events WHERE `id` = '.intval($automationCondition['ebregistration']['event']));
|
||||
}
|
||||
|
||||
$status = [
|
||||
'-1' => 'ACYM_ANY',
|
||||
'0' => 'EB_PENDING',
|
||||
'1' => 'EB_PAID',
|
||||
'2' => 'EB_CANCELLED',
|
||||
];
|
||||
|
||||
$status = acym_translation($status[$automationCondition['ebregistration']['status']]);
|
||||
|
||||
$finalText = acym_translation_sprintf('ACYM_REGISTERED', $event, $status);
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['ebregistration']['datemin'])) {
|
||||
$dates[] = acym_translation('ACYM_AFTER').' '.acym_replaceDate($automationCondition['ebregistration']['datemin'], true);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['ebregistration']['datemax'])) {
|
||||
$dates[] = acym_translation('ACYM_BEFORE').' '.acym_replaceDate($automationCondition['ebregistration']['datemax'], true);
|
||||
}
|
||||
|
||||
if (!empty($dates)) {
|
||||
$finalText .= ' '.implode(' '.acym_translation('ACYM_AND').' ', $dates);
|
||||
}
|
||||
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$newFilters = [];
|
||||
|
||||
$this->onAcymDeclareConditions($newFilters);
|
||||
foreach ($newFilters as $oneType) {
|
||||
foreach ($oneType as $oneFilterName => $oneFilter) {
|
||||
if (!empty($oneFilter->option)) $oneFilter->option = str_replace(['acym_condition', '[conditions]'], ['acym_action', '[filters]'], $oneFilter->option);
|
||||
$filters[$oneFilterName] = $oneFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_ebregistration(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_ebregistration($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_ebregistration(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_ebregistration($query, $options, $num);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
$this->summaryConditionFilters($automationFilter);
|
||||
}
|
||||
|
||||
public function onAcymDeclareTriggers(&$triggers, &$defaultValues)
|
||||
{
|
||||
|
||||
$every = [
|
||||
'3600' => acym_translation('ACYM_HOURS'),
|
||||
'86400' => acym_translation('ACYM_DAYS'),
|
||||
];
|
||||
|
||||
$when = [
|
||||
'before' => acym_translation('ACYM_BEFORE'),
|
||||
'after' => acym_translation('ACYM_AFTER'),
|
||||
];
|
||||
|
||||
$categories = acym_loadObjectList('SELECT `id`, `name` FROM #__eb_categories', 'id');
|
||||
|
||||
foreach ($categories as $key => $category) {
|
||||
$categories[$key] = $category->name;
|
||||
}
|
||||
|
||||
$categories = ['' => acym_translation('ACYM_ANY_CATEGORY')] + $categories;
|
||||
|
||||
$triggers['classic']['eventbooking_reminder'] = new stdClass();
|
||||
$triggers['classic']['eventbooking_reminder']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'EventBooking', acym_translation('ACYM_REMINDER'));
|
||||
$triggers['classic']['eventbooking_reminder']->option = '<div class="grid-x cell acym_vcenter"><div class="grid-x cell grid-margin-x acym_vcenter margin-bottom-1">';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '<div class="cell medium-shrink">
|
||||
<input
|
||||
type="number"
|
||||
name="[triggers][classic][eventbooking_reminder][number]"
|
||||
class="intext_input"
|
||||
value="'.(empty($defaultValues['eventbooking_reminder']) ? '1' : $defaultValues['eventbooking_reminder']['number']).'">
|
||||
</div>';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '<div class="cell medium-shrink">'.acym_select(
|
||||
$every,
|
||||
'[triggers][classic][eventbooking_reminder][time]',
|
||||
empty($defaultValues['eventbooking_reminder']) ? '86400' : $defaultValues['eventbooking_reminder']['time'],
|
||||
'data-class="intext_select acym__select"'
|
||||
).'</div></div>';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '<div class="grid-x cell grid-margin-x acym_vcenter margin-bottom-1"><div class="cell medium-shrink">'.acym_select(
|
||||
$when,
|
||||
'[triggers][classic][eventbooking_reminder][when]',
|
||||
empty($defaultValues['eventbooking_reminder']) ? 'before' : $defaultValues['eventbooking_reminder']['when'],
|
||||
'data-class="intext_select acym__select"'
|
||||
).'</div>';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '<div class="cell medium-shrink">'.acym_translation('ACYM_AN_EVENT_IN').'</div>';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '<div class="cell medium-auto">'.acym_select(
|
||||
$categories,
|
||||
'[triggers][classic][eventbooking_reminder][cat]',
|
||||
empty($defaultValues['eventbooking_reminder']) ? '' : $defaultValues['eventbooking_reminder']['cat'],
|
||||
'data-class="intext_select_larger intext_select acym__select"'
|
||||
).'</div>';
|
||||
$triggers['classic']['eventbooking_reminder']->option .= '</div></div>';
|
||||
}
|
||||
|
||||
public function onAcymExecuteTrigger(&$step, &$execute, $data)
|
||||
{
|
||||
$time = $data['time'];
|
||||
$triggers = json_decode($step->triggers, true);
|
||||
|
||||
if (!empty($triggers['eventbooking_reminder']['number'])) {
|
||||
$config = acym_config();
|
||||
$triggerReminder = $triggers['eventbooking_reminder'];
|
||||
|
||||
$timestamp = ($triggerReminder['number'] * $triggerReminder['time']);
|
||||
|
||||
if ($triggerReminder['when'] == 'before') {
|
||||
$timestamp += $time;
|
||||
} else {
|
||||
$timestamp -= $time;
|
||||
}
|
||||
|
||||
|
||||
$join = [];
|
||||
$where = [];
|
||||
|
||||
if (!empty($triggerReminder['cat'])) {
|
||||
$join[] = 'LEFT JOIN #__eb_event_categories as cat ON `event`.`id` = `cat`.`event_id`';
|
||||
$where[] = '`cat`.`category_id` = '.intval($triggerReminder['cat']);
|
||||
}
|
||||
|
||||
$where[] = '`event`.`event_date` >= '.acym_escapeDB(acym_date($timestamp, 'Y-m-d H:i:s', true));
|
||||
$where[] = '`event`.`event_date` <= '.acym_escapeDB(acym_date($timestamp + $config->get('cron_frequency', '900'), 'Y-m-d H:i:s', true));
|
||||
$where[] = '`event`.`published` = 1';
|
||||
|
||||
$events = acym_loadObjectList('SELECT * FROM `#__eb_events` as event '.implode(' ', $join).' WHERE '.implode(' AND ', $where));
|
||||
if (!empty($events)) $execute = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_triggers(&$automation)
|
||||
{
|
||||
if (!empty($automation->triggers['eventbooking_reminder'])) {
|
||||
$every = [
|
||||
'3600' => acym_translation('ACYM_HOURS'),
|
||||
'86400' => acym_translation('ACYM_DAYS'),
|
||||
];
|
||||
|
||||
$when = [
|
||||
'before' => acym_translation('ACYM_BEFORE'),
|
||||
'after' => acym_translation('ACYM_AFTER'),
|
||||
];
|
||||
|
||||
$categories = acym_loadObjectList('SELECT `id`, `name` FROM #__eb_categories', 'id');
|
||||
|
||||
foreach ($categories as $key => $category) {
|
||||
$categories[$key] = $category->name;
|
||||
}
|
||||
|
||||
$categories = ['' => acym_translation('ACYM_ANY_CATEGORY')] + $categories;
|
||||
|
||||
$final = $automation->triggers['eventbooking_reminder']['number'].' ';
|
||||
$final .= $every[$automation->triggers['eventbooking_reminder']['time']].' ';
|
||||
$final .= $when[$automation->triggers['eventbooking_reminder']['when']].' ';
|
||||
$final .= acym_translation('ACYM_AN_EVENT_IN').' '.strtolower($categories[$automation->triggers['eventbooking_reminder']['cat']]);
|
||||
|
||||
$automation->triggers['eventbooking_reminder'] = $final;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,872 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymJevents extends acymPlugin
|
||||
{
|
||||
var $imgFolder = '';
|
||||
var $useStdTime;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_jevents'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
$this->name = 'jevents';
|
||||
}
|
||||
|
||||
public function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = 'JEvents';
|
||||
$plugin->icon = ACYM_DYNAMICS_URL.basename(__DIR__).'/icon.ico';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
public function contentPopup()
|
||||
{
|
||||
acym_loadLanguageFile('com_jevents', JPATH_SITE);
|
||||
|
||||
$this->categories = acym_loadObjectList('SELECT id, parent_id, title FROM `#__categories` WHERE extension = "com_jevents"', 'id');
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
$tabHelper->startTab(acym_translation('ACYM_ONE_BY_ONE'));
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'radio',
|
||||
'name' => 'type',
|
||||
'options' => [
|
||||
'title' => 'ACYM_TITLE_ONLY',
|
||||
'full' => 'ACYM_FULL_TEXT',
|
||||
],
|
||||
'default' => 'full',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_READ_MORE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'readmore',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TRUNCATE',
|
||||
'type' => 'intextfield',
|
||||
'name' => 'wrap',
|
||||
'text' => 'ACYM_TRUNCATE_AFTER',
|
||||
'default' => 0,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
];
|
||||
|
||||
if (file_exists(JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevfiles'.DS.'jevfiles.php')) {
|
||||
$displayOptions[] = [
|
||||
'title' => 'ACY_FILES',
|
||||
'type' => 'boolean',
|
||||
'name' => 'pluginFields',
|
||||
'default' => true,
|
||||
];
|
||||
}
|
||||
|
||||
if (file_exists(JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevcustomfields')) {
|
||||
$jevCFParams = acym_loadObject('SELECT params FROM #__extensions WHERE element = "jevcustomfields"');
|
||||
if (!empty($jevCFParams->params)) {
|
||||
$template = json_decode($jevCFParams->params)->template;
|
||||
}
|
||||
if (!empty($template)) {
|
||||
$xmlfile = JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevcustomfields'.DS.'customfields'.DS.'templates'.DS.$template;
|
||||
if (file_exists($xmlfile)) {
|
||||
$xml = simplexml_load_file($xmlfile);
|
||||
$jevCf = $xml->xpath('//fields/fieldset/field');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($jevCf)) {
|
||||
$customField = [
|
||||
'title' => 'ACYM_FIELDS_TO_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'custom',
|
||||
'separator' => ', ',
|
||||
'options' => [],
|
||||
];
|
||||
foreach ($jevCf as $oneParam) {
|
||||
$name = $oneParam->attributes()->name;
|
||||
$label = $oneParam->attributes()->label;
|
||||
if (!empty($name) && !empty($label)) {
|
||||
$customField['options'][$name] = [$label, false];
|
||||
}
|
||||
}
|
||||
|
||||
$displayOptions[] = $customField;
|
||||
}
|
||||
}
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone();
|
||||
|
||||
$this->displayListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
$tabHelper->startTab(acym_translation('ACYM_BY_CATEGORY'));
|
||||
|
||||
$catOptions = [
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'text',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'id' => 'ACYM_ID',
|
||||
'startrepeat' => 'JEV_EVENT_STARTDATE',
|
||||
'endrepeat' => 'JEV_EVENT_ENDDATE',
|
||||
'summary' => 'ACYM_TITLE',
|
||||
'rand' => 'ACYM_RANDOM',
|
||||
],
|
||||
'default' => 'startrepeat',
|
||||
'defaultdir' => 'asc',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_FROM',
|
||||
'type' => 'date',
|
||||
'name' => 'from',
|
||||
'default' => date('Y-m-d'),
|
||||
'relativeDate' => '+',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TO',
|
||||
'type' => 'date',
|
||||
'name' => 'to',
|
||||
'default' => '',
|
||||
'relativeDate' => '+',
|
||||
],
|
||||
];
|
||||
|
||||
if (file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jevlocations')) {
|
||||
$locs = acym_loadObjectList('SELECT loc_id, title, city, state, country FROM #__jev_locations');
|
||||
|
||||
if (!empty($locs)) {
|
||||
$allCities = [0 => 'ACYM_ALL'];
|
||||
$allStates = [0 => 'ACYM_ALL'];
|
||||
$allCountries = [0 => 'ACYM_ALL'];
|
||||
$locations = [0 => 'ACYM_ALL'];
|
||||
foreach ($locs as $oneLoc) {
|
||||
$locations[$oneLoc->loc_id] = $oneLoc->title;
|
||||
|
||||
if (!empty($oneLoc->city)) $allCities[$oneLoc->city] = $oneLoc->city;
|
||||
if (!empty($oneLoc->state)) $allStates[$oneLoc->state] = $oneLoc->state;
|
||||
if (!empty($oneLoc->country)) $allCountries[$oneLoc->country] = $oneLoc->country;
|
||||
}
|
||||
|
||||
$catOptions[] = [
|
||||
'title' => 'ACYM_LOCATION',
|
||||
'type' => 'select',
|
||||
'name' => 'location',
|
||||
'options' => $locations,
|
||||
];
|
||||
|
||||
$catOptions[] = [
|
||||
'title' => 'ACYM_COUNTRY',
|
||||
'type' => 'select',
|
||||
'name' => 'country',
|
||||
'options' => $allCountries,
|
||||
];
|
||||
|
||||
$catOptions[] = [
|
||||
'title' => 'ACYM_STATE',
|
||||
'type' => 'select',
|
||||
'name' => 'state',
|
||||
'options' => $allStates,
|
||||
];
|
||||
|
||||
$catOptions[] = [
|
||||
'title' => 'ACYM_CITY',
|
||||
'type' => 'select',
|
||||
'name' => 'city',
|
||||
'options' => $allCities,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$displayOptions = array_merge($displayOptions, $catOptions);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'auto'.$this->name, 'grouped');
|
||||
|
||||
echo $this->getCategoryListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
|
||||
public function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT rpt.*, detail.*, cat.title AS cattitle ';
|
||||
$query = 'FROM `#__jevents_repetition` AS rpt ';
|
||||
$query .= 'JOIN `#__jevents_vevent` AS ev ON rpt.eventid = ev.ev_id ';
|
||||
$query .= 'JOIN `#__categories` AS cat ON ev.catid = cat.id ';
|
||||
$query .= 'JOIN `#__jevents_vevdetail` AS detail ON ev.detail_id = detail.evdet_id ';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'rpt.startrepeat';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['rpt.rp_id', 'detail.evdet_id', 'detail.description', 'detail.summary', 'detail.contact', 'detail.location'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(" LIKE ".acym_escapeDB($searchVal)." OR ", $searchFields)." LIKE ".acym_escapeDB($searchVal);
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->filter_cat)) {
|
||||
$filters[] = "ev.catid = ".intval($this->pageInfo->filter_cat);
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->order)) {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
}
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'summary' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '5',
|
||||
],
|
||||
'startrepeat' => [
|
||||
'label' => 'ACYM_DATE',
|
||||
'size' => '3',
|
||||
'type' => 'date',
|
||||
],
|
||||
'cattitle' => [
|
||||
'label' => 'ACYM_CATEGORY',
|
||||
'size' => '3',
|
||||
],
|
||||
'rp_id' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'rp_id',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
public function replaceContent(&$email)
|
||||
{
|
||||
$this->_replaceAuto($email);
|
||||
$this->_replaceOne($email);
|
||||
}
|
||||
|
||||
public function _replaceAuto(&$email)
|
||||
{
|
||||
$this->generateByCategory($email);
|
||||
if (empty($this->tags)) return;
|
||||
$this->acympluginHelper->replaceTags($email, $this->tags, true);
|
||||
}
|
||||
|
||||
public function generateByCategory(&$email)
|
||||
{
|
||||
$time = time();
|
||||
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'auto'.$this->name);
|
||||
$return = new stdClass();
|
||||
$return->status = true;
|
||||
$return->message = '';
|
||||
$this->tags = [];
|
||||
|
||||
if (empty($tags)) return $return;
|
||||
|
||||
$multicat = JComponentHelper::getParams('com_jevents')->get('multicategory', 0);
|
||||
|
||||
foreach ($tags as $oneTag => $parameter) {
|
||||
if (isset($this->tags[$oneTag])) continue;
|
||||
|
||||
$where = [];
|
||||
$where[] = 'ev.`state` = 1';
|
||||
|
||||
$query = 'SELECT DISTINCT rpt.rp_id FROM `#__jevents_repetition` AS rpt ';
|
||||
$query .= ' JOIN `#__jevents_vevent` AS ev ON rpt.eventid = ev.ev_id ';
|
||||
|
||||
if (empty($parameter->order)) $parameter->order = 'startrepeat,ASC';
|
||||
if (empty($parameter->from)) {
|
||||
$parameter->from = date('Y-m-d H:i:s', $time);
|
||||
} else {
|
||||
$parameter->from = acym_date(acym_replaceDate($parameter->from), 'Y-m-d H:i:s');
|
||||
}
|
||||
if (!empty($parameter->to)) $parameter->to = acym_date(acym_replaceDate($parameter->to), 'Y-m-d H:i:s');
|
||||
|
||||
if (!empty($parameter->id)) {
|
||||
$allCats = explode('-', $parameter->id);
|
||||
array_pop($allCats);
|
||||
if (!empty($allCats)) {
|
||||
acym_arrayToInteger($allCats);
|
||||
$catToSearch = implode(',', $allCats);
|
||||
if ($multicat == 1) {
|
||||
$query .= ' JOIN `#__jevents_catmap` AS cats ON ev.ev_id = cats.evid ';
|
||||
$where[] = 'cats.catid IN ('.$catToSearch.')';
|
||||
} else {
|
||||
$where[] = 'ev.catid IN ('.$catToSearch.')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$locationColumn = '';
|
||||
if (empty($parameter->location)) {
|
||||
if (!empty($parameter->country)) $locationColumn = 'country';
|
||||
if (!empty($parameter->state)) $locationColumn = 'state';
|
||||
if (!empty($parameter->city)) $locationColumn = 'city';
|
||||
}
|
||||
|
||||
if (isset($parameter->priority) || !empty($parameter->location) || !empty($locationColumn) || strpos($parameter->order, 'summary') !== false) {
|
||||
$query .= ' JOIN `#__jevents_vevdetail` AS evdet ON ev.detail_id = evdet.evdet_id ';
|
||||
}
|
||||
|
||||
if (!empty($locationColumn)) {
|
||||
$query .= ' JOIN `#__jev_locations` AS evloc ON evdet.location = evloc.loc_id';
|
||||
$where[] = 'evloc.'.$locationColumn.' = '.acym_escapeDB($parameter->$locationColumn);
|
||||
}
|
||||
|
||||
if (!empty($parameter->location)) {
|
||||
$where[] = 'evdet.location = '.intval($parameter->location);
|
||||
}
|
||||
|
||||
if (isset($parameter->priority)) {
|
||||
$parameter->priority = explode(',', $parameter->priority);
|
||||
acym_arrayToInteger($parameter->priority);
|
||||
$where[] = 'evdet.priority IN ('.implode(',', $parameter->priority).')';
|
||||
}
|
||||
|
||||
if ((empty($parameter->mindelay) || substr($parameter->mindelay, 0, 1) != '-') && (empty($parameter->delay) || substr($parameter->delay, 0, 1) != '-')) {
|
||||
if (!empty($parameter->addcurrent)) {
|
||||
$where[] = 'rpt.`endrepeat` >= '.acym_escapeDB($parameter->from);
|
||||
} else {
|
||||
$where[] = 'rpt.`startrepeat` >= '.acym_escapeDB($parameter->from);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($parameter->todaysevent)) {
|
||||
$where[] = 'rpt.`startrepeat` <= '.acym_escapeDB(date('Y-m-d 23:59:59', $time));
|
||||
}
|
||||
|
||||
if (!empty($parameter->mindelay)) $where[] = 'rpt.`startrepeat` >= '.acym_escapeDB(date('Y-m-d H:i:s', $time + $parameter->mindelay));
|
||||
if (!empty($parameter->delay)) $where[] = 'rpt.`startrepeat` <= '.acym_escapeDB(date('Y-m-d H:i:s', $time + $parameter->delay));
|
||||
if (!empty($parameter->to)) $where[] = 'rpt.`startrepeat` <= '.acym_escapeDB($parameter->to);
|
||||
|
||||
if (isset($parameter->access)) {
|
||||
$where[] = 'ev.`access` = '.intval($parameter->access);
|
||||
}
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $where).')';
|
||||
|
||||
$ordering = explode(',', $parameter->order);
|
||||
if ($ordering[0] == 'rand') {
|
||||
$query .= ' ORDER BY rand()';
|
||||
} else {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn(trim($ordering[0])).' '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
|
||||
if (!empty($parameter->max)) $query .= ' LIMIT '.intval($parameter->max);
|
||||
|
||||
$allArticles = acym_loadResultArray($query);
|
||||
|
||||
if (!empty($parameter->min) && count($allArticles) < $parameter->min) {
|
||||
$return->status = false;
|
||||
$return->message = 'Not enough events for the tag '.$oneTag.' : '.count($allArticles).' / '.$parameter->min;
|
||||
}
|
||||
|
||||
$this->tags[$oneTag] = $this->finalizeCategoryFormat($this->name, $allArticles, $parameter);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function _replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
acym_loadLanguageFile('com_jevents', JPATH_SITE);
|
||||
|
||||
if (file_exists(JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevfiles'.DS.'jevfiles.php')) {
|
||||
$JEVplugin = JPluginHelper::getPlugin('jevents', 'jevfiles');
|
||||
$JEVparams = new acymParameter($JEVplugin->params);
|
||||
$imagesFolder = JComponentHelper::getParams('com_media')->get('image_path', 'images');
|
||||
$this->imgFolder = ACYM_LIVE.$imagesFolder.'/'.trim($JEVparams->get('folder', 'jevents'), '/').'/';
|
||||
}
|
||||
|
||||
$this->useStdTime = JComponentHelper::getParams("com_jevents")->get('com_calUseStdTime');
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $params) {
|
||||
if (isset($tagsReplaced[$i])) continue;
|
||||
|
||||
$tagsReplaced[$i] = $this->_replaceContent($tags[$i]);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
public function _replaceContent(&$tag)
|
||||
{
|
||||
$query = 'SELECT rpt.*, detail.*, cat.title AS category, ev.catid, ev.uid FROM `#__jevents_repetition` AS rpt ';
|
||||
$query .= ' JOIN `#__jevents_vevent` AS ev ON rpt.eventid = ev.ev_id ';
|
||||
$query .= ' JOIN `#__jevents_vevdetail` AS detail ON rpt.eventdetail_id = detail.evdet_id ';
|
||||
$query .= 'LEFT JOIN `#__categories` AS cat ON cat.id = ev.catid ';
|
||||
$query .= 'WHERE rpt.rp_id = '.intval($tag->id).' LIMIT 1';
|
||||
|
||||
$element = acym_loadObject($query);
|
||||
|
||||
if (empty($element)) {
|
||||
if (acym_isAdmin()) acym_enqueueMessage('The event "'.$tag->id.'" could not be loaded', 'notice');
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->acympluginHelper->translateItem($element, $tag, 'jevents_vevdetail', $element->evdet_id);
|
||||
|
||||
if (file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jevlocations') && !empty($element->location) && is_numeric($element->location)) {
|
||||
$query = 'SELECT title, street, postcode, city, state, country FROM `#__jev_locations` WHERE loc_id = '.intval($element->location);
|
||||
$location = acym_loadObject($query);
|
||||
if (!empty($location)) {
|
||||
foreach ($location as $prop => $value) {
|
||||
$element->$prop = $value;
|
||||
}
|
||||
$element->location = $location->title;
|
||||
}
|
||||
}
|
||||
|
||||
$varFields = [];
|
||||
foreach ($element as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$startdate = acym_date($element->startrepeat, acym_translation('ACYM_DATE_FORMAT_LC1'), null);
|
||||
$enddate = acym_date($element->endrepeat, acym_translation('ACYM_DATE_FORMAT_LC1'), null);
|
||||
$starttime = substr($element->startrepeat, 11, 5);
|
||||
$endtime = substr($element->endrepeat, 11, 5);
|
||||
|
||||
if ($starttime == '00:00') {
|
||||
$starttime = '';
|
||||
$endtime = '';
|
||||
} elseif ($element->noendtime) {
|
||||
$endtime = '';
|
||||
}
|
||||
|
||||
if (!empty($this->useStdTime)) {
|
||||
if (!empty($starttime)) $starttime = strtolower(strftime("%#I:%M%p", strtotime($element->startrepeat)));
|
||||
if (!empty($endtime)) $endtime = strtolower(strftime("%#I:%M%p", strtotime($element->endrepeat)));
|
||||
}
|
||||
|
||||
$date = $startdate;
|
||||
if (!empty($starttime)) $date .= ' '.$starttime;
|
||||
if ($startdate == $enddate) {
|
||||
if (!empty($endtime)) $date .= ' - '.$endtime;
|
||||
} else {
|
||||
$date .= ' - '.$enddate;
|
||||
if (!empty($endtime)) $date .= ' '.$endtime;
|
||||
}
|
||||
$varFields['{date}'] = $date;
|
||||
|
||||
|
||||
$link = ACYM_LIVE.'index.php?option=com_jevents&task=icalrepeat.detail&evid='.intval($element->rp_id);
|
||||
if (empty($tag->itemid)) {
|
||||
$areaCats = [];
|
||||
$areaCats[] = $element->catid;
|
||||
$cats = acym_loadObjectList('SELECT id, parent_id FROM #__categories', 'id');
|
||||
$position = $element->catid;
|
||||
|
||||
while ($cats[$position]->parent_id != 0) {
|
||||
$areaCats[] = $cats[$position]->parent_id;
|
||||
$position = $cats[$position]->parent_id;
|
||||
}
|
||||
|
||||
$menuId = '';
|
||||
$menus = acym_loadObjectList('SELECT id, params FROM #__menu WHERE link LIKE "index.php?option=com_jevents&view=cat&layout=listevents"');
|
||||
if (!empty($menus)) {
|
||||
foreach ($menus as $i => $menu) {
|
||||
$menus[$i]->params = json_decode($menus[$i]->params);
|
||||
if (empty($menus[$i]->params->catidnew)) continue;
|
||||
foreach ($menus[$i]->params->catidnew as $oneCatid) {
|
||||
if (in_array($oneCatid, $areaCats)) {
|
||||
$menuId = $menus[$i]->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($menuId != '') break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($menuId)) {
|
||||
$summary = str_replace('-', ' ', $element->summary);
|
||||
$summary = trim(strtolower($summary));
|
||||
$summary = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $summary);
|
||||
$summary = trim($summary, '-');
|
||||
$time = explode('-', substr($element->startrepeat, 0, strpos($element->startrepeat, ' ')));
|
||||
$link = 'index.php?option=com_jevents&task=icalrepeat.detail&evid='.intval($element->rp_id).'&year='.intval($time[0]).'&month='.intval($time[1]).'&day='.intval($time[2]).'&title='.$summary.'&uid='.$element->uid;
|
||||
} else {
|
||||
$link .= '&Itemid='.intval($menuId);
|
||||
}
|
||||
} else {
|
||||
$link .= '&Itemid='.intval($tag->itemid);
|
||||
}
|
||||
|
||||
if (!empty($tag->lang)) $link .= '&lang='.substr($tag->lang, 0, strpos($tag->lang, ','));
|
||||
$varFields['{link}'] = $link;
|
||||
|
||||
$title = $element->summary;
|
||||
|
||||
$afterTitle = '';
|
||||
$afterArticle = '';
|
||||
|
||||
$imagePath = '';
|
||||
$contentText = $element->description;
|
||||
$customFields = [];
|
||||
|
||||
if ($tag->type == 'full') {
|
||||
$customFields[] = [$date];
|
||||
|
||||
if (!empty($element->location)) $customFields[] = [$element->location, acym_translation('ACYM_ADDRESS')];
|
||||
|
||||
if (!empty($tag->custom)) {
|
||||
$tag->custom = explode(',', $tag->custom);
|
||||
foreach ($tag->custom as $i => $oneField) {
|
||||
$tag->custom[$i] = trim($oneField);
|
||||
}
|
||||
|
||||
$jevCFParams = acym_loadObject('SELECT params FROM #__extensions WHERE element = "jevcustomfields"');
|
||||
if (!empty($jevCFParams->params)) $template = json_decode($jevCFParams->params)->template;
|
||||
|
||||
if (!empty($template)) {
|
||||
$xmlfile = JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevcustomfields'.DS.'customfields'.DS.'templates'.DS.$template;
|
||||
if (file_exists($xmlfile)) {
|
||||
$xml = simplexml_load_file($xmlfile);
|
||||
$jevCf = $xml->xpath('//fields/fieldset/field');
|
||||
$jevCustomFields = [];
|
||||
foreach ($jevCf as $i => $oneField) {
|
||||
$name = (string)$oneField->attributes()->name;
|
||||
$jevCustomFields[$name] = new stdClass();
|
||||
$jevCustomFields[$name]->label = (string)$oneField->attributes()->label;
|
||||
$jevCustomFields[$name]->type = (string)$oneField->attributes()->type;
|
||||
|
||||
if (empty($oneField->option)) continue;
|
||||
|
||||
$jevCustomFields[$name]->options = [];
|
||||
foreach ($oneField->option as $oneOption) {
|
||||
$jevCustomFields[$name]->options[] = $oneOption;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customVDB = acym_loadObjectList('SELECT name, value FROM #__jev_customfields WHERE evdet_id = '.intval($element->evdet_id));
|
||||
foreach ($customVDB as $oneField) {
|
||||
$varFields['{'.$oneField->name.'}'] = $oneField->value;
|
||||
}
|
||||
|
||||
$customValues = [];
|
||||
foreach ($customVDB as $oneCustomValue) {
|
||||
$customValues[$oneCustomValue->name] = $oneCustomValue->value;
|
||||
}
|
||||
|
||||
if (!empty($customValues)) {
|
||||
foreach ($tag->custom as $oneCustom) {
|
||||
$label = (!empty($jevCustomFields[$oneCustom]->label)) ? $jevCustomFields[$oneCustom]->label : $oneCustom;
|
||||
if (!empty($jevCustomFields[$oneCustom]->options)) {
|
||||
$multipleValues = explode(',', $customValues[$oneCustom]);
|
||||
|
||||
$orderedValues = [];
|
||||
foreach ($multipleValues as $oneValue) {
|
||||
$orderedValues[$oneValue] = $oneValue;
|
||||
}
|
||||
|
||||
$possibleValues = [];
|
||||
foreach ($jevCustomFields[$oneCustom]->options as $oneOption) {
|
||||
$possibleValues[(string)$oneOption->attributes()->value] = (string)$oneOption;
|
||||
}
|
||||
|
||||
foreach ($orderedValues as $key => $j) {
|
||||
$orderedValues[$key] = $possibleValues[$key];
|
||||
}
|
||||
$customValues[$oneCustom] = implode(', ', $orderedValues);
|
||||
} elseif ($jevCustomFields[$oneCustom]->type == 'jevrurl') { //we want a link !
|
||||
$customValues[$oneCustom] = '<a href="'.$customValues[$oneCustom].'">'.$customValues[$oneCustom].'</a>';
|
||||
} elseif ($jevCustomFields[$oneCustom]->type == 'jevrcalendar') {//comprehensible display
|
||||
$customValues[$oneCustom] = acym_getDate(acym_getTime($customValues[$oneCustom]), acym_translation('ACYM_DATE_FORMAT_LC1'));
|
||||
} elseif ($jevCustomFields[$oneCustom]->type == 'jevruser') {//we do not want the user id but its name
|
||||
$user = acym_loadResultArray('SELECT name FROM #__users WHERE id = '.intval($customValues[$oneCustom]));
|
||||
$customValues[$oneCustom] = (empty($user[0])) ? $customValues[$oneCustom] : $user[0];
|
||||
} elseif ($jevCustomFields[$oneCustom]->type == 'jevcfboolean') {
|
||||
$customValues[$oneCustom] = empty($customValues[$oneCustom]) ? acym_translation('ACYM_NO') : acym_translation('ACYM_YES');
|
||||
}
|
||||
|
||||
if (empty($customValues[$oneCustom]) && in_array($jevCustomFields[$oneCustom]->type, ['jevcfuser', 'jevcfyoutube', 'jevcfupdatable', 'jevcfdblist', 'jevcftext', 'jevcfimage', 'jevcffile', 'jevcfhtml', 'jevcfeventflag', 'jevcfnotes'])) {
|
||||
unset($customValues[$oneCustom]);
|
||||
}
|
||||
|
||||
if (isset($customValues[$oneCustom])) $customFields[] = [$customValues[$oneCustom], $label];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($element->contact)) {
|
||||
$value = $element->contact;
|
||||
|
||||
if (acym_isValidEmail($value)) $value = '<a href="mailto:'.$value.'">'.$value.'</a>';
|
||||
|
||||
$customFields[] = [$value, acym_translation('JEV_EVENT_CONTACT')];
|
||||
}
|
||||
if (!empty($element->extra_info)) $customFields[] = [$element->extra_info];
|
||||
}
|
||||
|
||||
if (file_exists(JPATH_SITE.DS.'plugins'.DS.'jevents'.DS.'jevfiles'.DS.'jevfiles.php')) {
|
||||
|
||||
if (in_array(acym_getPrefix().'jev_files_combined', acym_getTableList())) {
|
||||
$filesRow = acym_loadObject(
|
||||
'SELECT files.*
|
||||
FROM `#__jev_files_combined` AS files
|
||||
JOIN #__jevents_repetition AS rpt ON files.ev_id = rpt.eventid
|
||||
WHERE rpt.rp_id = '.intval($tag->id)
|
||||
);
|
||||
|
||||
if (!empty($filesRow)) {
|
||||
for ($i = 1 ; $i < 30 ; $i++) {
|
||||
if (!empty($filesRow->{'imagename'.$i})) {
|
||||
$varFields['{imgpath'.$i.'}'] = $this->imgFolder.$filesRow->{'imagename'.$i};
|
||||
if (empty($imagePath)) {
|
||||
$imagePath = $varFields['{imgpath'.$i.'}'];
|
||||
continue;
|
||||
}
|
||||
$afterArticle .= '<br /><a target="_blank" href="'.$varFields['{imgpath'.$i.'}'].'"><img src="'.$varFields['{imgpath'.$i.'}'].'" alt="" /></a>';
|
||||
}
|
||||
|
||||
if (!empty($filesRow->{'filename'.$i})) {
|
||||
$varFields['{filepath'.$i.'}'] = $this->imgFolder.$filesRow->{'filename'.$i};
|
||||
if (!empty($tag->pluginFields)) $files[] = '<a target="_blank" href="'.$varFields['{filepath'.$i.'}'].'">'.(empty($filesRow->{'filename'.$i}) ? : $filesRow->{'filetitle'.$i}).'</a>';
|
||||
}
|
||||
}
|
||||
if (!empty($files)) $afterArticle .= implode('<br />', $files);
|
||||
}
|
||||
} else {
|
||||
$files = acym_loadObjectList(
|
||||
'SELECT files.*
|
||||
FROM `#__jev_files` AS files
|
||||
JOIN #__jevents_repetition AS rpt ON files.ev_id = rpt.eventid
|
||||
WHERE rpt.rp_id = '.intval($tag->id).'
|
||||
ORDER BY filetype DESC'
|
||||
);
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $i => $oneFile) {
|
||||
if (empty($oneFile->filename)) continue;
|
||||
|
||||
$varFields['{imgpath'.$i.'}'] = $this->imgFolder.$oneFile->filename;
|
||||
if ($oneFile->filetype == 'file') {
|
||||
if (!empty($tag->pluginFields)) $afterArticle .= '<br /><a target="_blank" href="'.$varFields['{imgpath'.$i.'}'].'">'.$oneFile->filetitle.'</a>';
|
||||
} else {
|
||||
if (empty($imagePath)) {
|
||||
$imagePath = $varFields['{imgpath'.$i.'}'];
|
||||
continue;
|
||||
}
|
||||
$afterArticle .= '<br /><a target="_blank" href="'.$varFields['{imgpath'.$i.'}'].'"><img src="'.$varFields['{imgpath'.$i.'}'].'" alt="" /></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.acym_translation('ACYM_READ_MORE').'</span></a>';
|
||||
if (!empty($tag->readmore)) {
|
||||
$afterArticle .= $varFields['{readmore}'];
|
||||
}
|
||||
|
||||
$format = new stdClass();
|
||||
$format->tag = $tag;
|
||||
$format->title = $title;
|
||||
$format->afterTitle = $afterTitle;
|
||||
$format->afterArticle = $afterArticle;
|
||||
$format->imagePath = $imagePath;
|
||||
$format->description = $contentText;
|
||||
$format->link = empty($tag->clickable) ? '' : $link;
|
||||
$format->cols = empty($tag->nbcols) ? 1 : intval($tag->nbcols);
|
||||
$format->customFields = $customFields;
|
||||
$result = '<div class="acymailing_content">'.$this->acympluginHelper->getStandardDisplay($format).'</div>';
|
||||
|
||||
return $this->finalizeElementFormat($this->name, $result, $tag, $varFields);
|
||||
}
|
||||
|
||||
public function onAcymDeclareTriggers(&$triggers, &$defaultValues)
|
||||
{
|
||||
|
||||
$every = [
|
||||
'3600' => acym_translation('ACYM_HOURS'),
|
||||
'86400' => acym_translation('ACYM_DAYS'),
|
||||
];
|
||||
|
||||
$when = [
|
||||
'before' => acym_translation('ACYM_BEFORE'),
|
||||
'after' => acym_translation('ACYM_AFTER'),
|
||||
];
|
||||
|
||||
$categories = acym_loadObjectList('SELECT `id`, `title` FROM #__categories WHERE `extension` = "com_jevents"', 'id');
|
||||
|
||||
foreach ($categories as $key => $category) {
|
||||
$categories[$key] = $category->title;
|
||||
}
|
||||
|
||||
$categories = ['' => acym_translation('ACYM_ANY_CATEGORY')] + $categories;
|
||||
|
||||
$triggers['classic']['jevents_reminder'] = new stdClass();
|
||||
$triggers['classic']['jevents_reminder']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'JEvents', acym_translation('ACYM_REMINDER'));
|
||||
$triggers['classic']['jevents_reminder']->option = '<div class="grid-x cell acym_vcenter"><div class="grid-x cell grid-margin-x acym_vcenter margin-bottom-1">';
|
||||
$triggers['classic']['jevents_reminder']->option .= '<div class="cell medium-shrink">
|
||||
<input
|
||||
type="number"
|
||||
name="[triggers][classic][jevents_reminder][number]"
|
||||
class="intext_input"
|
||||
value="'.(empty($defaultValues['jevents_reminder']) ? '1' : $defaultValues['jevents_reminder']['number']).'">
|
||||
</div>';
|
||||
$triggers['classic']['jevents_reminder']->option .= '<div class="cell medium-shrink">'.acym_select(
|
||||
$every,
|
||||
'[triggers][classic][jevents_reminder][time]',
|
||||
empty($defaultValues['jevents_reminder']) ? '86400' : $defaultValues['jevents_reminder']['time'],
|
||||
'data-class="intext_select acym__select"'
|
||||
).'</div></div>';
|
||||
$triggers['classic']['jevents_reminder']->option .= '<div class="grid-x cell grid-margin-x acym_vcenter margin-bottom-1"><div class="cell medium-shrink">'.acym_select(
|
||||
$when,
|
||||
'[triggers][classic][jevents_reminder][when]',
|
||||
empty($defaultValues['jevents_reminder']) ? 'before' : $defaultValues['jevents_reminder']['when'],
|
||||
'data-class="intext_select acym__select"'
|
||||
).'</div>';
|
||||
$triggers['classic']['jevents_reminder']->option .= '<div class="cell medium-shrink">'.acym_translation('ACYM_AN_EVENT_IN').'</div>';
|
||||
$triggers['classic']['jevents_reminder']->option .= '<div class="cell medium-auto">'.acym_select(
|
||||
$categories,
|
||||
'[triggers][classic][jevents_reminder][cat]',
|
||||
empty($defaultValues['jevents_reminder']) ? '' : $defaultValues['jevents_reminder']['cat'],
|
||||
'data-class="intext_select_larger intext_select acym__select"'
|
||||
).'</div>';
|
||||
$triggers['classic']['jevents_reminder']->option .= '</div></div>';
|
||||
}
|
||||
|
||||
public function onAcymExecuteTrigger(&$step, &$execute, $data)
|
||||
{
|
||||
$time = $data['time'];
|
||||
$triggers = json_decode($step->triggers, true);
|
||||
|
||||
if (!empty($triggers['jevents_reminder']['number'])) {
|
||||
$config = acym_config();
|
||||
$triggerReminder = $triggers['jevents_reminder'];
|
||||
|
||||
$timestamp = ($triggerReminder['number'] * $triggerReminder['time']);
|
||||
|
||||
if ($triggerReminder['when'] == 'before') {
|
||||
$timestamp += $time;
|
||||
} else {
|
||||
$timestamp -= $time;
|
||||
}
|
||||
|
||||
|
||||
$join = [];
|
||||
$where = [];
|
||||
|
||||
if (!empty($triggerReminder['cat'])) {
|
||||
$multicat = JComponentHelper::getParams('com_jevents')->get('multicategory', 0);
|
||||
if ($multicat == 1) {
|
||||
$join[] = 'JOIN #__jevents_catmap AS cats ON rpt.eventid = cats.evid ';
|
||||
$where[] = 'cats.catid = '.intval($triggerReminder['cat']);
|
||||
} else {
|
||||
$join[] = 'LEFT JOIN #__jevents_vevent AS event ON `rpt`.`eventid` = `event`.`ev_id`';
|
||||
$where[] = '`event`.`catid` = '.intval($triggerReminder['cat']);
|
||||
}
|
||||
}
|
||||
$join[] = 'LEFT JOIN #__jevents_vevdetail AS eventd ON `rpt`.`eventdetail_id` = `eventd`.`evdet_id`';
|
||||
|
||||
$where[] = '`rpt`.`startrepeat` >= '.acym_escapeDB(acym_date($timestamp, 'Y-m-d H:i:s'));
|
||||
$where[] = '`rpt`.`startrepeat` <= '.acym_escapeDB(acym_date($timestamp + $config->get('cron_frequency', '900'), 'Y-m-d H:i:s'));
|
||||
$where[] = '`eventd`.`state` = 1';
|
||||
|
||||
$events = acym_loadObjectList('SELECT * FROM `#__jevents_repetition` AS rpt '.implode(' ', $join).' WHERE '.implode(' AND ', $where));
|
||||
if (!empty($events)) $execute = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_triggers(&$automation)
|
||||
{
|
||||
if (!empty($automation->triggers['jevents_reminder'])) {
|
||||
$every = [
|
||||
'3600' => acym_translation('ACYM_HOURS'),
|
||||
'86400' => acym_translation('ACYM_DAYS'),
|
||||
];
|
||||
|
||||
$when = [
|
||||
'before' => acym_translation('ACYM_BEFORE'),
|
||||
'after' => acym_translation('ACYM_AFTER'),
|
||||
];
|
||||
$categories = acym_loadObjectList('SELECT `id`, `title` FROM #__categories WHERE `extension` = "com_jevents"', 'id');
|
||||
|
||||
foreach ($categories as $key => $category) {
|
||||
$categories[$key] = $category->title;
|
||||
}
|
||||
|
||||
$categories = ['' => acym_translation('ACYM_ANY_CATEGORY')] + $categories;
|
||||
|
||||
$final = '';
|
||||
|
||||
$final = $automation->triggers['jevents_reminder']['number'].' ';
|
||||
$final .= $every[$automation->triggers['jevents_reminder']['time']].' ';
|
||||
$final .= $when[$automation->triggers['jevents_reminder']['when']].' ';
|
||||
$final .= acym_translation('ACYM_AN_EVENT_IN').' '.strtolower($categories[$automation->triggers['jevents_reminder']['cat']]);
|
||||
|
||||
$automation->triggers['jevents_reminder'] = $final;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymJomsocial extends acymPlugin
|
||||
{
|
||||
var $lastuserid = 0;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (true || !defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_community'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
}
|
||||
|
||||
function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = 'JomSocial';
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->type = 'joomla';
|
||||
$onePlugin->help = 'plugin-jomsocial';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = 'JomSocial';
|
||||
$plugin->icon = ACYM_DYNAMICS_URL.basename(__DIR__).'/icon.ico';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
function textPopup()
|
||||
{
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
function applyJomSocial(tagname, element) {
|
||||
var string = '{jomsocialfield:' + tagname + '}';
|
||||
setTag(string, jQuery(element));
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$text = '<div class="grid-x acym__popup__listing">';
|
||||
|
||||
|
||||
$otherFields = acym_loadObjectList("SELECT `name`, `id` FROM `#__community_fields` WHERE `type` != 'group' ORDER BY `ordering` ASC");
|
||||
foreach ($otherFields as $oneField) {
|
||||
$text .= '<div class="cell acym__listing__row acym__listing__row__popup" onclick="applyJomSocial(\''.$oneField->id.'\');" >'.$oneField->name.'</div>';
|
||||
}
|
||||
|
||||
$fields = acym_getColumns('community_users', false);
|
||||
foreach ($fields as $fieldname) {
|
||||
$type = '';
|
||||
if (strpos(strtolower($fieldname), 'date') !== false) {
|
||||
$type = '|type:date';
|
||||
}
|
||||
if (!empty($fieldType[$fieldname]) && $fieldType[$fieldname]->type == 'image') {
|
||||
$type = '|type:image';
|
||||
}
|
||||
$text .= '<div class="cell acym__listing__row acym__listing__row__popup" onclick="applyJomSocial(\''.$fieldname.$type.'\', this);" >'.$fieldname.'</div>';
|
||||
}
|
||||
|
||||
$text .= '</div>';
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$extractedTags = $this->acympluginHelper->extractTags($email, 'jomsocialfield');
|
||||
if (empty($extractedTags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tags = [];
|
||||
foreach ($extractedTags as $i => $oneTag) {
|
||||
if (isset($tags[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty ($user->cms_id)) {
|
||||
$tags[$i] = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($user->cms_id != $this->lastuserid) {
|
||||
$this->lastuserid = $user->cms_id;
|
||||
$this->valuesNum = null;
|
||||
$this->valuesString = null;
|
||||
}
|
||||
|
||||
|
||||
$field = $oneTag->id;
|
||||
|
||||
if (is_numeric($field)) {
|
||||
if ($this->valuesNum === null) {
|
||||
$this->valuesNum = acym_loadObjectList('SELECT `field_id`,`value` FROM #__community_fields_values WHERE user_id = '.intval($user->cms_id), 'field_id');
|
||||
}
|
||||
if (isset($this->valuesNum[$field]->value)) {
|
||||
$tags[$i] = $this->valuesNum[$field]->value;
|
||||
}
|
||||
} else {
|
||||
if ($this->valuesString === null) {
|
||||
$this->valuesString = acym_loadObject('SELECT * FROM #__community_users WHERE userid = '.intval($user->cms_id));
|
||||
}
|
||||
|
||||
if (isset($this->valuesString->$field)) {
|
||||
$tags[$i] = $this->valuesString->$field;
|
||||
}
|
||||
|
||||
if (in_array($field, ['avatar', 'thumb']) && !empty($this->valuesString->$field)) {
|
||||
$tags[$i] = '<img src="'.ACYM_LIVE.$this->valuesString->$field.'"/>';
|
||||
if (!empty($oneTag->maxheight) || !empty($oneTag->maxwidth)) {
|
||||
$tags[$i] = $this->acympluginHelper->managePicts($oneTag, $tags[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
function contentPopup()
|
||||
{
|
||||
acym_loadLanguageFile('com_community', JPATH_SITE);
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
|
||||
$tabHelper->startTab(acym_translation('ACYM_USERS'));
|
||||
|
||||
$attributes = [
|
||||
'title' => 'ACYM_TITLE',
|
||||
'karma' => 'COM_COMMUNITY_KARMA',
|
||||
'email' => 'COM_COMMUNITY_EMAIL',
|
||||
'registerdate' => 'COM_COMMUNITY_MEMBER_SINCE',
|
||||
'lastvisitdate' => 'COM_COMMUNITY_LAST_LOGIN',
|
||||
'views' => 'COM_COMMUNITY_PROFILE_VIEW',
|
||||
'friends' => 'COM_COMMUNITY_PROFILE_FRIENDS',
|
||||
];
|
||||
|
||||
$extraFields = acym_loadObjectList(
|
||||
"SELECT `name`, `fieldcode`
|
||||
FROM `#__community_fields`
|
||||
WHERE `type` != 'group'
|
||||
ORDER BY `ordering` ASC"
|
||||
);
|
||||
|
||||
$extra = [];
|
||||
foreach ($extraFields as $field) {
|
||||
$extra[strtolower($field->fieldcode)] = $field->name;
|
||||
}
|
||||
|
||||
$attributes = array_merge($attributes, $extra);
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'fields',
|
||||
'options' => $attributes,
|
||||
'default' => 'full',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_IMAGE_REQUIRED',
|
||||
'type' => 'boolean',
|
||||
'name' => 'required',
|
||||
'default' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'u.registerDate' => 'ACYM_DATE_CREATED',
|
||||
'u.lastvisitDate' => 'COM_COMMUNITY_LAST_LOGIN',
|
||||
'c.view' => 'COM_COMMUNITY_PROFILE_VIEW',
|
||||
'c.points' => 'COM_COMMUNITY_KARMA',
|
||||
'rand()' => 'ACYM_RANDOM',
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'Number of characters ("About me" field)',
|
||||
'type' => 'text',
|
||||
'name' => 'chars',
|
||||
'default' => 150,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'text',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'jomsocialusers', 'simple');
|
||||
|
||||
$tabHelper->endTab();
|
||||
$tabHelper->startTab(acym_translation('COM_COMMUNITY_VIDEOS'));
|
||||
|
||||
|
||||
$attributes = [
|
||||
'description' => acym_translation('COM_COMMUNITY_VIDEOS_DESCRIPTION'),
|
||||
'duration' => trim(acymailing_translation('COM_COMMUNITY_VIDEOS_DURATION'), ': '),
|
||||
'uploadedby' => acymailing_translation_sprintf('COM_COMMUNITY_PHOTOS_UPLOADED_BY', ''),
|
||||
'uploadedon' => trim(acymailing_translation('COM_COMMUNITY_VIDEOS_CREATED'), ': '),
|
||||
'views' => ucfirst(trim(acymailing_translation_sprintf('COM_COMMUNITY_VIDEOS_HITS_COUNT', ''))),
|
||||
'category' => acymailing_translation('COM_COMMUNITY_VIDEOS_CATEGORY'),
|
||||
];
|
||||
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'fields',
|
||||
'options' => $attributes,
|
||||
'default' => 'full',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'v.created' => 'COM_COMMUNITY_VIDEOS_SORT_LATEST',
|
||||
'v.hits' => 'COM_COMMUNITY_VIDEOS_SORT_POPULAR',
|
||||
'rand()' => 'ACYM_RANDOM',
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'Number of characters ("Description" field)',
|
||||
'type' => 'text',
|
||||
'name' => 'chars',
|
||||
'default' => 150,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'text',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'jomsocialusers', 'simple');
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymManagetext extends acymPlugin
|
||||
{
|
||||
var $foundtags = [];
|
||||
|
||||
public function replaceContent(&$email, $send = true)
|
||||
{
|
||||
$this->_replaceConstant($email);
|
||||
$this->_replaceRandom($email);
|
||||
$this->_addAlignmentCss($email);
|
||||
$this->_handleAnchors($email);
|
||||
}
|
||||
|
||||
public function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$this->acympluginHelper->cleanHtml($email->body);
|
||||
$this->acympluginHelper->replaceVideos($email->body);
|
||||
|
||||
$this->_removetext($email);
|
||||
$this->_ifstatement($email, $user);
|
||||
}
|
||||
|
||||
private function _replaceConstant(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, '(?:const|trans|config)');
|
||||
if (empty($tags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $oneTag) {
|
||||
$val = '';
|
||||
$arrayVal = [];
|
||||
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] = acym_getCMSConfig($val);
|
||||
}
|
||||
} else {
|
||||
static $done = false;
|
||||
if (!$done && strpos($val, 'COM_USERS') !== false) {
|
||||
$done = true;
|
||||
|
||||
acym_loadLanguageFile('com_users');
|
||||
}
|
||||
if (!empty($arrayVal)) {
|
||||
$tagsReplaced[$i] = nl2br(vsprintf(acym_translation($val), $arrayVal));
|
||||
} else {
|
||||
$tagsReplaced[$i] = acym_translation($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
private function _replaceRandom(&$email)
|
||||
{
|
||||
$randTag = $this->acympluginHelper->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 = [];
|
||||
foreach (array_keys($results) as $oneResult) {
|
||||
$tags['{rand:'.$oneResult.'}'] = end($results[$oneResult]);
|
||||
}
|
||||
|
||||
if (empty($tags)) {
|
||||
return;
|
||||
}
|
||||
$this->acympluginHelper->replaceTags($email, $tags, true);
|
||||
}
|
||||
|
||||
|
||||
private function _ifstatement(&$email, $user, $loop = 1)
|
||||
{
|
||||
if (isset($this->noIfStatementTags[$email->id])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isAdmin = acym_isAdmin();
|
||||
|
||||
if ($loop > 3) {
|
||||
if ($isAdmin) {
|
||||
acym_display('You cannot have more than 3 nested {if} tags.', 'warning');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$match = '#{if:(((?!{if).)*)}(((?!{if).)*){/if}#Uis';
|
||||
$variables = ['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->id] = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static $a = false;
|
||||
|
||||
$tags = [];
|
||||
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('#^(.+)(!=|<|>|>|<|!~)([^=!<>~]+)$#is', $allresults[1][$i], $operators) && !preg_match('#^(.+)(=|~)([^=!<>~]+)$#is', $allresults[1][$i], $operators)) {
|
||||
if ($isAdmin) {
|
||||
acym_display('Operation not found : '.$allresults[1][$i], 'error');
|
||||
}
|
||||
$tags[$oneTag] = $allresults[3][$i];
|
||||
continue;
|
||||
};
|
||||
$field = trim($operators[1]);
|
||||
$prop = '';
|
||||
|
||||
$operatorsParts = explode('.', $operators[1]);
|
||||
$operatorComp = 'acym';
|
||||
if (count($operatorsParts) > 1 && in_array($operatorsParts[0], ['acym', 'joomla', 'var'])) {
|
||||
$operatorComp = $operatorsParts[0];
|
||||
unset($operatorsParts[0]);
|
||||
$field = implode('.', $operatorsParts);
|
||||
}
|
||||
|
||||
if ($operatorComp == 'joomla') {
|
||||
if (!empty($user->userid)) {
|
||||
if ($field == 'gid') {
|
||||
$prop = implode(';', acym_loadResultArray('SELECT group_id FROM #__user_usergroup_map WHERE user_id = '.intval($user->userid)));
|
||||
} else {
|
||||
$juser = acym_loadObject('SELECT * FROM #__users WHERE id = '.intval($user->userid));
|
||||
if (isset($juser->{$field})) {
|
||||
$prop = strtolower($juser->{$field});
|
||||
} else {
|
||||
if ($isAdmin && !$a) {
|
||||
acym_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) {
|
||||
acym_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] == '>') && $prop > $val) {
|
||||
$tags[$oneTag] = $allresults[3][$i];
|
||||
} elseif (($operators[2] == '<' || $operators[2] == '<') && $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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags, true);
|
||||
|
||||
$this->_ifstatement($email, $user, $loop + 1);
|
||||
}
|
||||
|
||||
private function _removetext(&$email)
|
||||
{
|
||||
$removetext = '{reg},{/reg},{pub},{/pub}';
|
||||
if (!empty($removetext)) {
|
||||
$removeArray = explode(',', trim($removetext, ' ,'));
|
||||
if (!empty($email->body)) {
|
||||
$email->body = str_replace($removeArray, '', $email->body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$removetags = 'youtube';
|
||||
if (!empty($removetags)) {
|
||||
$regex = [];
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _addAlignmentCss(&$email)
|
||||
{
|
||||
$imageAlignment = '<style type="text/css">
|
||||
.alignleft{float:left;margin:0.5em 1em 0.5em 0;}
|
||||
.aligncenter{display: block;margin-left: auto;margin-right: auto;}
|
||||
.alignright{float: right;margin: 0.5em 0 0.5em 1em;}
|
||||
</style>';
|
||||
|
||||
if (strpos($email->body, '</body>')) {
|
||||
$email->body = str_replace('</body>', $imageAlignment.'</body>', $email->body);
|
||||
} else {
|
||||
$email->body .= $imageAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
private function _handleAnchors(&$email)
|
||||
{
|
||||
if (empty($email->body)) return;
|
||||
|
||||
$newBody = preg_replace('/(<a +href="#[^"]*"[^>]*) target="_blank"([^>]*>)/Uis', '$1 $2', $email->body);
|
||||
|
||||
if (!empty($newBody)) $email->body = $newBody;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymOnline extends acymPlugin
|
||||
{
|
||||
function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = acym_translation('ACYM_WEBSITE_LINKS');
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->help = 'plugin-online';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
function textPopup()
|
||||
{
|
||||
$others = [];
|
||||
$others['readonline'] = ['default' => acym_translation('ACYM_VIEW_ONLINE', true), 'desc' => acym_translation('ACYM_VIEW_ONLINE_DESC')];
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
var selectedTag = '';
|
||||
|
||||
function changeOnlineTag(tagName) {
|
||||
selectedTag = tagName;
|
||||
defaultText = [];
|
||||
<?php
|
||||
foreach ($others as $tagname => $tag) {
|
||||
echo 'defaultText["'.$tagname.'"] = "'.$tag['default'].'";';
|
||||
}
|
||||
?>
|
||||
jQuery('#tr_' + tagName).addClass('selected_row');
|
||||
document.getElementById('acym__popup__online__tagtext').value = defaultText[tagName];
|
||||
|
||||
setOnlineTag();
|
||||
}
|
||||
|
||||
function setOnlineTag() {
|
||||
var tag = '{' + selectedTag + '}' + document.getElementById('acym__popup__online__tagtext').value + '{/' + selectedTag + '}';
|
||||
setTag(tag, jQuery('#tr_' + selectedTag));
|
||||
}
|
||||
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<div class="acym__popup__listing text-center grid-x">
|
||||
<div class="grid-x medium-12 cell acym__listing__row text-left">
|
||||
<div class="grid-x cell medium-5 small-12 acym__listing__title acym__listing__title__dynamics">
|
||||
<label class="small-3" style="line-height: 40px;" for="acym__popup__online__tagtext"><?php echo acym_translation('ACYM_TEXT'); ?>: </label>
|
||||
<input class="small-9" type="text" name="tagtext" id="acym__popup__online__tagtext" onchange="setOnlineTag();">
|
||||
</div>
|
||||
<div class="medium-auto"></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
foreach ($others as $tagname => $tag) {
|
||||
$onclick = 'changeOnlineTag(\''.$tagname.'\');';
|
||||
echo '<div class="grid-x small-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="'.$onclick.'" id="tr_'.$tagname.'" ><div class="cell small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['desc'].'</div></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
function replaceContent(&$email, $send = true)
|
||||
{
|
||||
$match = '#(?:{|%7B)(readonline)([^}]*)(?:}|%7D)(.*)(?:{|%7B)/(readonline)(?:}|%7D)#Uis';
|
||||
$variables = ['body'];
|
||||
$found = false;
|
||||
$results = [];
|
||||
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 = [];
|
||||
|
||||
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];
|
||||
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) ? '' : '&key='.$email->key;
|
||||
$lang = empty($email->lang) ? '' : '&lang='.$email->lang;
|
||||
|
||||
$link = '';
|
||||
if ($tag->type == 'readonline') {
|
||||
$link = acym_frontendLink('archive&task=view&id='.$email->id.'&userid={subtag:id}-{subtag:key}'.$addkey.$lang.'&'.acym_noTemplate());
|
||||
}
|
||||
|
||||
if (empty($allresults[3][$i])) {
|
||||
$tags[$oneTag] = $link;
|
||||
} else {
|
||||
$tags[$oneTag] = '<a style="text-decoration:none;" href="'.$link.'" target="_blank"><span class="acym_online">'.$allresults[3][$i].'</span></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymPage extends acymPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'WordPress';
|
||||
$this->name = 'page';
|
||||
}
|
||||
|
||||
function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = acym_translation('ACYM_PAGE');
|
||||
$plugin->icon = '<div class="wp-menu-image dashicons-before dashicons-admin-page"></div>';
|
||||
$plugin->icontype = 'raw';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
function contentPopup()
|
||||
{
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display',
|
||||
'options' => [
|
||||
'title' => ['ACYM_TITLE', true],
|
||||
'image' => ['ACYM_FEATURED_IMAGE', true],
|
||||
'content' => ['ACYM_CONTENT', true],
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TRUNCATE',
|
||||
'type' => 'intextfield',
|
||||
'name' => 'wrap',
|
||||
'text' => 'ACYM_TRUNCATE_AFTER',
|
||||
'default' => 0,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone(false);
|
||||
|
||||
$this->displayListing();
|
||||
}
|
||||
|
||||
function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT page.ID, page.post_title, page.post_date, page.post_content ';
|
||||
$query = 'FROM #__posts AS page ';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'page.ID';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['page.ID', 'page.post_title'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(" LIKE ".acym_escapeDB($searchVal)." OR ", $searchFields)." LIKE ".acym_escapeDB($searchVal);
|
||||
}
|
||||
|
||||
$filters[] = 'page.post_type = "page"';
|
||||
$filters[] = 'page.post_status = "publish"';
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
if (!empty($this->pageInfo->order)) $query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
foreach ($rows as $i => $row) {
|
||||
if (str_replace(['wp:core-embed', 'wp:shortcode'], '', $row->post_content) !== $row->post_content) {
|
||||
$rows[$i]->post_title = acym_tooltip('<i class="fa fa-warning"></i>', acym_translation('ACYM_SPECIAL_CONTENT_WARNING')).$rows[$i]->post_title;
|
||||
}
|
||||
}
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'post_title' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '7',
|
||||
],
|
||||
'post_date' => [
|
||||
'label' => 'ACYM_DATE_CREATED',
|
||||
'size' => '4',
|
||||
'type' => 'date',
|
||||
],
|
||||
'ID' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'ID',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
function replaceContent(&$email)
|
||||
{
|
||||
$this->_replaceOne($email);
|
||||
}
|
||||
|
||||
private function _replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $oneTag) {
|
||||
if (isset($tagsReplaced[$i])) continue;
|
||||
$tagsReplaced[$i] = $this->_replaceContent($oneTag, $email);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
function _replaceContent($tag, &$email)
|
||||
{
|
||||
$query = 'SELECT page.*
|
||||
FROM #__posts AS page
|
||||
WHERE page.post_type = "page"
|
||||
AND page.post_status = "publish"
|
||||
AND page.ID = '.intval($tag->id);
|
||||
|
||||
$element = acym_loadObject($query);
|
||||
|
||||
if (empty($element)) {
|
||||
if (acym_isAdmin()) {
|
||||
acym_enqueueMessage('The page "'.$tag->id.'" could not be found', 'notice');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($tag->display)) {
|
||||
$tag->display = [];
|
||||
} else {
|
||||
$tag->display = explode(',', $tag->display);
|
||||
}
|
||||
|
||||
$varFields = [];
|
||||
foreach ($element as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$link = $element->guid;
|
||||
$varFields['{link}'] = $link;
|
||||
|
||||
$title = '';
|
||||
if (in_array('title', $tag->display)) $title = $element->post_title;
|
||||
|
||||
$afterTitle = '';
|
||||
|
||||
$imagePath = '';
|
||||
if (in_array('image', $tag->display)) {
|
||||
$imageId = get_post_thumbnail_id($tag->id);
|
||||
if (!empty($imageId)) {
|
||||
$imagePath = get_the_post_thumbnail_url($tag->id);
|
||||
}
|
||||
}
|
||||
|
||||
$contentText = '';
|
||||
if (in_array('content', $tag->display)) $contentText .= $element->post_content;
|
||||
|
||||
$customFields = [];
|
||||
|
||||
$format = new stdClass();
|
||||
$format->tag = $tag;
|
||||
$format->title = $title;
|
||||
$format->afterTitle = $afterTitle;
|
||||
$format->afterArticle = '';
|
||||
$format->imagePath = $imagePath;
|
||||
$format->description = $contentText;
|
||||
$format->link = empty($tag->clickable) ? '' : $link;
|
||||
$format->cols = empty($tag->nbcols) ? 1 : intval($tag->nbcols);
|
||||
$format->customFields = $customFields;
|
||||
$result = '<div class="acymailing_content">'.$this->acympluginHelper->getStandardDisplay($format).'</div>';
|
||||
|
||||
return $this->finalizeElementFormat($this->name, $result, $tag, $varFields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymPayplans extends acymPlugin
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_payplans'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
$this->name = 'jevents';
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
$allPlans = acym_loadObjectList('SELECT `title` AS `text`, `plan_id` AS `value` FROM `#__payplans_plan` ORDER BY `ordering` ASC');
|
||||
if (empty($allPlans)) return;
|
||||
|
||||
acym_loadLanguageFile('com_payplans', JPATH_SITE);
|
||||
|
||||
$conditions['user']['payplans'] = new stdClass();
|
||||
$conditions['user']['payplans']->name = 'Payplans';
|
||||
$conditions['user']['payplans']->option = '<div class="cell grid-x grid-margin-x">';
|
||||
|
||||
$operatorIn = acym_get('type.operatorin');
|
||||
|
||||
$conditions['user']['payplans']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['payplans']->option .= $operatorIn->display('acym_condition[conditions][__numor__][__numand__][payplans][type]');
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
|
||||
$firstGroup = new stdClass();
|
||||
$firstGroup->text = acym_translation('ACYM_ANY_PLAN');
|
||||
$firstGroup->value = 0;
|
||||
array_unshift($allPlans, $firstGroup);
|
||||
|
||||
$conditions['user']['payplans']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['payplans']->option .= acym_select($allPlans, 'acym_condition[conditions][__numor__][__numand__][payplans][plan]', '', 'class="acym__select"');
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
|
||||
$status = [];
|
||||
$status[] = acym_selectOption('', acym_translation('ACYM_ANY_STATUS'));
|
||||
$status[] = acym_selectOption('1601', acym_translation('COM_PAYPLANS_STATUS_SUBSCRIPTION_ACTIVE'));
|
||||
$status[] = acym_selectOption('1602', acym_translation('COM_PAYPLANS_STATUS_SUBSCRIPTION_HOLD'));
|
||||
$status[] = acym_selectOption('1603', acym_translation('COM_PAYPLANS_STATUS_SUBSCRIPTION_EXPIRED'));
|
||||
|
||||
$conditions['user']['payplans']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['payplans']->option .= acym_select($status, 'acym_condition[conditions][__numor__][__numand__][payplans][status]', '', 'class="acym__select"');
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
|
||||
|
||||
$conditions['user']['payplans']->option .= '<div class="cell grid-x margin-top-1 margin-bottom-1">';
|
||||
$conditions['user']['payplans']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][payplans][signup_date_inf]', '', 'cell shrink');
|
||||
$conditions['user']['payplans']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['payplans']->option .= '<span class="acym_vcenter">'.acym_translation('ACYM_SUBSCRIPTION_DATE').'</span>';
|
||||
$conditions['user']['payplans']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['payplans']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][payplans][signup_date_sup]', '', 'cell shrink');
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
|
||||
$conditions['user']['payplans']->option .= '<div class="cell grid-x">';
|
||||
$conditions['user']['payplans']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][payplans][expiration_date_inf]', '', 'cell shrink');
|
||||
$conditions['user']['payplans']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['payplans']->option .= '<span class="acym_vcenter">'.acym_translation('ACYM_END_DATE').'</span>';
|
||||
$conditions['user']['payplans']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['payplans']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][payplans][expiration_date_sup]', '', 'cell shrink');
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
|
||||
$conditions['user']['payplans']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_payplans(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_payplans($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
|
||||
private function processConditionFilter_payplans(&$query, $options, $num)
|
||||
{
|
||||
$lj = '`#__payplans_subscription` AS payplans'.$num.' ON payplans'.$num.'.`user_id` = user.`cms_id`';
|
||||
if (!empty($options['plan'])) $lj .= ' AND payplans'.$num.'.`plan_id` = '.intval($options['plan']);
|
||||
if (!empty($options['status'])) $lj .= ' AND payplans'.$num.'.`status` = '.intval($options['status']);
|
||||
|
||||
if (!empty($options['signup_date_inf'])) {
|
||||
$options['signup_date_inf'] = acym_replaceDate($options['signup_date_inf']);
|
||||
if (!is_numeric($options['signup_date_inf'])) $options['signup_date_inf'] = strtotime($options['signup_date_inf']);
|
||||
$lj .= ' AND payplans'.$num.'.`subscription_date` > '.acym_escapeDB(acym_date($options['signup_date_inf'], 'Y-m-d H:i', false));
|
||||
}
|
||||
if (!empty($options['signup_date_sup'])) {
|
||||
$options['signup_date_sup'] = acym_replaceDate($options['signup_date_sup']);
|
||||
if (!is_numeric($options['signup_date_sup'])) $options['signup_date_sup'] = strtotime($options['signup_date_sup']);
|
||||
$lj .= ' AND payplans'.$num.'.`subscription_date` < '.acym_escapeDB(acym_date($options['signup_date_sup'], 'Y-m-d H:i', false));
|
||||
}
|
||||
|
||||
if (!empty($options['expiration_date_inf'])) {
|
||||
$options['expiration_date_inf'] = acym_replaceDate($options['expiration_date_inf']);
|
||||
if (!is_numeric($options['expiration_date_inf'])) $options['expiration_date_inf'] = strtotime($options['expiration_date_inf']);
|
||||
$lj .= ' AND (payplans'.$num.'.`expiration_date` > '.acym_escapeDB(acym_date($options['expiration_date_inf'], 'Y-m-d H:i', false));
|
||||
$lj .= ' OR payplans'.$num.'.`expiration_date` = "0000-00-00 00:00:00")';
|
||||
}
|
||||
if (!empty($options['expiration_date_sup'])) {
|
||||
$options['expiration_date_sup'] = acym_replaceDate($options['expiration_date_sup']);
|
||||
if (!is_numeric($options['expiration_date_sup'])) $options['expiration_date_sup'] = strtotime($options['expiration_date_sup']);
|
||||
$lj .= ' AND payplans'.$num.'.`expiration_date` < '.acym_escapeDB(acym_date($options['expiration_date_sup'], 'Y-m-d H:i', false));
|
||||
$lj .= ' AND payplans'.$num.'.`expiration_date` > "0000-00-00 00:00:00"';
|
||||
}
|
||||
|
||||
$query->leftjoin['payplans'.$num] = $lj;
|
||||
$query->where['member'] = 'user.cms_id > 0';
|
||||
|
||||
$operator = (empty($options['type']) || $options['type'] == 'in') ? 'IS NOT NULL' : 'IS NULL';
|
||||
$query->where[] = 'payplans'.$num.'.`user_id` '.$operator;
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
$this->summaryConditionFilters($automationCondition);
|
||||
}
|
||||
|
||||
private function summaryConditionFilters(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['payplans'])) {
|
||||
acym_loadLanguageFile('com_payplans', JPATH_SITE);
|
||||
|
||||
if (empty($automationCondition['payplans']['plan'])) {
|
||||
$element = acym_translation('ACYM_ANY_PLAN');
|
||||
} else {
|
||||
$element = acym_loadResult('SELECT `title` FROM #__payplans_plan WHERE `plan_id` = '.intval($automationCondition['payplans']['plan']));
|
||||
}
|
||||
|
||||
$status = [
|
||||
'' => 'ACYM_ANY',
|
||||
'1601' => 'COM_PAYPLANS_STATUS_SUBSCRIPTION_ACTIVE',
|
||||
'1602' => 'COM_PAYPLANS_STATUS_SUBSCRIPTION_HOLD',
|
||||
'1603' => 'COM_PAYPLANS_STATUS_SUBSCRIPTION_EXPIRED',
|
||||
];
|
||||
|
||||
$status = acym_translation($status[$automationCondition['payplans']['status']]);
|
||||
|
||||
$finalText = acym_translation_sprintf('ACYM_REGISTERED', $element, $status);
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['payplans']['signup_date_inf'])) {
|
||||
$dates[] = acym_translation('ACYM_AFTER').' '.acym_replaceDate($automationCondition['payplans']['signup_date_inf'], true);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['payplans']['signup_date_sup'])) {
|
||||
$dates[] = acym_translation('ACYM_BEFORE').' '.acym_replaceDate($automationCondition['payplans']['signup_date_sup'], true);
|
||||
}
|
||||
|
||||
if (!empty($dates)) {
|
||||
$finalText .= '<br />'.acym_translation('ACYM_SUBSCRIPTION_DATE').': '.implode(' '.acym_translation('ACYM_AND').' ', $dates);
|
||||
}
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['payplans']['expiration_date_inf'])) {
|
||||
$dates[] = acym_translation('ACYM_AFTER').' '.acym_replaceDate($automationCondition['payplans']['expiration_date_inf'], true);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['payplans']['expiration_date_sup'])) {
|
||||
$dates[] = acym_translation('ACYM_BEFORE').' '.acym_replaceDate($automationCondition['payplans']['expiration_date_sup'], true);
|
||||
}
|
||||
|
||||
if (!empty($dates)) {
|
||||
$finalText .= '<br />'.acym_translation('ACYM_END_DATE').': '.implode(' '.acym_translation('ACYM_AND').' ', $dates);
|
||||
}
|
||||
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$newFilters = [];
|
||||
|
||||
$this->onAcymDeclareConditions($newFilters);
|
||||
foreach ($newFilters as $oneType) {
|
||||
foreach ($oneType as $oneFilterName => $oneFilter) {
|
||||
if (!empty($oneFilter->option)) $oneFilter->option = str_replace(['acym_condition', '[conditions]'], ['acym_action', '[filters]'], $oneFilter->option);
|
||||
$filters[$oneFilterName] = $oneFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_payplans(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_payplans($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_payplans(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_payplans($query, $options, $num);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
$this->summaryConditionFilters($automationFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,355 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymPost extends acymPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'WordPress';
|
||||
$this->name = 'post';
|
||||
$this->rootCategoryId = 0;
|
||||
}
|
||||
|
||||
function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = acym_translation('ACYM_ARTICLE');
|
||||
$plugin->icon = '<i class="cell fa fa-wordpress"></i>';
|
||||
$plugin->icontype = 'raw';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
function contentPopup()
|
||||
{
|
||||
$this->categories = acym_loadObjectList(
|
||||
"SELECT cat.term_taxonomy_id AS id, cat.parent AS parent_id, catdetails.name AS title
|
||||
FROM `#__term_taxonomy` AS cat
|
||||
JOIN `#__terms` AS catdetails ON cat.term_id = catdetails.term_id
|
||||
WHERE cat.taxonomy = 'category'"
|
||||
);
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
$tabHelper->startTab(acym_translation('ACYM_ONE_BY_ONE'));
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display',
|
||||
'options' => [
|
||||
'title' => ['ACYM_TITLE', true],
|
||||
'image' => ['ACYM_FEATURED_IMAGE', true],
|
||||
'content' => ['ACYM_CONTENT', true],
|
||||
'cats' => ['ACYM_CATEGORIES', false],
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_TRUNCATE',
|
||||
'type' => 'intextfield',
|
||||
'name' => 'wrap',
|
||||
'text' => 'ACYM_TRUNCATE_AFTER',
|
||||
'default' => 0,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone();
|
||||
|
||||
$this->displayListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
$tabHelper->startTab(acym_translation('ACYM_BY_CATEGORY'));
|
||||
|
||||
$catOptions = [
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'ID' => 'ACYM_ID',
|
||||
'post_date' => 'ACYM_PUBLISHING_DATE',
|
||||
'post_modified' => 'ACYM_MODIFICATION_DATE',
|
||||
'post_title' => 'ACYM_TITLE',
|
||||
'rand' => 'ACYM_RANDOM',
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'text',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
];
|
||||
|
||||
$displayOptions = array_merge($displayOptions, $catOptions);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'auto'.$this->name, 'grouped');
|
||||
|
||||
acym_display(acym_translation('ACYM_SPECIAL_CONTENT_WARNING'), 'warning', false);
|
||||
|
||||
echo $this->getCategoryListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
|
||||
function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT post.ID, post.post_title, post.post_date, post.post_content ';
|
||||
$query = 'FROM #__posts AS post ';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'post.ID';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['post.ID', 'post.post_title'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(" LIKE ".acym_escapeDB($searchVal)." OR ", $searchFields)." LIKE ".acym_escapeDB($searchVal);
|
||||
}
|
||||
|
||||
if (!empty($this->pageInfo->filter_cat)) {
|
||||
$query .= 'JOIN #__term_relationships AS cat ON post.ID = cat.object_id';
|
||||
$filters[] = "cat.term_taxonomy_id = ".intval($this->pageInfo->filter_cat);
|
||||
}
|
||||
|
||||
$filters[] = 'post.post_type = "post"';
|
||||
$filters[] = 'post.post_status = "publish"';
|
||||
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
if (!empty($this->pageInfo->order)) $query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
foreach ($rows as $i => $row) {
|
||||
if (str_replace(['wp:core-embed', 'wp:shortcode'], '', $row->post_content) !== $row->post_content) {
|
||||
$rows[$i]->post_title = acym_tooltip('<i class="fa fa-warning"></i>', acym_translation('ACYM_SPECIAL_CONTENT_WARNING')).$rows[$i]->post_title;
|
||||
}
|
||||
}
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'post_title' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '7',
|
||||
],
|
||||
'post_date' => [
|
||||
'label' => 'ACYM_PUBLISHING_DATE',
|
||||
'size' => '4',
|
||||
'type' => 'date',
|
||||
],
|
||||
'ID' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'ID',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
function replaceContent(&$email)
|
||||
{
|
||||
$this->_replaceAuto($email);
|
||||
$this->_replaceOne($email);
|
||||
}
|
||||
|
||||
function _replaceAuto(&$email)
|
||||
{
|
||||
$this->generateByCategory($email);
|
||||
if (empty($this->tags)) {
|
||||
return;
|
||||
}
|
||||
$this->acympluginHelper->replaceTags($email, $this->tags, true);
|
||||
}
|
||||
|
||||
function generateByCategory(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'auto'.$this->name);
|
||||
$return = new stdClass();
|
||||
$return->status = true;
|
||||
$return->message = '';
|
||||
$this->tags = [];
|
||||
|
||||
if (empty($tags)) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
foreach ($tags as $oneTag => $parameter) {
|
||||
if (isset($this->tags[$oneTag])) {
|
||||
continue;
|
||||
}
|
||||
$allcats = explode('-', $parameter->id);
|
||||
$selectedArea = [];
|
||||
foreach ($allcats as $oneCat) {
|
||||
if (empty($oneCat)) {
|
||||
continue;
|
||||
}
|
||||
$selectedArea[] = intval($oneCat);
|
||||
}
|
||||
|
||||
$query = 'SELECT DISTINCT post.`ID`
|
||||
FROM #__posts AS post
|
||||
LEFT JOIN #__term_relationships AS cat ON post.ID = cat.object_id';
|
||||
|
||||
$where = [];
|
||||
|
||||
if (!empty($selectedArea)) {
|
||||
$where[] = 'cat.term_taxonomy_id IN ('.implode(',', $selectedArea).')';
|
||||
}
|
||||
|
||||
$where[] = 'post.post_type = "post"';
|
||||
$where[] = 'post.post_status = "publish"';
|
||||
|
||||
$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 post.`'.acym_secureDBColumn(trim($ordering[0])).'` '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($parameter->max)) $parameter->max = 20;
|
||||
$query .= ' LIMIT '.intval($parameter->max);
|
||||
|
||||
$allArticles = acym_loadResultArray($query);
|
||||
|
||||
$this->tags[$oneTag] = $this->finalizeCategoryFormat($this->name, $allArticles, $parameter);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function _replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $oneTag) {
|
||||
if (isset($tagsReplaced[$i])) {
|
||||
continue;
|
||||
}
|
||||
$tagsReplaced[$i] = $this->_replaceContent($oneTag, $email);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
function _replaceContent($tag, &$email)
|
||||
{
|
||||
$query = 'SELECT post.*
|
||||
FROM #__posts AS post
|
||||
WHERE post.post_type = "post"
|
||||
AND post.post_status = "publish"
|
||||
AND post.ID = '.intval($tag->id);
|
||||
|
||||
$element = acym_loadObject($query);
|
||||
|
||||
if (empty($element)) {
|
||||
if (acym_isAdmin()) {
|
||||
acym_enqueueMessage('The post "'.$tag->id.'" could not be found', 'notice');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($tag->display)) {
|
||||
$tag->display = [];
|
||||
} else {
|
||||
$tag->display = explode(',', $tag->display);
|
||||
}
|
||||
|
||||
$varFields = [];
|
||||
foreach ($element as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$link = $element->guid;
|
||||
$varFields['{link}'] = $link;
|
||||
|
||||
$title = '';
|
||||
if (in_array('title', $tag->display)) $title = $element->post_title;
|
||||
|
||||
$afterTitle = '';
|
||||
|
||||
$imagePath = '';
|
||||
if (in_array('image', $tag->display)) {
|
||||
$imageId = get_post_thumbnail_id($tag->id);
|
||||
if (!empty($imageId)) {
|
||||
$imagePath = get_the_post_thumbnail_url($tag->id);
|
||||
}
|
||||
}
|
||||
|
||||
$contentText = '';
|
||||
if (in_array('content', $tag->display)) $contentText .= $element->post_content;
|
||||
|
||||
$customFields = [];
|
||||
if (in_array('cats', $tag->display)) {
|
||||
$customFields[] = [
|
||||
get_the_term_list($tag->id, 'category', '', ', '),
|
||||
acym_translation('ACYM_CATEGORIES'),
|
||||
];
|
||||
}
|
||||
|
||||
$format = new stdClass();
|
||||
$format->tag = $tag;
|
||||
$format->title = $title;
|
||||
$format->afterTitle = $afterTitle;
|
||||
$format->afterArticle = '';
|
||||
$format->imagePath = $imagePath;
|
||||
$format->description = $contentText;
|
||||
$format->link = empty($tag->clickable) ? '' : $link;
|
||||
$format->cols = empty($tag->nbcols) ? 1 : intval($tag->nbcols);
|
||||
$format->customFields = $customFields;
|
||||
$result = '<div class="acymailing_content">'.$this->acympluginHelper->getStandardDisplay($format).'</div>';
|
||||
|
||||
return $this->finalizeElementFormat($this->name, $result, $tag, $varFields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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') || die('Restricted access');
|
||||
|
||||
class AcyplgContentCCK extends plgContentCCK
|
||||
{
|
||||
|
||||
var $acyDisplays = [];
|
||||
|
||||
public function onContentPrepare($context, &$article, &$params, $limitstart = 0)
|
||||
{
|
||||
if (strpos($article->text, '/cck') === false) {
|
||||
return true;
|
||||
}
|
||||
$this->_prepare($context, $article, $params, $limitstart);
|
||||
}
|
||||
|
||||
public function _prepare($context, &$article, &$params, $page = 0)
|
||||
{
|
||||
$property = 'text';
|
||||
preg_match('#::cck::(.*)::/cck::#U', $article->$property, $matches);
|
||||
if (!@$matches[1]) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = 'SELECT a.id, a.pk, a.pkb, a.cck, a.storage_location, a.store_id, b.id as type_id, b.alias as type_alias, b.indexed,
|
||||
b.options_content, b.options_intro, c.template as content_template, c.params as content_params, d.template as intro_template,
|
||||
d.params as intro_params, f.app as folder_app
|
||||
FROM #__cck_core AS a
|
||||
LEFT JOIN #__cck_core_types AS b ON b.name = a.cck
|
||||
LEFT JOIN #__template_styles AS c ON c.id = b.template_content
|
||||
LEFT JOIN #__template_styles AS d ON d.id = b.template_intro
|
||||
LEFT JOIN #__cck_core_folders AS f ON f.id = b.folder
|
||||
WHERE a.id = '.intval($matches[1]);
|
||||
$cck = JCckDatabase::loadObject($query);
|
||||
$contentType = (string)$cck->cck;
|
||||
$article->id = (int)$cck->pk;
|
||||
if (!$contentType) {
|
||||
return;
|
||||
}
|
||||
|
||||
JPluginHelper::importPlugin('cck_storage_location');
|
||||
if ($context == 'text') {
|
||||
$client = 'intro';
|
||||
} else {
|
||||
if ($cck->storage_location != '') {
|
||||
$properties = ['contexts'];
|
||||
$properties = JCck::callFunc('plgCCK_Storage_Location'.$cck->storage_location, 'getStaticProperties', $properties);
|
||||
$client = (in_array($context, $properties['contexts'])) ? 'content' : 'intro';
|
||||
} else {
|
||||
$client = 'intro';
|
||||
}
|
||||
}
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$user = JFactory::getUser();
|
||||
$authorizedViewLevels = $user->getAuthorisedViewLevels();
|
||||
acym_arrayToInteger($authorizedViewLevels);
|
||||
$access = implode(',', $user->getAuthorisedViewLevels());
|
||||
foreach ($this->acyDisplays as $i => $oneDisplay) {
|
||||
$this->acyDisplays[$i] = acym_escapeDB($this->acyDisplays[$i]);
|
||||
}
|
||||
if ($client == 'intro' && $this->cache) {
|
||||
if (isset($this->loaded[$contentType.'_'.$client.'_fields'])) {
|
||||
$fields = $this->loaded[$contentType.'_'.$client.'_fields'];
|
||||
} else {
|
||||
$query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.position'.' FROM #__cck_core_type_field AS c'.' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid'.' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid'//we modify the code here, adding a condition at the end of the 'WHERE'
|
||||
.' WHERE sc.name = '.acym_escapeDB($contentType).' AND sc.published = 1 AND c.access IN ('.$access.') AND cc.name IN ('.implode(',', $this->acyDisplays).')'.' ORDER BY c.ordering ASC';
|
||||
$fields = JCckDatabase::loadObjectList($query, 'name'); //#
|
||||
if (!count($fields) && $client == 'intro') {
|
||||
$client = 'content';
|
||||
$query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.position'.' FROM #__cck_core_type_field AS c'.' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid'.' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid'.' WHERE sc.name = '.acym_escapeDB($contentType).' AND sc.published = 1 AND c.access IN ('.$access.') AND cc.name IN ('.implode(',', $this->acyDisplays).')'.' ORDER BY c.ordering ASC';
|
||||
$fields = JCckDatabase::loadObjectList($query, 'name'); //#
|
||||
}
|
||||
$this->loaded[$contentType.'_'.$client.'_fields'] = $fields;
|
||||
}
|
||||
} else {
|
||||
$query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.position'.' FROM #__cck_core_type_field AS c'.' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid'.' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid'.' WHERE sc.name = '.acym_escapeDB($contentType).' AND sc.published = 1 AND c.access IN ('.$access.') AND cc.name IN ('.implode(',', $this->acyDisplays).')'.' ORDER BY c.ordering ASC';
|
||||
$fields = JCckDatabase::loadObjectList($query, 'name'); //#
|
||||
if (!count($fields) && $client == 'intro') {
|
||||
$client = 'content';
|
||||
$query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.position'.' FROM #__cck_core_type_field AS c'.' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid'.' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid'.' WHERE sc.name = '.acym_escapeDB($contentType).' AND sc.published = 1 AND c.access IN ('.$access.') AND cc.name IN ('.implode(',', $this->acyDisplays).')'.' ORDER BY c.ordering ASC';
|
||||
$fields = JCckDatabase::loadObjectList($query, 'name'); //#
|
||||
}
|
||||
}
|
||||
foreach ($fields as $oneField) {
|
||||
if ($oneField->display == 1 || $oneField->display < 0) {
|
||||
$oneField->label = '<br />';
|
||||
$oneField->display = 3;
|
||||
}
|
||||
}
|
||||
if (!isset($this->loaded[$contentType.'_'.$client.'_options'])) {
|
||||
acym_loadLanguageFile('pkg_app_cck_'.$cck->folder_app, JPATH_SITE, null, false, false);
|
||||
$registry = new JRegistry;
|
||||
$registry->loadString($cck->{'options_'.$client});
|
||||
$this->loaded[$contentType.'_'.$client.'_options'] = $registry->toArray();
|
||||
if (isset($this->loaded[$contentType.'_'.$client.'_options']['sef'])) {
|
||||
if ($this->loaded[$contentType.'_'.$client.'_options']['sef'] == '') {
|
||||
$this->loaded[$contentType.'_'.$client.'_options']['sef'] = JCck::getConfig_Param('sef', '2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl['home'] = $app->getTemplate();
|
||||
$tpl['folder'] = $cck->{$client.'_template'};
|
||||
$tpl['params'] = $cck->{$client.'_params'};
|
||||
if (file_exists(JPATH_SITE.'/templates/'.$tpl['home'].'/html/tpl_'.$tpl['folder'])) {
|
||||
$tpl['folder'] = 'tpl_'.$tpl['folder'];
|
||||
$tpl['root'] = JPATH_SITE.'/templates/'.$tpl['home'].'/html';
|
||||
} else {
|
||||
$tpl['root'] = JPATH_SITE.'/templates';
|
||||
}
|
||||
$tpl['path'] = $tpl['root'].'/'.$tpl['folder'];
|
||||
if (!$tpl['folder'] || !file_exists($tpl['path'].'/index.php')) {
|
||||
$article->$property = str_replace($article->$property, 'Template Style does not exist. Open the Content Type & save it again. (Intro + Content views)', $article->$property);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$article_params = null;
|
||||
@parent::_render($context, $article, $article_params, $tpl, $contentType, $fields, $property, $client, $cck, '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
<svg width="28" height="28" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ -->
|
||||
|
||||
<g>
|
||||
<title>background</title>
|
||||
<rect fill="none" id="canvas_background" height="30" width="30" y="-1" x="-1"/>
|
||||
<g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasGrid">
|
||||
<rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<title>Layer 1</title>
|
||||
<g stroke="null" id="svg_9">
|
||||
<path stroke="null" id="svg_5" fill="#a1a1a1" d="m26.512386,13.771522c-0.170892,-6.442804 -5.489929,-11.631372 -12.092599,-11.799055c0.121814,0.380771 0.533384,1.784255 0.71841,3.92317c0.19512,-0.053285 0.399404,-0.083841 0.611712,-0.083841c1.255314,0 2.276577,0.997056 2.276577,2.221998c0,1.22469 -1.021263,2.221746 -2.276577,2.221746c-0.231515,0 -0.453969,-0.034294 -0.66431,-0.09667c-0.147596,1.202265 -0.38672,2.456552 -0.629417,3.692555c1.59099,0.29693 3.209314,0.587445 4.697178,0.695984c-0.312431,0.29395 -0.507551,0.706288 -0.507551,1.163021c0,0.892254 0.741137,1.61632 1.65622,1.61632c0.914565,0 1.65622,-0.724066 1.65622,-1.61632c0,-0.444915 -0.184508,-0.849323 -0.483841,-1.141354c3.032416,-0.136116 4.920668,-0.758108 4.94091,-0.764977l0.097068,-0.032577z"/>
|
||||
<path stroke="null" id="svg_6" fill="#a1a1a1" d="m13.048198,22.289148c-0.196156,0.053285 -0.401423,0.084851 -0.614766,0.084851c-1.256867,0 -2.277561,-0.996854 -2.277561,-2.222049c0,-1.22469 1.020694,-2.221493 2.277561,-2.221493c0.231049,0 0.453969,0.034042 0.664828,0.097175c0.147596,-1.203022 0.387238,-2.458269 0.629935,-3.695283c-1.590006,-0.296425 -3.208848,-0.587445 -4.695211,-0.697954c0.309946,-0.29395 0.504083,-0.704318 0.504083,-1.158576c0,-0.892759 -0.741706,-1.616573 -1.656737,-1.616573c-0.915083,0 -1.655754,0.723814 -1.655754,1.616573c0,0.4434 0.184042,0.845889 0.481304,1.137869c-2.947928,0.139096 -4.92217,0.758108 -4.943395,0.765027l-0.09303,0.029597c0.170892,6.444067 5.489929,11.634302 12.095135,11.801025c-0.118294,-0.381781 -0.528829,-1.819509 -0.716391,-3.92019z"/>
|
||||
<path stroke="null" id="svg_7" fill="#184d9d" d="m22.493133,15.11263c0.054617,0.190411 0.085938,0.39062 0.085938,0.597799c0,1.22565 -1.021729,2.221998 -2.277043,2.221998c-1.255832,0 -2.277561,-0.996348 -2.277561,-2.221998c0,-0.225917 0.035359,-0.443905 0.100071,-0.649114c-1.232536,-0.143995 -2.518187,-0.377791 -3.786133,-0.614567c-0.303837,1.552732 -0.602135,3.131525 -0.715407,4.583142c-0.3013,-0.303849 -0.722965,-0.49426 -1.189567,-0.49426c-0.915083,0 -1.656737,0.724066 -1.656737,1.61632c0,0.892759 0.741654,1.61536 1.656737,1.61536c0.455988,0 0.86906,-0.179047 1.168341,-0.471027c0.143609,2.875506 0.777583,4.800574 0.784623,4.822292l0.030337,0.090761c6.604688,-0.166723 11.923777,-5.355998 12.095653,-11.799055c-0.389775,0.120358 -1.827629,0.521837 -4.019253,0.702348z"/>
|
||||
<path stroke="null" id="svg_8" fill="#184d9d" d="m15.749909,6.418433c-0.455988,0 -0.868542,0.179299 -1.168859,0.46931c-0.13952,-2.95763 -0.776029,-4.799867 -0.784105,-4.820575l-0.032356,-0.0947c-6.605206,0.166723 -11.924243,5.356251 -12.095135,11.800065c0.391276,-0.116418 1.865007,-0.516938 4.020236,-0.699419c-0.054617,-0.19137 -0.086973,-0.39062 -0.086973,-0.597294c0,-1.226155 1.022298,-2.222251 2.277613,-2.222251c1.255314,0 2.277561,0.996096 2.277561,2.222251c0,0.224402 -0.035411,0.44143 -0.099087,0.646639c1.233053,0.143995 2.519222,0.377791 3.786651,0.614567c0.304355,-1.551217 0.601617,-3.129303 0.714372,-4.58092c0.300317,0.303597 0.72193,0.492997 1.190084,0.492997c0.914565,0 1.655754,-0.722803 1.655754,-1.61531c0,-0.892506 -0.741188,-1.61536 -1.655754,-1.61536z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,444 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymSeblod extends acymPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_cck'.DS)) {
|
||||
$this->installed = false;
|
||||
}
|
||||
$this->name = 'seblod';
|
||||
}
|
||||
|
||||
function insertOptions()
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->name = 'Seblod';
|
||||
$plugin->icon = ACYM_DYNAMICS_URL.basename(__DIR__).'/icon.svg';
|
||||
$plugin->plugin = __CLASS__;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
function contentPopup()
|
||||
{
|
||||
$this->categories = acym_loadObjectList('SELECT id, parent_id, title FROM #__categories WHERE extension = "com_content" ORDER BY `id` DESC');
|
||||
|
||||
$tabHelper = acym_get('helper.tab');
|
||||
$tabHelper->startTab(acym_translation('ACYM_ONE_BY_ONE'));
|
||||
|
||||
$fields = [
|
||||
'title' => ['ACYM_TITLE', true],
|
||||
'introtext' => ['ACYM_INTRO_TEXT', true],
|
||||
'fulltext' => ['ACYM_FULL_TEXT', false],
|
||||
'created' => ['ACYM_DATE_CREATED', false],
|
||||
'pubdate' => ['ACYM_PUBLISHING_DATE', false],
|
||||
'image' => ['ACYM_IMAGE', true],
|
||||
];
|
||||
|
||||
$query = 'SELECT a.name, a.title
|
||||
FROM `#__cck_core_fields` AS a
|
||||
WHERE a.published = 1
|
||||
AND (a.storage LIKE "custom"
|
||||
OR a.storage_table LIKE "#__cck_store_item_content"
|
||||
OR a.storage_field LIKE "introtext"
|
||||
OR a.folder = 1)
|
||||
ORDER BY a.title';
|
||||
$customFields = acym_loadObjectList($query);
|
||||
|
||||
if (!empty($customFields)) {
|
||||
foreach ($customFields as $onefield) {
|
||||
if (in_array($onefield->name, ['art_introtext', 'art_fulltext', 'cat_description'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields[$onefield->name] = [$onefield->title, false];
|
||||
}
|
||||
}
|
||||
|
||||
$displayOptions = [
|
||||
[
|
||||
'title' => 'ACYM_FIELDS_TO_DISPLAY',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'displays',
|
||||
'options' => $fields,
|
||||
'separator' => '; ',
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_CLICKABLE_TITLE',
|
||||
'type' => 'boolean',
|
||||
'name' => 'clickable',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_DISPLAY_PICTURES',
|
||||
'type' => 'pictures',
|
||||
'name' => 'pictures',
|
||||
],
|
||||
];
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, $this->name);
|
||||
|
||||
echo $this->getFilteringZone();
|
||||
|
||||
$this->displayListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->startTab(acym_translation('ACYM_BY_CATEGORY'));
|
||||
|
||||
$catOptions = [
|
||||
[
|
||||
'title' => 'ACYM_ORDER_BY',
|
||||
'type' => 'select',
|
||||
'name' => 'order',
|
||||
'options' => [
|
||||
'id' => 'ACYM_ID',
|
||||
'created' => 'ACYM_DATE_CREATED',
|
||||
'modified' => 'ACYM_MODIFICATION_DATE',
|
||||
'title' => 'ACYM_TITLE',
|
||||
'rand' => 'ACYM_RANDOM',
|
||||
],
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_MAX_NB_ELEMENTS',
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'default' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'ACYM_COLUMNS',
|
||||
'type' => 'text',
|
||||
'name' => 'cols',
|
||||
'default' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
$displayOptions = array_merge($displayOptions, $catOptions);
|
||||
|
||||
echo $this->acympluginHelper->displayOptions($displayOptions, 'auto'.$this->name, 'grouped');
|
||||
|
||||
echo $this->getCategoryListing();
|
||||
|
||||
$tabHelper->endTab();
|
||||
|
||||
$tabHelper->display('plugin');
|
||||
}
|
||||
|
||||
function displayListing()
|
||||
{
|
||||
$querySelect = 'SELECT a.*,b.*,c.*,a.id AS gID, a.title AS gtitle ';
|
||||
$query = 'FROM `#__content` AS a
|
||||
JOIN #__categories AS b ON a.catid = b.id
|
||||
LEFT JOIN `#__users` AS c ON a.created_by = c.id';
|
||||
$filters = [];
|
||||
|
||||
$this->pageInfo = new stdClass();
|
||||
$this->pageInfo->limit = acym_getCMSConfig('list_limit');
|
||||
$this->pageInfo->page = acym_getVar('int', 'pagination_page_ajax', 1);
|
||||
$this->pageInfo->start = ($this->pageInfo->page - 1) * $this->pageInfo->limit;
|
||||
$this->pageInfo->search = acym_getVar('string', 'plugin_search', '');
|
||||
$this->pageInfo->filter_cat = acym_getVar('int', 'plugin_category', 0);
|
||||
$this->pageInfo->order = 'a.id';
|
||||
$this->pageInfo->orderdir = 'DESC';
|
||||
|
||||
$searchFields = ['a.id', 'a.title', 'b.title', 'c.username'];
|
||||
if (!empty($this->pageInfo->search)) {
|
||||
$searchVal = '%'.acym_getEscaped($this->pageInfo->search, true).'%';
|
||||
$filters[] = implode(" LIKE ".acym_escapeDB($searchVal)." OR ", $searchFields)." LIKE ".acym_escapeDB($searchVal);
|
||||
}
|
||||
$filters[] = "a.state != -2";
|
||||
if (!empty($this->pageInfo->filter_cat)) {
|
||||
$filters[] = "a.catid = ".intval($this->pageInfo->filter_cat);
|
||||
}
|
||||
if (!empty($filters)) {
|
||||
$query .= ' WHERE ('.implode(') AND (', $filters).')';
|
||||
}
|
||||
if (!empty($this->pageInfo->order)) {
|
||||
$query .= ' ORDER BY '.acym_secureDBColumn($this->pageInfo->order).' '.acym_secureDBColumn($this->pageInfo->orderdir);
|
||||
}
|
||||
|
||||
$rows = acym_loadObjectList($querySelect.$query, '', $this->pageInfo->start, $this->pageInfo->limit);
|
||||
$this->pageInfo->total = acym_loadResult('SELECT COUNT(*) '.$query);
|
||||
|
||||
|
||||
foreach ($rows as $i => $row) {
|
||||
if (strpos($row->created, ': ') != false) {
|
||||
$rows[$i]->created = str_replace('/', '', strrchr(strip_tags($row->created), '/'));
|
||||
}
|
||||
}
|
||||
|
||||
$listingOptions = [
|
||||
'header' => [
|
||||
'gtitle' => [
|
||||
'label' => 'ACYM_TITLE',
|
||||
'size' => '5',
|
||||
],
|
||||
'created' => [
|
||||
'label' => 'ACYM_DATE_CREATED',
|
||||
'size' => '3',
|
||||
'type' => 'date',
|
||||
],
|
||||
'title' => [
|
||||
'label' => 'ACYM_CATEGORY',
|
||||
'size' => '3',
|
||||
],
|
||||
'gID' => [
|
||||
'label' => 'ACYM_ID',
|
||||
'size' => '1',
|
||||
'class' => 'text-center',
|
||||
],
|
||||
],
|
||||
'id' => 'gID',
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
echo $this->getElementsListing($listingOptions);
|
||||
}
|
||||
|
||||
function replaceContent(&$email)
|
||||
{
|
||||
$this->_replaceAuto($email);
|
||||
$this->_replaceOne($email);
|
||||
}
|
||||
|
||||
private function _replaceOne(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, $this->name);
|
||||
if (empty($tags)) return;
|
||||
|
||||
require_once(JPATH_SITE.DS.'plugins'.DS.'content'.DS.'cck'.DS.'cck.php');
|
||||
require_once(__DIR__.DS.'acyseblodfield.php');
|
||||
|
||||
$menuid = acym_loadResult('SELECT id FROM #__menu WHERE link LIKE "%index.php?option=com_content&view=article%" LIMIT 1');
|
||||
$this->itemId = empty($menuid) ? '' : '&Itemid='.$menuid;
|
||||
|
||||
|
||||
acym_loadLanguageFile('com_cck_default', JPATH_SITE);
|
||||
|
||||
$this->addedcss = false;
|
||||
|
||||
$tagsReplaced = [];
|
||||
foreach ($tags as $i => $oneTag) {
|
||||
if (isset($tagsReplaced[$i])) {
|
||||
continue;
|
||||
}
|
||||
$tagsReplaced[$i] = $this->_replaceContent($oneTag);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tagsReplaced, true);
|
||||
}
|
||||
|
||||
function _replaceContent(&$tag)
|
||||
{
|
||||
if (!empty($tag->displays)) {
|
||||
$tag->displays = explode(';', $tag->displays);
|
||||
} else {
|
||||
$tag->displays = ['title'];
|
||||
}
|
||||
|
||||
foreach ($tag->displays as $i => $oneField) {
|
||||
$tag->displays[$i] = trim($oneField);
|
||||
}
|
||||
$query = 'SELECT a.*,b.alias AS catalias,c.name AS username FROM #__content AS a ';
|
||||
$query .= 'JOIN #__categories AS b ON a.catid = b.id ';
|
||||
$query .= 'LEFT JOIN #__users AS c ON a.created_by = c.id ';
|
||||
$query .= 'WHERE a.id = '.intval($tag->id).' LIMIT 1';
|
||||
$article = acym_loadObject($query);
|
||||
$result = '';
|
||||
$varFields = [];
|
||||
|
||||
if (empty($article)) {
|
||||
if (acym_isAdmin()) {
|
||||
acym_enqueueMessage('The article "'.$tag->id.'" could not be loaded', 'notice');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$link = 'index.php?option=com_content&view=article&id='.$article->id.'&catid='.$article->catid.''.$this->itemId;
|
||||
$varFields['{link}'] = $link;
|
||||
$resultTitle = $article->title;
|
||||
$created = '';
|
||||
if (in_array('title', $tag->displays)) {
|
||||
if (!empty($tag->clickable)) {
|
||||
$resultTitle = '<a href="'.$link.'" target="_blank" >'.$resultTitle.'</a>';
|
||||
}
|
||||
$resultTitle = '<tr><td colspan="2"><h2 class="acym_title">'.$resultTitle.'</h2></td></tr>';
|
||||
}
|
||||
$varFields['{created}'] = acym_getDate(acym_getTime($article->created), acym_translation('ACYM_DATE_FORMAT_LC1'));
|
||||
if (in_array('created', $tag->displays)) {
|
||||
$created = '<tr><td>'.acym_translation('ACYM_DATE_CREATED').' : </td><td>'.$varFields['{created}'].'</td></tr>';
|
||||
}
|
||||
|
||||
$pubdate = '';
|
||||
$varFields['{pubdate}'] = acym_getDate(acym_getTime($article->publish_up), acym_translation('ACYM_DATE_FORMAT_LC1'));
|
||||
if (in_array('pubdate', $tag->displays)) {
|
||||
$pubdate = '<tr><td>'.acym_translation('ACYM_PUBLISHING_DATE').' : </td><td>'.$varFields['{pubdate}'].'</td></tr>';
|
||||
}
|
||||
|
||||
$answer = [];
|
||||
preg_match_all('#::([^/:]+)::(.*)::/#Uis', $article->introtext, $fields);
|
||||
|
||||
if (!empty($fields)) {
|
||||
foreach ($fields[1] as $i => $property) {
|
||||
$answer[$property] = $fields[2][$i];
|
||||
}
|
||||
}
|
||||
|
||||
$description = '';
|
||||
|
||||
if (in_array('image', $tag->displays) && !empty($article->images) && !empty($tag->pict)) {
|
||||
$images = json_decode($article->images);
|
||||
$pictVar = 'image_intro';
|
||||
if (empty($images->$pictVar)) {
|
||||
$pictVar = 'image_fulltext';
|
||||
}
|
||||
if (!empty($images->$pictVar)) {
|
||||
$varFields['{picthtml}'] = '<img style="float:left;padding-right:10px;padding-bottom:10px;" alt="" border="0" src="'.acym_rootURI().$images->$pictVar.'" />';
|
||||
$result .= $varFields['{picthtml}'];
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('introtext', $tag->displays) && !empty($answer['introtext'])) {
|
||||
$varFields['{introtext}'] = $answer['introtext'];
|
||||
$description .= '<tr><td colspan="2">'.$answer['introtext'].'</td></tr>';
|
||||
}
|
||||
if (in_array('fulltext', $tag->displays) && !empty($answer['fulltext'])) {
|
||||
$varFields['{fulltext}'] = $answer['fulltext'];
|
||||
$description .= '<tr><td colspan="2">'.$answer['fulltext'].'</td></tr>';
|
||||
}
|
||||
$article->text = $article->introtext.$article->fulltext;
|
||||
|
||||
$params = [];
|
||||
$acyCCK = new AcyplgContentCCK();
|
||||
$acyCCK->acyDisplays = $tag->displays;
|
||||
$acyCCK->onContentPrepare('com_content.article', $article, $params, 0);
|
||||
|
||||
foreach ($article as $fieldName => $oneField) {
|
||||
$varFields['{'.$fieldName.'}'] = $oneField;
|
||||
}
|
||||
|
||||
$result .= $article->text;
|
||||
|
||||
if (strlen(strip_tags($description)) < 3) {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$result = '<div class="acym_content" style="clear:both"><table cellspacing="0" cellpadding="5" border="0" style="width:100%;">'.$resultTitle.$description.$created.$pubdate.'<tr><td colspan="2">'.$result.'</td></tr></table></div>';
|
||||
$result = preg_replace('#administrator/#', '', $result);
|
||||
|
||||
$result = str_replace(' ', ' ', $result);
|
||||
$result = preg_replace('#<iframe[^>]*(http[^"]*embed/)([^"]*)[^<]*</iframe>#', '<a href="$1$2" target="_blank"><img src="http://img.youtube.com/vi/$2/1.jpg"/></a>', $result);
|
||||
$result = str_replace('/embed/', '/watch?v=', $result);
|
||||
|
||||
if (!empty($tag->tmpl) && file_exists(ACYM_MEDIA.'plugins'.DS.'seblod_'.$tag->tmpl.'.php')) {
|
||||
ob_start();
|
||||
require(ACYM_MEDIA.'plugins'.DS.'seblod_'.$tag->tmpl.'.php');
|
||||
$result = ob_get_clean();
|
||||
$result = str_replace(array_keys($varFields), $varFields, $result);
|
||||
} elseif (file_exists(ACYM_MEDIA.'plugins'.DS.'seblod.php')) {
|
||||
ob_start();
|
||||
require(ACYM_MEDIA.'plugins'.DS.'seblod.php');
|
||||
$result = ob_get_clean();
|
||||
$result = str_replace(array_keys($varFields), $varFields, $result);
|
||||
}
|
||||
|
||||
|
||||
if (!$this->addedcss) {
|
||||
$result .= '<style type="text/css">
|
||||
div.cck_value, div.cck_label {
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
div.cck_label {
|
||||
min-width: 50px;
|
||||
}
|
||||
</style>';
|
||||
$this->addedcss = true;
|
||||
}
|
||||
|
||||
$result = $this->acympluginHelper->managePicts($tag, $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function _replaceAuto(&$email)
|
||||
{
|
||||
$this->generateByCategory($email);
|
||||
if (empty($this->tags)) {
|
||||
return;
|
||||
}
|
||||
$this->acympluginHelper->replaceTags($email, $this->tags, true);
|
||||
}
|
||||
|
||||
function generateByCategory(&$email)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'auto'.$this->name);
|
||||
$return = new stdClass();
|
||||
$return->status = true;
|
||||
$return->message = '';
|
||||
$this->tags = [];
|
||||
|
||||
if (empty($tags)) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
foreach ($tags as $oneTag => $parameter) {
|
||||
if (isset($this->tags[$oneTag])) {
|
||||
continue;
|
||||
}
|
||||
$allcats = explode('-', $parameter->id);
|
||||
$selectedArea = [];
|
||||
foreach ($allcats as $oneCat) {
|
||||
if (empty($oneCat)) {
|
||||
continue;
|
||||
}
|
||||
$selectedArea[] = intval($oneCat);
|
||||
}
|
||||
$query = 'SELECT id FROM #__content';
|
||||
$where = [];
|
||||
|
||||
if (!empty($selectedArea)) {
|
||||
$where[] = 'catid IN ('.implode(',', $selectedArea).')';
|
||||
}
|
||||
|
||||
$where[] = "state = 1";
|
||||
$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 `'.acym_secureDBColumn(trim($ordering[0])).'` '.acym_secureDBColumn(trim($ordering[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($parameter->max)) {
|
||||
$query .= ' LIMIT '.intval($parameter->max);
|
||||
} else {
|
||||
$query .= ' LIMIT 20';
|
||||
}
|
||||
|
||||
$allArticles = acym_loadResultArray($query);
|
||||
|
||||
$this->tags[$oneTag] = $this->finalizeCategoryFormat($this->name, $allArticles, $parameter);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymStatistics extends acymPlugin
|
||||
{
|
||||
public function searchMail()
|
||||
{
|
||||
$id = acym_getVar('int', 'id');
|
||||
if (!empty($id)) {
|
||||
$subject = acym_loadResult('SELECT `subject` FROM #__acym_mail WHERE `id` = '.intval($id));
|
||||
if (empty($subject)) $subject = '';
|
||||
echo json_encode(['value' => $subject.' ['.acym_translation('ACYM_ID').' '.$id.']']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$search = acym_getVar('cmd', 'search', '');
|
||||
|
||||
$mails = acym_loadObjectList(
|
||||
'SELECT `id`, `subject`
|
||||
FROM #__acym_mail
|
||||
WHERE `subject` LIKE '.acym_escapeDB('%'.$search.'%').'
|
||||
ORDER BY `subject` ASC'
|
||||
);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mails = $mailClass->decode($mails);
|
||||
|
||||
foreach ($mails as $oneMail) {
|
||||
$return[] = [$oneMail->id, $oneMail->subject.' ['.acym_translation('ACYM_ID').' '.$oneMail->id.']'];
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$status = [
|
||||
acym_selectOption('opened', 'ACYM_OPENED'),
|
||||
acym_selectOption('notopen', 'ACYM_NOTOPEN'),
|
||||
acym_selectOption('failed', 'ACYM_FAILED'),
|
||||
acym_selectOption('notsent', 'ACYM_NOTSENT'),
|
||||
acym_selectOption('bounced', 'ACYM_BOUNCED'),
|
||||
];
|
||||
|
||||
$filters['statistics'] = new stdClass();
|
||||
$filters['statistics']->name = acym_translation('ACYM_STATISTICS');
|
||||
$filters['statistics']->option = '<div class="intext_select_automation cell">';
|
||||
$filters['statistics']->option .= acym_select($status, 'acym_action[filters][__numor__][__numand__][statistics][status]', 'open', 'class="intext_select_automation acym__select"');
|
||||
$filters['statistics']->option .= '</div>';
|
||||
$filters['statistics']->option .= '<div class="intext_select_automation cell">';
|
||||
$ajaxParams = json_encode(['plugin' => __CLASS__, 'trigger' => 'searchMail',]);
|
||||
$filters['statistics']->option .= acym_select(
|
||||
[],
|
||||
'acym_action[filters][__numor__][__numand__][statistics][mail]',
|
||||
null,
|
||||
'class="acym__select acym_select2_ajax" data-placeholder="'.acym_translation('ACYM_SELECT_A_MAIL', true).'" data-params="'.acym_escape($ajaxParams).'"'
|
||||
);
|
||||
$filters['statistics']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_statistics(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_statistics($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_statistics(&$query, $options, $num)
|
||||
{
|
||||
if (empty($options['mail'])) {
|
||||
acym_enqueueMessage(acym_translation('ACYM_EMAIL_NOT_FOUND'), 'warning');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($options['status']) || !in_array($options['status'], ['opened', 'notopen', 'failed', 'bounced', 'notsent'])) {
|
||||
acym_enqueueMessage(acym_translation_sprintf('ACYM_UNKNOWN_OPERATOR', $options['status']), 'warning');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = '`stats'.$num.'`';
|
||||
$join = '#__acym_user_stat AS '.$alias.' ON '.$alias.'.`user_id` = `user`.`id` AND '.$alias.'.`mail_id` = '.intval($options['mail']);
|
||||
|
||||
$query->leftjoin[$alias] = $join;
|
||||
|
||||
if ($options['status'] == 'opened') {
|
||||
$where = $alias.'.`open` > 0';
|
||||
} elseif ($options['status'] == 'notopen') {
|
||||
$where = $alias.'.`open` = 0 OR '.$alias.'.`user_id` IS NULL';
|
||||
} elseif ($options['status'] == 'failed') {
|
||||
$where = $alias.'.`fail` > 0';
|
||||
} elseif ($options['status'] == 'bounced') {
|
||||
$where = $alias.'.`bounce` > 0';
|
||||
} elseif ($options['status'] == 'notsent') {
|
||||
$where = $alias.'.`user_id` IS NULL';
|
||||
}
|
||||
|
||||
$query->where[] = $where;
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
if (!empty($automationFilter['statistics'])) {
|
||||
$status = acym_translation('ACYM_'.strtoupper($automationFilter['statistics']['status']));
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = $mailClass->getOneById($automationFilter['statistics']['mail']);
|
||||
|
||||
if (empty($mail)) {
|
||||
$automationFilter = acym_translation_sprintf('ACYM_NOT_FOUND', acym_translation('ACYM_MAIL'));
|
||||
} else {
|
||||
$automationFilter = acym_translation_sprintf('ACYM_FILTER_STATISTICS_SUMMARY', $status, $mail->subject, $mail->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,642 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymSubscriber extends acymPlugin
|
||||
{
|
||||
var $fields = [];
|
||||
const TRIGGERS = [
|
||||
'user_creation' => 'ACYM_ON_USER_CREATION',
|
||||
'user_modification' => 'ACYM_ON_USER_MODIFICATION',
|
||||
'user_click' => 'ACYM_WHEN_USER_CLICKS_MAIL',
|
||||
'user_open' => 'ACYM_WHEN_USER_OPEN_MAIL',
|
||||
'user_subscribe' => 'ACYM_WHEN_USER_SUBSCRIBES',
|
||||
];
|
||||
|
||||
public function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = acym_translation('ACYM_SUBSCRIBER');
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->help = 'plugin-subscriber';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
public function textPopup()
|
||||
{
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
var selectedTag;
|
||||
|
||||
function changeUserTag(tagname, element) {
|
||||
if (!tagname) return;
|
||||
|
||||
var finalTag = '{subtag:' + tagname;
|
||||
|
||||
if (jQuery('input[name="typeinfo"]:checked').length > 0) {
|
||||
finalTag += '|info:' + jQuery('input[name="typeinfo"]:checked').val() + '';
|
||||
}
|
||||
finalTag += '}';
|
||||
|
||||
|
||||
setTag(finalTag, element);
|
||||
}
|
||||
|
||||
-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$fieldClass = acym_get('class.field');
|
||||
$fieldsUser = acym_getColumns('user');
|
||||
$fieldsStats = acym_getColumns('user_stat');
|
||||
$fields = array_merge($fieldsUser, $fieldsStats);
|
||||
$customFields = $fieldClass->getAllFieldsForUser();
|
||||
$descriptions = [];
|
||||
$isAutomationAdmin = acym_getVar('string', 'automation');
|
||||
|
||||
foreach ($customFields as $one) {
|
||||
$descriptions[$one->namekey] = acym_translation('ACYM_CUSTOM_FIELD');
|
||||
$fields[] = $one->namekey;
|
||||
}
|
||||
|
||||
|
||||
$descriptions['id'] = acym_translation('ACYM_USER_ID');
|
||||
$descriptions['email'] = acym_translation('ACYM_USER_EMAIL');
|
||||
$descriptions['name'] = acym_translation('ACYM_USER_NAME');
|
||||
$descriptions['cms_id'] = acym_translation('ACYM_USER_CMSID');
|
||||
$descriptions['source'] = acym_translation('ACYM_USER_SOURCE');
|
||||
$descriptions['confirmed'] = acym_translation('ACYM_USER_CONFIRMED');
|
||||
$descriptions['active'] = acym_translation('ACYM_USER_ACTIVE');
|
||||
$descriptions['creation_date'] = acym_translation('ACYM_USER_CREATION_DATE');
|
||||
$descriptions['open_date'] = acym_translation('ACYM_USER_OPEN_DATE');
|
||||
$descriptions['date_click'] = acym_translation('ACYM_USER_CLICK_DATE');
|
||||
$descriptions['send_date'] = acym_translation('ACYM_USER_SEND_DATE');
|
||||
|
||||
$text = '<div class="acym__popup__listing text-center grid-x">';
|
||||
if (!empty($isAutomationAdmin)) {
|
||||
$typeinfo = [];
|
||||
$typeinfo[] = acym_selectOption('receiver', 'ACYM_RECEIVER_INFORMATION');
|
||||
$typeinfo[] = acym_selectOption('current', 'ACYM_USER_TRIGGERING_AUTOMATION');
|
||||
$text .= acym_radio($typeinfo, 'typeinfo', 'receiver', null, ['onclick' => 'changeUserTag(selectedTag)']);
|
||||
}
|
||||
$text .= '<h1 class="acym__popup__plugin__title cell">'.acym_translation('ACYM_RECEIVER_INFORMATION').'</h1>
|
||||
';
|
||||
|
||||
$others = [];
|
||||
$others['name|part:first|ucfirst'] = ['name' => acym_translation('ACYM_USER_FIRSTPART'), 'desc' => acym_translation('ACYM_USER_FIRSTPART_DESC')];
|
||||
$others['name|part:last|ucfirst'] = ['name' => acym_translation('ACYM_USER_LASTPART'), 'desc' => acym_translation('ACYM_USER_LASTPART_DESC')];
|
||||
|
||||
foreach ($others as $tagname => $tag) {
|
||||
$text .= '<div style="cursor:pointer" class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="changeUserTag(\''.$tagname.'\', jQuery(this));" ><div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['name'].'</div><div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['desc'].'</div></div>';
|
||||
}
|
||||
|
||||
foreach ($fields as $fieldname) {
|
||||
if (empty($descriptions[$fieldname])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = '';
|
||||
if (in_array($fieldname, ['creation_date', 'open_date', 'date_click', 'send_date'])) {
|
||||
$type = '|type:time';
|
||||
}
|
||||
|
||||
$text .= '<div style="cursor:pointer" class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="changeUserTag(\''.$fieldname.$type.'\', jQuery(this));" >
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$fieldname.'</div>
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$descriptions[$fieldname].'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$text .= '</div>';
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
public function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$extractedTags = $this->acympluginHelper->extractTags($email, 'subtag');
|
||||
if (empty($extractedTags)) return;
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$user = $userClass->getAllUserFields($user);
|
||||
|
||||
$tags = [];
|
||||
foreach ($extractedTags as $i => $oneTag) {
|
||||
if (isset($tags[$i])) continue;
|
||||
|
||||
if (!empty($oneTag->info) && $oneTag->info == 'current') continue;
|
||||
$tags[$i] = empty($user->id) ? $oneTag->default : $this->replaceSubTag($oneTag, $user);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
private function replaceSubTag(&$mytag, $user)
|
||||
{
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $mytag->id;
|
||||
if (strpos($mytag->id, 'custom') === false) {
|
||||
$replaceme = (isset($user->$field) && strlen($user->$field) > 0) ? $user->$field : $mytag->default;
|
||||
} else {
|
||||
$value = empty($user->id) ? "" : $fieldClass->getAllfieldBackEndListingByUserIds($user->id, explode(',', $field)[1]);
|
||||
|
||||
$replaceme = empty($value) ? $mytag->default : $value[explode(',', $field)[1].$user->id];
|
||||
}
|
||||
$replaceme = nl2br($replaceme);
|
||||
|
||||
$this->acympluginHelper->formatString($replaceme, $mytag);
|
||||
|
||||
return $replaceme;
|
||||
}
|
||||
|
||||
public function onAcymDeclareTriggers(&$triggers)
|
||||
{
|
||||
foreach (self::TRIGGERS as $key => $name) {
|
||||
$triggers['user'][$key] = new stdClass();
|
||||
$triggers['user'][$key]->name = acym_translation($name);
|
||||
$triggers['user'][$key]->option = '<input type="hidden" name="[triggers][user]['.$key.'][]" value="">';
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymExecuteTrigger(&$step, &$execute, $data)
|
||||
{
|
||||
if (empty($data['userId'])) return;
|
||||
|
||||
$triggers = json_decode($step->triggers, true);
|
||||
|
||||
foreach (self::TRIGGERS as $identifier => $name) {
|
||||
if (empty($triggers[$identifier])) continue;
|
||||
|
||||
$execute = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
$fieldClass = acym_get('class.field');
|
||||
$fields = $userClass->getAllColumnsUserAndCustomField();
|
||||
unset($fields['automation']);
|
||||
|
||||
$customFields = $fieldClass->getAllFieldsForUser();
|
||||
$customFieldValues = [];
|
||||
foreach ($customFields as $field) {
|
||||
if (in_array($field->type, ['single_dropdown', 'radio', 'checkbox', 'multiple_dropdown']) && !empty($field->value)) {
|
||||
$values = [];
|
||||
$field->value = json_decode($field->value, true);
|
||||
foreach ($field->value as $value) {
|
||||
$valueTmp = new stdClass();
|
||||
$valueTmp->text = $value['title'];
|
||||
$valueTmp->value = $value['value'];
|
||||
if ($value['disabled'] == 'y') $valueTmp->disable = true;
|
||||
$values[$value['value']] = $valueTmp;
|
||||
}
|
||||
$customFieldValues[$field->id] = '<div class="acym__automation__one-field intext_select_automation cell" style="display: none">';
|
||||
$customFieldValues[$field->id] .= acym_select($values, '[conditions][__numor__][__numand__][acy_field][value]', null, 'class="acym__select acym__automation__conditions__fields__select" data-condition-field="'.$field->id.'"');
|
||||
$customFieldValues[$field->id] .= '</div>';
|
||||
} elseif ('date' == $field->type) {
|
||||
$field->option = json_decode($field->option, true);
|
||||
$customFieldValues[$field->id] = acym_tooltip('<input class="acym__automation__one-field acym__automation__conditions__fields__select intext_input_automation cell" type="text" name="[conditions][__numor__][__numand__][acy_field][value]" style="display: none" data-condition-field="'.$field->id.'">', acym_translation_sprintf('ACYM_DATE_AUTOMATION_INPUT', $field->option['format']), 'intext_select_automation cell');
|
||||
}
|
||||
}
|
||||
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$conditions['user']['acy_field'] = new stdClass();
|
||||
$conditions['user']['acy_field']->name = acym_translation('ACYM_ACYMAILING_FIELD');
|
||||
$conditions['user']['acy_field']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_field']->option .= acym_select($fields, 'acym_condition[conditions][__numor__][__numand__][acy_field][field]', null, 'class="acym__select acym__automation__conditions__fields__dropdown"');
|
||||
$conditions['user']['acy_field']->option .= '</div>';
|
||||
$conditions['user']['acy_field']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_field']->option .= $operator->display('acym_condition[conditions][__numor__][__numand__][acy_field][operator]', '', 'acym__automation__conditions__operator__dropdown');
|
||||
$conditions['user']['acy_field']->option .= '</div>';
|
||||
$conditions['user']['acy_field']->option .= '<input class="acym__automation__one-field intext_input_automation cell acym__automation__condition__regular-field" type="text" name="acym_condition[conditions][__numor__][__numand__][acy_field][value]">';
|
||||
$conditions['user']['acy_field']->option .= implode(' ', $customFieldValues);
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$userClass = acym_get('class.user');
|
||||
$fieldClass = acym_get('class.field');
|
||||
$fields = $userClass->getAllColumnsUserAndCustomField();
|
||||
unset($fields['automation']);
|
||||
|
||||
$customFields = $fieldClass->getAllFieldsForUser();
|
||||
$customFieldValues = [];
|
||||
foreach ($customFields as $field) {
|
||||
if (in_array($field->type, ['single_dropdown', 'radio', 'checkbox', 'multiple_dropdown']) && !empty($field->value)) {
|
||||
$values = [];
|
||||
$field->value = json_decode($field->value, true);
|
||||
foreach ($field->value as $value) {
|
||||
$valueTmp = new stdClass();
|
||||
$valueTmp->text = $value['title'];
|
||||
$valueTmp->value = $value['value'];
|
||||
if ($value['disabled'] == 'y') $valueTmp->disable = true;
|
||||
$values[$value['value']] = $valueTmp;
|
||||
}
|
||||
$customFieldValues[$field->id] = '<div class="acym__automation__one-field intext_select_automation cell" style="display: none">';
|
||||
$customFieldValues[$field->id] .= acym_select($values, '[filters][__numor__][__numand__][acy_field][value]', null, 'class="acym__select acym__automation__filters__fields__select" data-filter-field="'.$field->id.'"');
|
||||
$customFieldValues[$field->id] .= '</div>';
|
||||
} elseif ('date' == $field->type) {
|
||||
$field->option = json_decode($field->option, true);
|
||||
$customFieldValues[$field->id] = acym_tooltip('<input class="acym__automation__one-field acym__automation__filters__fields__select intext_input_automation cell" type="text" name="[filters][__numor__][__numand__][acy_field][value]" style="display: none" data-filter-field="'.$field->id.'">', acym_translation_sprintf('ACYM_DATE_AUTOMATION_INPUT', $field->option['format']), 'intext_select_automation cell');
|
||||
}
|
||||
}
|
||||
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$filters['acy_field'] = new stdClass();
|
||||
$filters['acy_field']->name = acym_translation('ACYM_ACYMAILING_FIELD');
|
||||
$filters['acy_field']->option = '<div class="intext_select_automation cell">';
|
||||
$filters['acy_field']->option .= acym_select($fields, 'acym_action[filters][__numor__][__numand__][acy_field][field]', null, 'class="acym__select acym__automation__filters__fields__dropdown"');
|
||||
$filters['acy_field']->option .= '</div>';
|
||||
$filters['acy_field']->option .= '<div class="intext_select_automation cell">';
|
||||
$filters['acy_field']->option .= $operator->display('acym_action[filters][__numor__][__numand__][acy_field][operator]', '', 'acym__automation__filters__operator__dropdown');
|
||||
$filters['acy_field']->option .= '</div>';
|
||||
$filters['acy_field']->option .= '<input class="acym__automation__one-field intext_input_automation cell acym__automation__filter__regular-field" type="text" name="acym_action[filters][__numor__][__numand__][acy_field][value]">';
|
||||
$filters['acy_field']->option .= implode(' ', $customFieldValues);
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_field(&$query, &$conditionOptions, $num, &$conditionNotValid)
|
||||
{
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (!in_array($conditionOptions['field'], $usersColumns)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldByID($conditionOptions['field']);
|
||||
if ('date' == $field->type) {
|
||||
$conditionOptions['value'] = explode('/', $conditionOptions['value']);
|
||||
$conditionOptions['value'] = json_encode($conditionOptions['value']);
|
||||
}
|
||||
|
||||
$type = 'phone' == $field->type ? 'phone' : '';
|
||||
|
||||
$query->leftjoin['userfield'.$num] = ' #__acym_user_has_field as userfield'.$num.' ON userfield'.$num.'.user_id = user.id AND userfield'.$num.'.field_id = '.intval($conditionOptions['field']);
|
||||
$query->where[] = $query->convertQuery('userfield'.$num, 'value', $conditionOptions['operator'], $conditionOptions['value'], $type);
|
||||
} else {
|
||||
if ($conditionOptions['field'] == 'creation_date') $conditionOptions['value'] = acym_date($conditionOptions['value'], "Y-m-d H:i:s");
|
||||
$query->where[] = $query->convertQuery('user', $conditionOptions['field'], $conditionOptions['operator'], $conditionOptions['value']);
|
||||
}
|
||||
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_acy_field(&$query, &$filterOptions, $num)
|
||||
{
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (!in_array($filterOptions['field'], $usersColumns)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldByID($filterOptions['field']);
|
||||
if ('date' == $field->type) {
|
||||
$filterOptions['value'] = explode('/', $filterOptions['value']);
|
||||
$filterOptions['value'] = json_encode($filterOptions['value']);
|
||||
}
|
||||
|
||||
$type = 'phone' == $field->type ? 'phone' : '';
|
||||
|
||||
$query->leftjoin['userfield'.$num] = ' #__acym_user_has_field as userfield'.$num.' ON userfield'.$num.'.user_id = user.id AND userfield'.$num.'.field_id = '.intval($filterOptions['field']);
|
||||
$query->where[] = $query->convertQuery('userfield'.$num, 'value', $filterOptions['operator'], $filterOptions['value'], $type);
|
||||
} else {
|
||||
if ($filterOptions['field'] == 'creation_date') $filterOptions['value'] = acym_date($filterOptions['value'], "Y-m-d H:i:s");
|
||||
$query->where[] = $query->convertQuery('user', $filterOptions['field'], $filterOptions['operator'], $filterOptions['value']);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_acy_field(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_acy_field($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymDeclareActions(&$actions)
|
||||
{
|
||||
$userActions = [
|
||||
'confirm' => acym_translation('ACYM_CONFIRM_USER'),
|
||||
'unconfirm' => acym_translation('ACYM_UNCONFIRM_USER'),
|
||||
'active' => acym_translation('ACYM_ACTIVE_USER'),
|
||||
'block' => acym_translation('ACYM_BLOCK_USER'),
|
||||
'delete' => acym_translation('ACYM_DELETE_USER'),
|
||||
];
|
||||
|
||||
$actions['acy_user'] = new stdClass();
|
||||
$actions['acy_user']->name = acym_translation('ACYM_ACTION_ON_USERS');
|
||||
$actions['acy_user']->option = '<div class="intext_select_automation cell">'.acym_select($userActions, 'acym_action[actions][__and__][acy_user][action]', null, 'class="acym__select"').'</div>';
|
||||
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$userFields = $userClass->getAllColumnsUserAndCustomField(true);
|
||||
unset($userFields['id']);
|
||||
unset($userFields['cms_id']);
|
||||
unset($userFields['key']);
|
||||
unset($userFields['active']);
|
||||
unset($userFields['source']);
|
||||
unset($userFields['confirmed']);
|
||||
unset($userFields['automation']);
|
||||
unset($userFields['creation_date']);
|
||||
|
||||
$userOperator = [
|
||||
'=' => '=',
|
||||
'-' => '-',
|
||||
'+' => '+',
|
||||
'add_end' => acym_translation('ACYM_ADD_AT_END'),
|
||||
'add_begin' => acym_translation('ACYM_ADD_AT_BEGINNING'),
|
||||
];
|
||||
|
||||
$fieldClass = acym_get('class.field');
|
||||
$customFields = $fieldClass->getAllFieldsForUser();
|
||||
$customFieldValues = [];
|
||||
foreach ($customFields as $field) {
|
||||
if (in_array($field->type, ['single_dropdown', 'radio', 'checkbox', 'multiple_dropdown']) && !empty($field->value)) {
|
||||
$values = [];
|
||||
$field->value = json_decode($field->value, true);
|
||||
foreach ($field->value as $value) {
|
||||
$valueTmp = new stdClass();
|
||||
$valueTmp->text = $value['title'];
|
||||
$valueTmp->value = $value['value'];
|
||||
if ($value['disabled'] == 'y') $valueTmp->disable = true;
|
||||
$values[$value['value']] = $valueTmp;
|
||||
}
|
||||
$customFieldValues[$field->id] = '<div class="acym__automation__one-field intext_select_automation cell" style="display: none">';
|
||||
$customFieldValues[$field->id] .= acym_select($values, '[actions][__and__][acy_user_value][value]', null, 'class="acym__select acym__automation__actions__fields__select" data-action-field="'.$field->id.'"');
|
||||
$customFieldValues[$field->id] .= '</div>';
|
||||
} elseif ('date' == $field->type) {
|
||||
$field->option = json_decode($field->option, true);
|
||||
$customFieldValues[$field->id] = acym_tooltip('<input class="acym__automation__one-field acym__automation__actions__fields__select intext_input_automation cell" type="text" name="[actions][__and__][acy_user_value][value]" style="display: none" data-action-field="'.$field->id.'">', acym_translation_sprintf('ACYM_DATE_AUTOMATION_INPUT', $field->option['format']), 'intext_select_automation cell');
|
||||
}
|
||||
}
|
||||
|
||||
$actions['acy_user_value'] = new stdClass();
|
||||
$actions['acy_user_value']->name = acym_translation('ACYM_SET_USER_VALUE');
|
||||
$actions['acy_user_value']->option = '<div class="intext_select_automation">'.acym_select($userFields, 'acym_action[actions][__and__][acy_user_value][field]', null, 'class="acym__select acym__automation__actions__fields__dropdown"').'</div><div class="intext_select_automation cell">'.acym_select($userOperator, 'acym_action[actions][__and__][acy_user_value][operator]', null, 'class="acym__select acym__automation__actions__operator__dropdown"').'</div><input type="text" name="acym_action[actions][__and__][acy_user_value][value]" class="intext_input_automation cell acym__automation__one-field acym__automation__action__regular-field">';
|
||||
$actions['acy_user_value']->option .= implode(' ', $customFieldValues);
|
||||
|
||||
$actions['acy_add_queue'] = new stdClass();
|
||||
$actions['acy_add_queue']->name = acym_translation('ACYM_ADD_EMAIL_QUEUE');
|
||||
$actions['acy_add_queue']->option = '<button class="shrink grid-x cell acy_button_submit button smaller-button" type="button" data-task="createMail" data-and="__and__">'.acym_translation('ACYM_CREATE_MAIL').'</button>';
|
||||
$actions['acy_add_queue']->option .= '<input type="hidden" name="acym_action[actions][__and__][acy_add_queue][mail_id]">';
|
||||
$actions['acy_add_queue']->option .= '<div class="shrink acym__automation__action__mail__name"></div>';
|
||||
$actions['acy_add_queue']->option .= '<div class="shrink margin-left-1 margin-right-1">'.strtolower(acym_translation('ACYM_OR')).' </div>';
|
||||
$actions['acy_add_queue']->option .= '<button type="button" data-modal-name="acym__template__choose__modal__and__" data-open="acym__template__choose__modal" aria-controls="acym__template__choose__modal" tabindex="0" aria-haspopup="true" class="cell medium-shrink button-secondary auto button smaller-button">'.acym_translation('ACYM_CHOOSE_EXISTING').'</button>';
|
||||
$actions['acy_add_queue']->option .= '<div class="medium-4 grid-x cell">';
|
||||
$actions['acy_add_queue']->option .= acym_dateField('acym_action[actions][__and__][acy_add_queue][time]', '[time]');
|
||||
$actions['acy_add_queue']->option .= '</div>';
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailRemove = $mailClass->getAllTemplatesForSelect();
|
||||
$actions['acy_remove_queue'] = new stdClass();
|
||||
$actions['acy_remove_queue']->name = acym_translation('ACYM_REMOVE_EMAIL_QUEUE');
|
||||
$actions['acy_remove_queue']->option = '<div class="intext_select_automation">'.acym_select($mailRemove, 'acym_action[actions][__and__][acy_remove_queue][mail_id]', null, 'class="acym__select"').'</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessAction_acy_user(&$query, $action)
|
||||
{
|
||||
if ($action['action'] == 'delete') {
|
||||
$userClass = acym_get('class.user');
|
||||
$usersToDelete = acym_loadResultArray($query->getQuery(['user.id']));
|
||||
if (!empty($usersToDelete)) $userClass->delete($usersToDelete);
|
||||
} else {
|
||||
$fieldToUpdate = '';
|
||||
if ($action['action'] == 'confirm') $fieldToUpdate = 'confirmed = 1';
|
||||
if ($action['action'] == 'unconfirm') $fieldToUpdate = 'confirmed = 0';
|
||||
if ($action['action'] == 'active') $fieldToUpdate = 'active = 1';
|
||||
if ($action['action'] == 'block') $fieldToUpdate = 'active = 0';
|
||||
|
||||
$queryToProcess = 'UPDATE #__acym_user AS `user` SET '.$fieldToUpdate.' WHERE ('.implode(') AND (', $query->where).')';
|
||||
$nbRows = acym_query($queryToProcess);
|
||||
|
||||
return acym_translation_sprintf('ACYM_X_USERS_X', $nbRows, acym_translation('ACYM_ACTION_'.strtoupper($action['action'])));
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessAction_acy_user_value(&$query, $action)
|
||||
{
|
||||
$value = $action['value'];
|
||||
|
||||
$replace = ['{year}', '{month}', '{weekday}', '{day}'];
|
||||
$replaceBy = [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(['year', 'month', 'weekday', 'day'], ['Y', 'm', 'N', 'd'], $results[1][$i]);
|
||||
$delay = str_replace(['add', 'remove'], ['+', '-'], $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'] = '=';
|
||||
|
||||
if (in_array($action['operator'], ['+', '-'])) {
|
||||
$value = intval($value);
|
||||
} else {
|
||||
$value = acym_escapeDB($value);
|
||||
}
|
||||
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (in_array($action['field'], $usersColumns)) {
|
||||
$execute = 'UPDATE #__acym_user AS user';
|
||||
|
||||
$column = "user.`".acym_secureDBColumn($action['field'])."`";
|
||||
} else {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldById($action['field']);
|
||||
if (empty($field)) return 'Unknown field: '.$action['field'];
|
||||
if ('date' == $field->type) $value = acym_escapeDB(json_encode(explode('/', trim($value, '"\''))));
|
||||
|
||||
$allColumn = "`user_id`, `field_id`, `value`";
|
||||
$column = "`value`";
|
||||
}
|
||||
|
||||
if ($action['operator'] == '=') {
|
||||
$newValue = $value;
|
||||
} elseif (in_array($action['operator'], ['+', '-'])) {
|
||||
$newValue = $column.' '.$action['operator']." ".$value;
|
||||
} elseif ($action['operator'] == 'add_end') {
|
||||
$newValue = "CONCAT(".$column.", ".$value.")";
|
||||
} elseif ($action['operator'] == 'add_begin') {
|
||||
$newValue = "CONCAT(".$value.", ".$column.")";
|
||||
} else {
|
||||
return 'Unknown operator: '.acym_escape($action['operator']);
|
||||
}
|
||||
|
||||
if (in_array($action['field'], $usersColumns)) {
|
||||
$execute .= " SET ".$column." = ".$newValue;
|
||||
if (!empty($query->where)) $execute .= ' WHERE ('.implode(') AND (', $query->where).')';
|
||||
} else {
|
||||
$customFieldAlreadyExists = acym_loadResult('SELECT COUNT(user_id) FROM #__acym_user_has_field WHERE field_id = '.intval($action['field']));
|
||||
$execute = 'INSERT INTO #__acym_user_has_field ('.$allColumn.') SELECT id AS user_id, '.intval($action['field']).' AS field_id, '.$newValue.' as value FROM #__acym_user AS user WHERE ('.implode(') AND (', $query->where).') ON DUPLICATE KEY UPDATE '.$column.' = VALUES('.$column.')';
|
||||
}
|
||||
|
||||
$nbAffected = acym_query($execute);
|
||||
|
||||
if (!empty($customFieldAlreadyExists)) {
|
||||
$nbAffected -= $customFieldAlreadyExists;
|
||||
}
|
||||
|
||||
return acym_translation_sprintf('ACYM_UPDATED_USERS', $nbAffected);
|
||||
}
|
||||
|
||||
public function onAcymProcessAction_acy_add_queue(&$query, &$action, $automationAdmin)
|
||||
{
|
||||
if (empty($action['time']) || empty($action['mail_id'])) return '';
|
||||
|
||||
$sendDate = acym_replaceDate($action['time']);
|
||||
$sendDate = acym_date($sendDate, "Y-m-d H:i:s", false);
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$mail = $mailClass->getOneById($action['mail_id']);
|
||||
|
||||
if ('automation' != $mail->type) {
|
||||
unset($mail->id);
|
||||
$mail->type = 'automation';
|
||||
$mail->template = 2;
|
||||
$mail->id = $mailClass->save($mail);
|
||||
}
|
||||
|
||||
$userIds = acym_loadResultArray($query->getQuery(['user.id']));
|
||||
$result = $mailClass->sendAutomation($mail->id, $userIds, $sendDate, $automationAdmin);
|
||||
|
||||
if (is_numeric($result)) {
|
||||
return acym_translation_sprintf('ACYM_EMAILS_ADDED_QUEUE', $result);
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessAction_acy_remove_queue(&$query, $action)
|
||||
{
|
||||
if (empty($action['mail_id'])) return '';
|
||||
|
||||
$mailCondition = '';
|
||||
if ($action['mail_id'] != -1) {
|
||||
$mailCondition = ' AND `mail_id` = '.intval($action['mail_id']);
|
||||
}
|
||||
$nbRows = acym_query('DELETE FROM #__acym_queue WHERE `user_id` IN ('.$query->getQuery(['user.id']).')'.$mailCondition);
|
||||
|
||||
return acym_translation_sprintf('ACYM_EMAILS_REMOVED_QUEUE', $nbRows);
|
||||
}
|
||||
|
||||
public function onAcymAfterUserCreate(&$user)
|
||||
{
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('user_creation', ['userId' => $user->id]);
|
||||
}
|
||||
|
||||
public function onAcymAfterUserModify(&$user)
|
||||
{
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('user_modification', ['userId' => $user->id]);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['acy_field'])) {
|
||||
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (!in_array($automationCondition['acy_field']['field'], $usersColumns)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldById($automationCondition['acy_field']['field']);
|
||||
$automationCondition['acy_field']['field'] = $field->name;
|
||||
}
|
||||
$automationCondition = acym_translation_sprintf('ACYM_CONDITION_ACY_FIELD_SUMMARY', $automationCondition['acy_field']['field'], $automationCondition['acy_field']['operator'], $automationCondition['acy_field']['value']);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
if (!empty($automationFilter['acy_field'])) {
|
||||
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (!in_array($automationFilter['acy_field']['field'], $usersColumns)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldById($automationFilter['acy_field']['field']);
|
||||
$automationFilter['acy_field']['field'] = $field->name;
|
||||
}
|
||||
$automationFilter = acym_translation_sprintf('ACYM_FILTER_ACY_FIELD_SUMMARY', $automationFilter['acy_field']['field'], $automationFilter['acy_field']['operator'], $automationFilter['acy_field']['value']);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_actions(&$automationAction)
|
||||
{
|
||||
if (!empty($automationAction['acy_user'])) {
|
||||
$userActions = [
|
||||
'confirm' => acym_translation('ACYM_WILL_CONFIRM'),
|
||||
'unconfirm' => acym_translation('ACYM_WILL_UNCONFIRM'),
|
||||
'active' => acym_translation('ACYM_WILL_ACTIVE'),
|
||||
'block' => acym_translation('ACYM_WILL_BLOCK'),
|
||||
'delete' => acym_translation('ACYM_WILL_DELETE'),
|
||||
];
|
||||
$automationAction = $userActions[$automationAction['acy_user']['action']];
|
||||
}
|
||||
|
||||
if (!empty($automationAction['acy_user_value'])) {
|
||||
$usersColumns = acym_getColumns('user');
|
||||
|
||||
if (!in_array($automationAction['acy_user_value']['field'], $usersColumns)) {
|
||||
$fieldClass = acym_get('class.field');
|
||||
$field = $fieldClass->getOneFieldById($automationAction['acy_user_value']['field']);
|
||||
$automationAction['acy_user_value']['field'] = $field->name;
|
||||
}
|
||||
$automationAction = acym_translation_sprintf('ACYM_ACTION_USER_VALUE_SUMMARY', $automationAction['acy_user_value']['field'], $automationAction['acy_user_value']['operator'], $automationAction['acy_user_value']['value']);
|
||||
}
|
||||
|
||||
if (!empty($automationAction['acy_add_queue'])) {
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = $mailClass->getOneById($automationAction['acy_add_queue']['mail_id']);
|
||||
if (empty($mail)) {
|
||||
$automationAction = '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_MAIL').'</span>';
|
||||
} else {
|
||||
$automationAction = acym_translation_sprintf('ACYM_ACTION_ADD_QUEUE_SUMMARY', $mail->name, acym_date(acym_replaceDate($automationAction['acy_add_queue']['time']), 'd M Y H:i'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($automationAction['acy_remove_queue'])) {
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mail = $mailClass->getOneById($automationAction['acy_remove_queue']['mail_id']);
|
||||
if (empty($mail)) {
|
||||
if ($automationAction['acy_remove_queue']['mail_id'] == -1) {
|
||||
$automationAction = acym_translation('ACYM_EMPTY_QUEUE_USER');
|
||||
} else {
|
||||
$automationAction = '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_MAIL').'</span>';
|
||||
}
|
||||
} else {
|
||||
$automationAction = acym_translation_sprintf('ACYM_ACTION_REMOVE_QUEUE_SUMMARY', $mail->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_triggers(&$automation)
|
||||
{
|
||||
if (!empty($automation->triggers['user_open'])) $automation->triggers['user_open'] = acym_translation('ACYM_WHEN_USER_OPEN_MAIL');
|
||||
if (!empty($automation->triggers['user_click'])) $automation->triggers['user_click'] = acym_translation('ACYM_WHEN_USER_CLICKS_MAIL');
|
||||
if (!empty($automation->triggers['user_modification'])) $automation->triggers['user_modification'] = acym_translation('ACYM_ON_USER_MODIFICATION');
|
||||
if (!empty($automation->triggers['user_creation'])) $automation->triggers['user_creation'] = acym_translation('ACYM_ON_USER_CREATION');
|
||||
if (!empty($automation->triggers['user_subscribe'])) $automation->triggers['user_subscribe'] = acym_translation('ACYM_WHEN_USER_SUBSCRIBES');
|
||||
}
|
||||
|
||||
public function onAcymToggleUserConfirmed($userId, $newValue)
|
||||
{
|
||||
if ($newValue == 1) {
|
||||
$userClass = acym_get('class.user');
|
||||
$userClass->confirm($userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,838 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymSubscription extends acymPlugin
|
||||
{
|
||||
var $listunsubscribe = false;
|
||||
var $lists = [];
|
||||
var $listsowner = [];
|
||||
var $listsinfo = [];
|
||||
var $campaigns = [];
|
||||
var $unsubscribeLink = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
global $acymCmsUserVars;
|
||||
$this->cmsUserVars = $acymCmsUserVars;
|
||||
}
|
||||
|
||||
public function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = acym_translation('ACYM_SUBSCRIPTION');
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->help = 'plugin-subscription';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
public function textPopup()
|
||||
{
|
||||
$others = [];
|
||||
$others['unsubscribe'] = ['name' => acym_translation('ACYM_UNSUBSCRIBE_LINK'), 'default' => 'ACYM_UNSUBSCRIBE'];
|
||||
$others['confirm'] = ['name' => acym_translation('ACYM_CONFIRM_SUBSCRIPTION_LINK'), 'default' => 'ACYM_CONFIRM_SUBSCRIPTION'];
|
||||
$others['subscribe'] = ['name' => acym_translation('ACYM_SUBSCRIBE_LINK'), 'default' => 'ACYM_SUBSCRIBE'];
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
var openLists = true;
|
||||
var selectedTag = '';
|
||||
|
||||
function changeSubscriptionTag(tagName) {
|
||||
selectedTag = tagName;
|
||||
defaultText = [];
|
||||
<?php
|
||||
foreach ($others as $tagname => $tag) {
|
||||
echo 'defaultText["'.$tagname.'"] = "'.acym_translation($tag['default'], true).'";';
|
||||
}
|
||||
?>
|
||||
jQuery('.acym__subscription__subscription').removeClass('selected_row');
|
||||
jQuery('#tr_' + tagName).addClass('selected_row');
|
||||
jQuery('#acym__popup__subscription__tagtext').val(defaultText[tagName]);
|
||||
setSubscriptionTag();
|
||||
}
|
||||
|
||||
function setSubscriptionTag() {
|
||||
var tag = '{' + selectedTag;
|
||||
var lists = jQuery('#acym__popup__subscription__listids');
|
||||
|
||||
if ('subscribe' === selectedTag && lists.html() !== '') {
|
||||
tag += '|lists:' + lists.html();
|
||||
} else {
|
||||
jQuery('#acym__popup__plugin__subscription__lists__modal').hide();
|
||||
jQuery('#select_lists_zone').hide();
|
||||
lists.html('');
|
||||
}
|
||||
|
||||
tag += '}' + jQuery('#acym__popup__subscription__tagtext').val() + '{/' + selectedTag + '}';
|
||||
setTag(tag, jQuery('#tr_' + selectedTag));
|
||||
}
|
||||
|
||||
function displayLists() {
|
||||
jQuery.Modal();
|
||||
jQuery('#acym__popup__plugin__subscription__lists__modal').toggle();
|
||||
jQuery('#select_lists_zone').toggle();
|
||||
openLists = !openLists;
|
||||
jQuery('#acym__popup__subscription__change').on('change', function () {
|
||||
var lists = JSON.parse(jQuery('#acym__modal__lists-selected').val());
|
||||
jQuery('#acym__popup__subscription__listids').html(lists.join());
|
||||
changeSubscriptionTag('subscribe');
|
||||
});
|
||||
}
|
||||
|
||||
//-->
|
||||
</script>
|
||||
<?php
|
||||
|
||||
$text = '<div class="acym__popup__listing text-center grid-x">
|
||||
<h1 class="acym__popup__plugin__title cell">'.acym_translation('ACYM_SUBSCRIPTION').'</h1>
|
||||
<div class="medium-1"></div>
|
||||
<div class="medium-10 text-left">';
|
||||
$text .= acym_modal_pagination_lists('', '', '', '', '', false, 'acym__popup__subscription__change', '', false, 'style="display: none;" id="acym__popup__plugin__subscription__lists__modal"');
|
||||
$text .= ' </div>
|
||||
<div class="medium-1"></div>
|
||||
<div class="grid-x medium-12 cell acym__listing__row text-left">
|
||||
<div class="grid-x cell medium-5 small-12 acym__listing__title acym__listing__title__dynamics acym__subscription__subscription">
|
||||
<label class="small-3" style="line-height: 40px;" for="acym__popup__subscription__tagtext">'.acym_translation('ACYM_TEXT').': </label>
|
||||
<input class="small-9" type="text" name="tagtext" id="acym__popup__subscription__tagtext" onchange="setSubscriptionTag();">
|
||||
</div>
|
||||
<div class="medium-1"></div>
|
||||
<div style="display: none;" id="select_lists_zone" class="grid-x cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">
|
||||
<p class="shrink" id="acym__popup__subscription__text__list">'.acym_translation('ACYM_LISTS_SELECTED').'</button>
|
||||
<p class="shrink" id="acym__popup__subscription__listids"></p>
|
||||
</div>
|
||||
</div>';
|
||||
$text .= '
|
||||
<div class="cell grid-x">';
|
||||
|
||||
foreach ($others as $tagname => $tag) {
|
||||
$onclick = "changeSubscriptionTag('".$tagname."');";
|
||||
if ($tagname == 'subscribe') {
|
||||
$onclick .= 'displayLists();return false;';
|
||||
}
|
||||
$text .= '<div class="grid-x small-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="'.$onclick.'" id="tr_'.$tagname.'" ><div class="cell small-12 acym__listing__title acym__listing__title__dynamics">'.$tag['name'].'</div></div>';
|
||||
}
|
||||
$text .= '</div></div>';
|
||||
|
||||
$others = [];
|
||||
$others['name'] = acym_translation('ACYM_LIST_NAME');
|
||||
$others['names'] = acym_translation('ACYM_LIST_NAMES');
|
||||
$others['id'] = acym_translation('ACYM_LIST_ID', true);
|
||||
|
||||
$text .= '<div class="acym__popup__listing text-center grid-x">
|
||||
<h1 class="acym__popup__plugin__title cell">'.acym_translation('ACYM_LIST').'</h1>
|
||||
<div class="cell grid-x">';
|
||||
|
||||
foreach ($others as $tagname => $tag) {
|
||||
$text .= '<div class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="setTag(\'{list:'.$tagname.'}\', jQuery(this));" id="tr_'.$tagname.'" >
|
||||
<div class="cell medium-12 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag.'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$text .= '</div></div>';
|
||||
|
||||
$text .= '<div class="acym__popup__listing text-center grid-x">
|
||||
<span class="acym__popup__plugin__title cell">'.acym_translation('ACYM_CAMPAIGN').'</span>
|
||||
<div class="cell grid-x">';
|
||||
$othersMail = ['campaignid', 'subject'];
|
||||
|
||||
foreach ($othersMail as $tag) {
|
||||
$text .= '<div class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="setTag(\'{mail:'.$tag.'}\', jQuery(this));" id="tr_'.$tag.'" >
|
||||
<div class="cell medium-12 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag.'</div>
|
||||
</div>';
|
||||
}
|
||||
$text .= '</div></div>';
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
public function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$this->_replacelisttags($email, $user, $send);
|
||||
|
||||
if (empty($user) || !$this->unsubscribeLink || $this->listunsubscribe || !method_exists($email, 'addCustomHeader')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lang = empty($email->lang) ? '' : '&lang='.$email->lang;
|
||||
$myLink = acym_frontendLink('frontusers&subid='.intval($user->id).'&task=unsubscribe&id='.$email->id.'&key='.urlencode($user->key).$lang.'&'.acym_noTemplate());
|
||||
|
||||
$this->listunsubscribe = true;
|
||||
if (!empty($email->replyemail)) {
|
||||
$mailto = $email->replyemail;
|
||||
}
|
||||
if (empty($mailto)) {
|
||||
$config = acym_config();
|
||||
$mailto = $config->get('replyto_email');
|
||||
}
|
||||
$email->addCustomHeader('List-Unsubscribe: <'.$myLink.'>, <mailto:'.$mailto.'?subject=unsubscribe_user_'.$user->id.'&body=Please%20unsubscribe%20user%20ID%20'.$user->id.'>');
|
||||
}
|
||||
|
||||
public function replaceContent(&$email, $send = true)
|
||||
{
|
||||
$this->_replaceSubscriptionTags($email);
|
||||
$this->_replacemailtags($email);
|
||||
}
|
||||
|
||||
private function _replacemailtags(&$email)
|
||||
{
|
||||
$result = $this->acympluginHelper->extractTags($email, 'mail');
|
||||
$tags = [];
|
||||
|
||||
foreach ($result as $key => $oneTag) {
|
||||
if (isset($tags[$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$field = $oneTag->id;
|
||||
if (!empty($email) && !empty($email->$field)) {
|
||||
$text = $email->$field;
|
||||
$this->acympluginHelper->formatString($text, $oneTag);
|
||||
$tags[$key] = $text;
|
||||
} else {
|
||||
$tags[$key] = $oneTag->default;
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
private function _replacelisttags(&$email, &$user, $send)
|
||||
{
|
||||
$tags = $this->acympluginHelper->extractTags($email, 'list');
|
||||
if (empty($tags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$replaceTags = [];
|
||||
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->acympluginHelper->replaceTags($email, $replaceTags, true);
|
||||
}
|
||||
|
||||
private function _getAttachedListid($email, $subid)
|
||||
{
|
||||
$mailid = $email->id;
|
||||
$type = strtolower($email->type);
|
||||
|
||||
if (isset($this->lists[$mailid][$subid])) {
|
||||
return $this->lists[$mailid][$subid];
|
||||
}
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
$mailLists = array_keys($mailClass->getAllListsByMailId($mailid));
|
||||
$userLists = [];
|
||||
|
||||
if (!empty($subid)) {
|
||||
$userClass = acym_get('class.user');
|
||||
$userLists = $userClass->getUserSubscriptionById($subid);
|
||||
|
||||
$listid = null;
|
||||
foreach ($userLists as $id => $oneList) {
|
||||
if ($oneList->status == 1 && in_array($id, $mailLists)) {
|
||||
$this->lists[$mailid][$subid] = $id;
|
||||
|
||||
return $this->lists[$mailid][$subid];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($listid)) {
|
||||
$this->lists[$mailid][$subid] = $listid;
|
||||
|
||||
return $listid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($mailLists)) {
|
||||
$this->lists[$mailid][$subid] = array_shift($mailLists);
|
||||
|
||||
return $this->lists[$mailid][$subid];
|
||||
}
|
||||
|
||||
if ($type == 'welcome' && !empty($subid)) {
|
||||
$listid = acym_loadResult(
|
||||
'SELECT list.id
|
||||
FROM #__acym_list AS list
|
||||
JOIN #__acym_user_has_list AS userlist ON list.id = userlist.list_id
|
||||
WHERE list.welcome_id = '.intval($mailid).' AND userlist.user_id = '.intval($subid).'
|
||||
ORDER BY userlist.subscription_date DESC'
|
||||
);
|
||||
if (!empty($listid)) {
|
||||
$this->lists[$mailid][$subid] = $listid;
|
||||
|
||||
return $listid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'unsubscribe' && !empty($subid)) {
|
||||
$listid = acym_loadResult(
|
||||
'SELECT list.id
|
||||
FROM #__acym_list AS list
|
||||
JOIN #__acym_user_has_list AS userlist ON list.id = userlist.list_id
|
||||
WHERE list.unsubscribe_id = '.intval($mailid).' AND userlist.user_id = '.intval($subid).'
|
||||
ORDER BY userlist.unsubscribe_date DESC'
|
||||
);
|
||||
if (!empty($listid)) {
|
||||
$this->lists[$mailid][$subid] = $listid;
|
||||
|
||||
return $listid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($userLists)) {
|
||||
$listIds = array_keys($userLists);
|
||||
$this->lists[$mailid][$subid] = array_shift($listIds);
|
||||
|
||||
return $this->lists[$mailid][$subid];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function _listnames(&$email, &$user, &$parameter)
|
||||
{
|
||||
if (empty($user->id)) return '';
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
$usersubscription = $userClass->getUserSubscriptionById($user->id);
|
||||
$lists = [];
|
||||
if (!empty($usersubscription)) {
|
||||
foreach ($usersubscription as $onesub) {
|
||||
if ($onesub->status < 1 || empty($onesub->active)) {
|
||||
continue;
|
||||
}
|
||||
$lists[] = $onesub->name;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(isset($parameter->separator) ? $parameter->separator : ', ', $lists);
|
||||
}
|
||||
|
||||
private function _listowner(&$email, &$user, &$parameter)
|
||||
{
|
||||
if (empty($user->id)) {
|
||||
return '';
|
||||
}
|
||||
$listid = $this->_getAttachedListid($email, $user->id);
|
||||
if (empty($listid)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!isset($this->listsowner[$listid])) {
|
||||
$this->listsowner[$listid] = acym_loadObject('SELECT user.* FROM #__acym_list AS list JOIN '.$this->cmsUserVars->table.' AS user ON user.'.$this->cmsUserVars->id.' = list.cms_user_id WHERE list.id = '.intval($listid));
|
||||
}
|
||||
|
||||
if (!in_array($parameter->field, [$this->cmsUserVars->username, $this->cmsUserVars->name, $this->cmsUserVars->email])) {
|
||||
return 'Field not found : '.$parameter->field;
|
||||
}
|
||||
|
||||
return @$this->listsowner[$listid]->{$this->cmsUserVars->{$parameter->field}};
|
||||
}
|
||||
|
||||
private function _loadlist($listid)
|
||||
{
|
||||
if (isset($this->listsinfo[$listid])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$this->listsinfo[$listid] = $listClass->getOneById(intval($listid));
|
||||
}
|
||||
|
||||
private function _listname(&$email, &$user, &$parameter)
|
||||
{
|
||||
if (empty($user->id)) {
|
||||
return '';
|
||||
}
|
||||
$listid = $this->_getAttachedListid($email, $user->id);
|
||||
if (empty($listid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->_loadlist($listid);
|
||||
|
||||
return @$this->listsinfo[$listid]->name;
|
||||
}
|
||||
|
||||
private function _listid(&$email, &$user, &$parameter)
|
||||
{
|
||||
if (empty($user->id)) {
|
||||
return '';
|
||||
}
|
||||
$listid = $this->_getAttachedListid($email, $user->id);
|
||||
if (empty($listid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $listid;
|
||||
}
|
||||
|
||||
private function _replaceSubscriptionTags(&$email)
|
||||
{
|
||||
$match = '#(?:{|%7B)(confirm[^}]*|unsubscribe(?:\|[^}]*)?|subscribe[^}]*)(?:}|%7D)(.*)(?:{|%7B)/(confirm|unsubscribe|subscribe)(?:}|%7D)#Uis';
|
||||
$variables = ['subject', 'body'];
|
||||
$found = false;
|
||||
$results = [];
|
||||
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 = [];
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
private function _replaceSubscriptionTag(&$allresults, $i, &$email)
|
||||
{
|
||||
$config = acym_config();
|
||||
$lang = empty($email->lang) ? '' : '&lang='.$email->lang;
|
||||
|
||||
$parameters = $this->acympluginHelper->extractTag($allresults[1][$i]);
|
||||
|
||||
if ($parameters->id == 'confirm') {
|
||||
$myLink = acym_frontendLink('frontusers&task=confirm&id={subtag:id}&key={subtag:key|urlencode}'.$lang);
|
||||
if (empty($allresults[2][$i])) {
|
||||
return $myLink;
|
||||
}
|
||||
|
||||
return '<a target="_blank" href="'.$myLink.'">'.$allresults[2][$i].'</a>';
|
||||
} elseif ($parameters->id == 'subscribe') {
|
||||
if (empty($parameters->lists)) {
|
||||
return 'You must select at least one list';
|
||||
}
|
||||
$lists = explode(',', $parameters->lists);
|
||||
acym_arrayToInteger($lists);
|
||||
$captchaKey = $config->get('captcha', '') == 1 ? '&seckey='.$config->get('security_key', '') : '';
|
||||
$myLink = acym_frontendLink('frontusers&task=subscribe&hiddenlists='.implode(',', $lists).'&user[email]={subtag:email|urlencode}'.$lang.$captchaKey);
|
||||
if (empty($allresults[2][$i])) {
|
||||
return $myLink;
|
||||
}
|
||||
|
||||
return '<a style="text-decoration:none;" target="_blank" href="'.$myLink.'"><span class="acym_subscribe">'.$allresults[2][$i].'</span></a>';
|
||||
} else {
|
||||
$this->unsubscribeLink = true;
|
||||
|
||||
$myLink = acym_frontendLink('frontusers&task=unsubscribe&id={subtag:id}&key={subtag:key|urlencode}&'.acym_noTemplate().$lang.'&mail_id='.$email->id);
|
||||
if (empty($allresults[2][$i])) {
|
||||
return $myLink;
|
||||
}
|
||||
|
||||
return '<a style="text-decoration:none;" target="_blank" href="'.$myLink.'"><span class="acym_unsubscribe">'.$allresults[2][$i].'</span></a>';
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
$listClass = acym_get('class.list');
|
||||
$list = [
|
||||
'type' => [
|
||||
'sub' => acym_translation('ACYM_SUBSCRIBED'),
|
||||
'unsub' => acym_translation('ACYM_UNSUBSCRIBED'),
|
||||
'notsub' => acym_translation('ACYM_NO_SUBSCRIPTION_STATUS'),
|
||||
],
|
||||
'lists' => $listClass->getAllForSelect(),
|
||||
'date' => [
|
||||
'subscription_date' => acym_translation('ACYM_SUBSCRIPTION_DATE'),
|
||||
'unsubscribe_date' => acym_translation('ACYM_UNSUBSCRIPTION_DATE'),
|
||||
],
|
||||
];
|
||||
|
||||
$conditions['user']['acy_list'] = new stdClass();
|
||||
$conditions['user']['acy_list']->name = acym_translation('ACYM_ACYMAILING_LIST');
|
||||
$conditions['user']['acy_list']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_list']->option .= acym_select($list['type'], 'acym_condition[conditions][__numor__][__numand__][acy_list][action]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['user']['acy_list']->option .= '</div>';
|
||||
$conditions['user']['acy_list']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_list']->option .= acym_select($list['lists'], 'acym_condition[conditions][__numor__][__numand__][acy_list][list]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['user']['acy_list']->option .= '</div>';
|
||||
$conditions['user']['acy_list']->option .= '<br><div class="cell grid-x grid-margin-x">';
|
||||
$conditions['user']['acy_list']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][acy_list][date-min]');
|
||||
$conditions['user']['acy_list']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['acy_list']->option .= '<div class="intext_select_automation">';
|
||||
$conditions['user']['acy_list']->option .= acym_select($list['date'], 'acym_condition[conditions][__numor__][__numand__][acy_list][date-type]', null, 'class="intext_select_automation acym__select cell"');
|
||||
$conditions['user']['acy_list']->option .= '</div>';
|
||||
$conditions['user']['acy_list']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['user']['acy_list']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][acy_list][date-max]');
|
||||
|
||||
$conditions['classic']['acy_list_all'] = new stdClass();
|
||||
$conditions['classic']['acy_list_all']->name = acym_translation('ACYM_NUMBER_USERS_LIST');
|
||||
$conditions['classic']['acy_list_all']->option = '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_THERE_IS').'</div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_select(['>' => acym_translation('ACYM_MORE_THAN'), '<' => acym_translation('ACYM_LESS_THAN'), '=' => acym_translation('ACYM_EXACTLY')], 'acym_condition[conditions][__numor__][__numand__][acy_list_all][operator]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['classic']['acy_list_all']->option .= '</div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<input type="number" min="0" class="intext_input_automation cell" name="acym_condition[conditions][__numor__][__numand__][acy_list_all][number]">';
|
||||
$conditions['classic']['acy_list_all']->option .= '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_ACYMAILING_USERS').'</div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<div class="cell grid-x grid-margin-x margin-left-0" style="margin-bottom: 0"><div class="intext_select_automation cell">';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_select($list['type'], 'acym_condition[conditions][__numor__][__numand__][acy_list_all][action]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['classic']['acy_list_all']->option .= '</div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_select($list['lists'], 'acym_condition[conditions][__numor__][__numand__][acy_list_all][list]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['classic']['acy_list_all']->option .= '</div></div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<br><div class="cell grid-x grid-margin-x">';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][acy_list_all][date-min]');
|
||||
$conditions['classic']['acy_list_all']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<div class="intext_select_automation">';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_select($list['date'], 'acym_condition[conditions][__numor__][__numand__][acy_list_all][date-type]', null, 'class="intext_select_automation acym__select cell"');
|
||||
$conditions['classic']['acy_list_all']->option .= '</div>';
|
||||
$conditions['classic']['acy_list_all']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$conditions['classic']['acy_list_all']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][acy_list_all][date-max]');
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$listClass = acym_get('class.list');
|
||||
$list = [
|
||||
'type' => [
|
||||
'sub' => acym_translation('ACYM_SUBSCRIBED'),
|
||||
'unsub' => acym_translation('ACYM_UNSUBSCRIBED'),
|
||||
'notsub' => acym_translation('ACYM_NO_SUBSCRIPTION_STATUS'),
|
||||
],
|
||||
'lists' => $listClass->getAllForSelect(),
|
||||
'date' => [
|
||||
'subscription_date' => acym_translation('ACYM_SUBSCRIPTION_DATE'),
|
||||
'unsubscribe_date' => acym_translation('ACYM_UNSUBSCRIPTION_DATE'),
|
||||
],
|
||||
];
|
||||
|
||||
$filters['acy_list'] = new stdClass();
|
||||
$filters['acy_list']->name = acym_translation('ACYM_ACYMAILING_LIST');
|
||||
$filters['acy_list']->option = '<div class="intext_select_automation cell">';
|
||||
$filters['acy_list']->option .= acym_select($list['type'], 'acym_action[filters][__numor__][__numand__][acy_list][action]', null, 'class="intext_select_automation acym__select"');
|
||||
$filters['acy_list']->option .= '</div>';
|
||||
$filters['acy_list']->option .= '<div class="intext_select_automation cell">';
|
||||
$filters['acy_list']->option .= acym_select($list['lists'], 'acym_action[filters][__numor__][__numand__][acy_list][list]', null, 'class="intext_select_automation acym__select"');
|
||||
$filters['acy_list']->option .= '</div>';
|
||||
$filters['acy_list']->option .= '<br><div class="cell grid-x grid-margin-x">';
|
||||
$filters['acy_list']->option .= acym_dateField('acym_action[filters][__numor__][__numand__][acy_list][date-min]');
|
||||
$filters['acy_list']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$filters['acy_list']->option .= '<div class="intext_select_automation">';
|
||||
$filters['acy_list']->option .= acym_select($list['date'], 'acym_action[filters][__numor__][__numand__][acy_list][date-type]', null, 'class="intext_select_automation acym__select cell"');
|
||||
$filters['acy_list']->option .= '</div>';
|
||||
$filters['acy_list']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 margin-left-1 margin-right-1"><</span>';
|
||||
$filters['acy_list']->option .= acym_dateField('acym_action[filters][__numor__][__numand__][acy_list][date-max]');
|
||||
$filters['acy_list']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymDeclareActions(&$actions)
|
||||
{
|
||||
$listClass = acym_get('class.list');
|
||||
|
||||
$listActions = [
|
||||
'sub' => acym_translation('ACYM_SUBSCRIBE_USERS_TO'),
|
||||
'remove' => acym_translation('ACYM_REMOVE_USERS_FROM'),
|
||||
'unsub' => acym_translation('ACYM_UNSUBSCRIBE_USERS_TO'),
|
||||
];
|
||||
$lists = $listClass->getAllForSelect();
|
||||
|
||||
$actions['acy_list'] = new stdClass();
|
||||
$actions['acy_list']->name = acym_translation('ACYM_ACYMAILING_LIST');
|
||||
$actions['acy_list']->option = '<div class="intext_select_automation cell">';
|
||||
$actions['acy_list']->option .= acym_select($listActions, 'acym_action[actions][__and__][acy_list][list_actions]', null, 'class="acym__select"');
|
||||
$actions['acy_list']->option .= '</div>';
|
||||
$actions['acy_list']->option .= '<div class="intext_select_automation cell">';
|
||||
$actions['acy_list']->option .= acym_select($lists, 'acym_action[actions][__and__][acy_list][list_id]', null, 'class="acym__select"');
|
||||
$actions['acy_list']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_list(&$query, &$options, $num, &$conditionNotValid)
|
||||
{
|
||||
$otherConditions = '';
|
||||
if (!empty($options['date-min'])) {
|
||||
$options['date-min'] = acym_replaceDate($options['date-min']);
|
||||
if (!is_numeric($options['date-min'])) {
|
||||
$options['date-min'] = strtotime($options['date-min']);
|
||||
}
|
||||
if (!empty($options['date-min'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($options['date-type']).' > '.acym_escapeDB(acym_date($options['date-min'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
if (!empty($options['date-max'])) {
|
||||
$options['date-max'] = acym_replaceDate($options['date-max']);
|
||||
if (!is_numeric($options['date-max'])) {
|
||||
$options['date-max'] = strtotime($options['date-max']);
|
||||
}
|
||||
if (!empty($options['date-max'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($options['date-type']).' < '.acym_escapeDB(acym_date($options['date-max'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
|
||||
$query->leftjoin['list'.$num] = '#__acym_user_has_list as userlist'.$num.' ON user.id = userlist'.$num.'.user_id AND userlist'.$num.'.list_id = '.intval($options['list']).$otherConditions;
|
||||
if ($options['action'] == 'notsub') {
|
||||
$query->where[] = 'userlist'.$num.'.user_id IS NULL';
|
||||
} else {
|
||||
$status = $options['action'] == 'sub' ? '1' : '0';
|
||||
$query->where[] = 'userlist'.$num.'.status = '.intval($status);
|
||||
}
|
||||
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_list_all(&$query, &$options, $num, &$conditionNotValid)
|
||||
{
|
||||
$otherConditions = '';
|
||||
if (!empty($options['date-min'])) {
|
||||
$options['date-min'] = acym_replaceDate($options['date-min']);
|
||||
if (!is_numeric($options['date-min'])) {
|
||||
$options['date-min'] = strtotime($options['date-min']);
|
||||
}
|
||||
if (!empty($options['date-min'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($options['date-type']).' > '.acym_escapeDB(acym_date($options['date-min'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
if (!empty($options['date-max'])) {
|
||||
$options['date-max'] = acym_replaceDate($options['date-max']);
|
||||
if (!is_numeric($options['date-max'])) {
|
||||
$options['date-max'] = strtotime($options['date-max']);
|
||||
}
|
||||
if (!empty($options['date-max'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($options['date-type']).' < '.acym_escapeDB(acym_date($options['date-max'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
|
||||
$query->leftjoin['list'.$num] = '#__acym_user_has_list as userlist'.$num.' ON user.id = userlist'.$num.'.user_id AND userlist'.$num.'.list_id = '.intval($options['list']).$otherConditions;
|
||||
if ($options['action'] == 'notsub') {
|
||||
$query->where[] = 'userlist'.$num.'.user_id IS NULL';
|
||||
} else {
|
||||
$status = $options['action'] == 'sub' ? '1' : '0';
|
||||
$query->where[] = 'userlist'.$num.'.status = '.intval($status);
|
||||
}
|
||||
|
||||
$numberReturn = $query->count();
|
||||
$res = false;
|
||||
|
||||
switch ($options['operator']) {
|
||||
case '=' :
|
||||
$res = $numberReturn == $options['number'];
|
||||
break;
|
||||
case '>' :
|
||||
$res = $numberReturn > $options['number'];
|
||||
break;
|
||||
case '<' :
|
||||
$res = $numberReturn < $options['number'];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$res) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_acy_list(&$query, &$filterOptions, $num)
|
||||
{
|
||||
$otherConditions = '';
|
||||
if (!empty($filterOptions['date-min'])) {
|
||||
$filterOptions['date-min'] = acym_replaceDate($filterOptions['date-min']);
|
||||
if (!is_numeric($filterOptions['date-min'])) {
|
||||
$filterOptions['date-min'] = strtotime($filterOptions['date-min']);
|
||||
}
|
||||
if (!empty($filterOptions['date-min'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($filterOptions['date-type']).' > '.acym_escapeDB(acym_date($filterOptions['date-min'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
if (!empty($filterOptions['date-max'])) {
|
||||
$filterOptions['date-max'] = acym_replaceDate($filterOptions['date-max']);
|
||||
if (!is_numeric($filterOptions['date-max'])) {
|
||||
$filterOptions['date-max'] = strtotime($filterOptions['date-max']);
|
||||
}
|
||||
if (!empty($filterOptions['date-max'])) {
|
||||
$otherConditions .= ' AND userlist'.$num.'.'.acym_secureDBColumn($filterOptions['date-type']).' < '.acym_escapeDB(acym_date($filterOptions['date-max'], "Y-m-d H:i:s"));
|
||||
}
|
||||
}
|
||||
|
||||
$query->leftjoin['list'.$num] = '#__acym_user_has_list as userlist'.$num.' ON user.id = userlist'.$num.'.user_id AND userlist'.$num.'.list_id = '.intval($filterOptions['list']).$otherConditions;
|
||||
if ($filterOptions['action'] == 'notsub') {
|
||||
$query->where[] = 'userlist'.$num.'.user_id IS NULL';
|
||||
} else {
|
||||
$status = $filterOptions['action'] == 'sub' ? '1' : '0';
|
||||
$query->where[] = 'userlist'.$num.'.status = '.intval($status);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_acy_list(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_acy_list($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessAction_acy_list(&$query, $action)
|
||||
{
|
||||
if ($action['list_actions'] == 'sub') {
|
||||
$queryToProcess = 'INSERT IGNORE #__acym_user_has_list (`user_id`, `list_id`, `status`, `subscription_date`) ('.$query->getQuery(
|
||||
[
|
||||
'user.id',
|
||||
$action['list_id'],
|
||||
'1',
|
||||
acym_escapeDB(acym_date(time(), "Y-m-d H:i:s")),
|
||||
]
|
||||
).') ON DUPLICATE KEY UPDATE status = 1';
|
||||
} elseif ($action['list_actions'] == 'remove') {
|
||||
$queryToProcess = 'DELETE FROM #__acym_user_has_list WHERE list_id = '.intval($action['list_id']).' AND user_id IN ('.$query->getQuery(['user.id']).')';
|
||||
} elseif ($action['list_actions'] == 'unsub') {
|
||||
$queryToProcess = 'UPDATE #__acym_user_has_list SET status = 0 WHERE list_id = '.intval($action['list_id']).' AND user_id IN ('.$query->getQuery(['user.id']).')';
|
||||
}
|
||||
|
||||
$nbAffected = acym_query($queryToProcess);
|
||||
|
||||
return acym_translation_sprintf('ACYM_ACTION_LIST_'.strtoupper($action['list_actions']), $nbAffected);
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['acy_list'])) {
|
||||
$finalText = '';
|
||||
$listClass = acym_get('class.list');
|
||||
$automationCondition['acy_list']['list'] = $listClass->getOneById($automationCondition['acy_list']['list']);
|
||||
if (empty($automationCondition['acy_list']['list'])) {
|
||||
$automationCondition = '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_LIST').'</span>';
|
||||
|
||||
return;
|
||||
}
|
||||
if ($automationCondition['acy_list']['action'] == 'sub') $automationCondition['acy_list']['action'] = 'ACYM_IS_SUBSCRIBED';
|
||||
if ($automationCondition['acy_list']['action'] == 'unsub') $automationCondition['acy_list']['action'] = 'ACYM_IS_UNSUBSCRIBED';
|
||||
if ($automationCondition['acy_list']['action'] == 'notsub') $automationCondition['acy_list']['action'] = 'ACYM_IS_NOT_SUBSCRIBED';
|
||||
$finalText .= acym_translation_sprintf('ACYM_CONDITION_ACY_LIST_SUMMARY', acym_translation($automationCondition['acy_list']['action']), $automationCondition['acy_list']['list']->name).' ';
|
||||
if (!empty($automationCondition['acy_list']['date-min']) || !empty($automationCondition['acy_list']['date-max'])) {
|
||||
$finalText .= acym_translation_sprintf('ACYM_WHERE_DATE_ACY_LIST_SUMMARY', strtolower(acym_translation('ACYM_'.strtoupper($automationCondition['acy_list']['date-type']))));
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['acy_list']['date-min'])) {
|
||||
$automationCondition['acy_list']['date-min'] = acym_replaceDate($automationCondition['acy_list']['date-min']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MIN_ACY_LIST_SUMMARY', acym_date($automationCondition['acy_list']['date-min'], 'd M Y H:i'));
|
||||
}
|
||||
if (!empty($automationCondition['acy_list']['date-max'])) {
|
||||
$automationCondition['acy_list']['date-max'] = acym_replaceDate($automationCondition['acy_list']['date-max']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MAX_ACY_LIST_SUMMARY', acym_date($automationCondition['acy_list']['date-max'], 'd M Y H:i'));
|
||||
}
|
||||
|
||||
$finalText .= ' '.implode(' '.strtolower(acym_translation('ACYM_AND')).' ', $dates);
|
||||
}
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($automationCondition['acy_list_all'])) {
|
||||
$operators = ['=' => acym_translation('ACYM_EXACTLY'), '>' => acym_translation('ACYM_MORE_THAN'), '<' => acym_translation('ACYM_LESS_THAN')];
|
||||
$finalText = acym_translation('ACYM_THERE_IS').' '.strtolower($operators[$automationCondition['acy_list_all']['operator']]).' '.$automationCondition['acy_list_all']['number'].' '.acym_translation('ACYM_ACYMAILING_USERS').' ';
|
||||
$listClass = acym_get('class.list');
|
||||
$automationCondition['acy_list_all']['list'] = $listClass->getOneById($automationCondition['acy_list_all']['list']);
|
||||
if (empty($automationCondition['acy_list_all']['list'])) {
|
||||
$automationCondition = '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_LIST').'</span>';
|
||||
|
||||
return;
|
||||
}
|
||||
if ($automationCondition['acy_list_all']['action'] == 'sub') $automationCondition['acy_list_all']['action'] = 'ACYM_SUBSCRIBED';
|
||||
if ($automationCondition['acy_list_all']['action'] == 'unsub') $automationCondition['acy_list_all']['action'] = 'ACYM_UNSUBSCRIBED';
|
||||
if ($automationCondition['acy_list_all']['action'] == 'notsub') $automationCondition['acy_list_all']['action'] = 'ACYM__NOT_SUBSCRIBED';
|
||||
$finalText .= acym_translation_sprintf('ACYM_CONDITION_ACY_LIST_SUMMARY', acym_translation($automationCondition['acy_list_all']['action']), $automationCondition['acy_list_all']['list']->name).' ';
|
||||
if (!empty($automationCondition['acy_list_all']['date-min']) || !empty($automationCondition['acy_list_all']['date-max'])) {
|
||||
$finalText .= acym_translation_sprintf('ACYM_WHERE_DATE_ACY_LIST_SUMMARY', strtolower(acym_translation('ACYM_'.strtoupper($automationCondition['acy_list_all']['date-type']))));
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['acy_list_all']['date-min'])) {
|
||||
$automationCondition['acy_list_all']['date-min'] = acym_replaceDate($automationCondition['acy_list_all']['date-min']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MIN_ACY_LIST_SUMMARY', acym_date($automationCondition['acy_list_all']['date-min'], 'd M Y H:i'));
|
||||
}
|
||||
if (!empty($automationCondition['acy_list_all']['date-max'])) {
|
||||
$automationCondition['acy_list_all']['date-max'] = acym_replaceDate($automationCondition['acy_list_all']['date-max']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MAX_ACY_LIST_SUMMARY', acym_date($automationCondition['acy_list_all']['date-max'], 'd M Y H:i'));
|
||||
}
|
||||
|
||||
$finalText .= ' '.implode(' '.strtolower(acym_translation('ACYM_AND')).' ', $dates);
|
||||
}
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
if (!empty($automationFilter['acy_list'])) {
|
||||
$finalText = '';
|
||||
$listClass = acym_get('class.list');
|
||||
$automationFilter['acy_list']['list'] = $listClass->getOneById($automationFilter['acy_list']['list']);
|
||||
if (empty($automationFilter['acy_list']['list'])) {
|
||||
$automationFilter = '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_LIST').'</span>';
|
||||
|
||||
return;
|
||||
}
|
||||
if ($automationFilter['acy_list']['action'] == 'sub') $automationFilter['acy_list']['action'] = 'ACYM_SUBSCRIBED';
|
||||
if ($automationFilter['acy_list']['action'] == 'unsub') $automationFilter['acy_list']['action'] = 'ACYM_UNSUBSCRIBED';
|
||||
if ($automationFilter['acy_list']['action'] == 'notsub') $automationFilter['acy_list']['action'] = 'ACYM_NOT_SUBSCRIBED';
|
||||
$finalText .= acym_translation_sprintf('ACYM_FILTER_ACY_LIST_SUMMARY', acym_translation($automationFilter['acy_list']['action']), $automationFilter['acy_list']['list']->name).' ';
|
||||
if (!empty($automationFilter['acy_list']['date-min']) || !empty($automationFilter['acy_list']['date-max'])) {
|
||||
$finalText .= acym_translation_sprintf('ACYM_WHERE_DATE_ACY_LIST_SUMMARY', strtolower(acym_translation('ACYM_'.strtoupper($automationFilter['acy_list']['date-type']))));
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationFilter['acy_list']['date-min'])) {
|
||||
$automationFilter['acy_list']['date-min'] = acym_replaceDate($automationFilter['acy_list']['date-min']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MIN_ACY_LIST_SUMMARY', acym_date($automationFilter['acy_list']['date-min'], 'd M Y H:i'));
|
||||
}
|
||||
if (!empty($automationFilter['acy_list']['date-max'])) {
|
||||
$automationFilter['acy_list']['date-max'] = acym_replaceDate($automationFilter['acy_list']['date-max']);
|
||||
$dates[] = acym_translation_sprintf('ACYM_WHERE_DATE_MAX_ACY_LIST_SUMMARY', acym_date($automationFilter['acy_list']['date-max'], 'd M Y H:i'));
|
||||
}
|
||||
|
||||
$finalText .= ' '.implode(' '.strtolower(acym_translation('ACYM_AND')).' ', $dates);
|
||||
}
|
||||
$automationFilter = $finalText;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_actions(&$automationAction)
|
||||
{
|
||||
if (!empty($automationAction['acy_list'])) {
|
||||
$listClass = acym_get('class.list');
|
||||
$list = $listClass->getOneById($automationAction['acy_list']['list_id']);
|
||||
if ($automationAction['acy_list']['list_actions'] == 'sub') $automationAction['acy_list']['list_actions'] = 'ACYM_SUBSCRIBED_TO';
|
||||
if ($automationAction['acy_list']['list_actions'] == 'unsub') $automationAction['acy_list']['list_actions'] = 'ACYM_UNSUBSCRIBE_FROM';
|
||||
if ($automationAction['acy_list']['list_actions'] == 'remove') $automationAction['acy_list']['list_actions'] = 'ACYM_REMOVE_FROM';
|
||||
$automationAction = empty($list) ? '<span class="acym__color__red">'.acym_translation('ACYM_SELECT_A_LIST').'</span>' : acym_translation_sprintf('ACYM_ACTION_LIST_SUMMARY', acym_translation($automationAction['acy_list']['list_actions']), $list->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function onAcymAfterUserSubscribe(&$user, $lists)
|
||||
{
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('user_subscribe', ['userId' => $user->id]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymTime extends acymPlugin
|
||||
{
|
||||
public function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = acym_translation('ACYM_TIME');
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->help = 'plugin-time';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
public function textPopup()
|
||||
{
|
||||
$text = '<div class="acym__popup__listing text-center grid-x">
|
||||
<h1 class="acym__popup__plugin__title cell">'.acym_translation('ACYM_TIME_FORMAT').'</h1>';
|
||||
|
||||
$others = [];
|
||||
$others['{date:1}'] = 'ACYM_DATE_FORMAT_LC1';
|
||||
$others['{date:2}'] = 'ACYM_DATE_FORMAT_LC2';
|
||||
$others['{date:3}'] = 'ACYM_DATE_FORMAT_LC3';
|
||||
$others['{date:4}'] = 'ACYM_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 .= '<div class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" onclick="setTag(\''.$tagname.'\', jQuery(this));" >
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$tag.'</div>
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_getDate(time(), acym_translation($tag)).'</div>
|
||||
</div>';
|
||||
$k = 1 - $k;
|
||||
}
|
||||
|
||||
$text .= '</div>';
|
||||
|
||||
echo $text;
|
||||
}
|
||||
|
||||
public function replaceContent(&$email, $send = true)
|
||||
{
|
||||
$extractedTags = $this->acympluginHelper->extractTags($email, 'date');
|
||||
if (empty($extractedTags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tags = [];
|
||||
foreach ($extractedTags as $i => $oneTag) {
|
||||
if (isset($tags[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
if (!empty($oneTag->senddate) && !empty($email->sending_date)) {
|
||||
$time = $email->sending_date;
|
||||
}
|
||||
if (!empty($oneTag->add)) {
|
||||
$time += intval($oneTag->add);
|
||||
}
|
||||
if (!empty($oneTag->remove)) {
|
||||
$time -= intval($oneTag->remove);
|
||||
}
|
||||
|
||||
if (empty($oneTag->id) || is_numeric($oneTag->id)) {
|
||||
$oneTag->id = acym_translation('ACYM_DATE_FORMAT_LC'.$oneTag->id);
|
||||
}
|
||||
|
||||
$tags[$i] = acym_getDate($time, $oneTag->id);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
public function onAcymDeclareTriggers(&$triggers, &$defaultValues)
|
||||
{
|
||||
$triggers['classic']['asap'] = new stdClass();
|
||||
$triggers['classic']['asap']->name = acym_translation('ACYM_EACH_TIME');
|
||||
$triggers['classic']['asap']->option = '<input type="hidden" name="[triggers][classic][asap]" value="y">';
|
||||
|
||||
$hour = [];
|
||||
$minutes = [];
|
||||
$i = 0;
|
||||
while ($i <= 59) {
|
||||
if ($i <= 23) {
|
||||
$hour[$i] = $i < 10 ? '0'.$i : $i;
|
||||
}
|
||||
$minutes[$i] = $i < 10 ? '0'.$i : $i;
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$triggers['classic']['day'] = new stdClass();
|
||||
$triggers['classic']['day']->name = acym_translation('ACYM_EVERY_DAY_AT');
|
||||
$triggers['classic']['day']->option = '<div class="grid-x grid-margin-x" style="height: 40px;">';
|
||||
$triggers['classic']['day']->option .= '<div class="cell medium-shrink">'.acym_select($hour, '[triggers][classic][day][hour]', empty($defaultValues['day']) ? date('H') : $defaultValues['day']['hour'], 'data-class="intext_select acym__select"').'</div>';
|
||||
$triggers['classic']['day']->option .= '<div class="cell medium-shrink acym_vcenter">:</div>';
|
||||
$triggers['classic']['day']->option .= '<div class="cell medium-auto">'.acym_select($minutes, '[triggers][classic][day][minutes]', empty($defaultValues['day']) ? date('i') : $defaultValues['day']['minutes'], 'data-class="intext_select acym__select"').'</div>';
|
||||
$triggers['classic']['day']->option .= '</div>';
|
||||
|
||||
$days = [
|
||||
'monday' => acym_translation('ACYM_MONDAY'),
|
||||
'tuesday' => acym_translation('ACYM_TUESDAY'),
|
||||
'wednesday' => acym_translation('ACYM_WEDNESDAY'),
|
||||
'thursday' => acym_translation('ACYM_THURSDAY'),
|
||||
'friday' => acym_translation('ACYM_FRIDAY'),
|
||||
'saturday' => acym_translation('ACYM_SATURDAY'),
|
||||
'sunday' => acym_translation('ACYM_SUNDAY'),
|
||||
];
|
||||
|
||||
$triggers['classic']['weeks_on'] = new stdClass();
|
||||
$triggers['classic']['weeks_on']->name = acym_translation('ACYM_EVERY_WEEK_ON');
|
||||
$triggers['classic']['weeks_on']->option = acym_selectMultiple($days, '[triggers][classic][weeks_on][day]', empty($defaultValues['weeks_on']) ? ['monday'] : $defaultValues['weeks_on']['day'], ['data-class' => 'acym__select']);
|
||||
|
||||
$triggers['classic']['on_day_month'] = new stdClass();
|
||||
$triggers['classic']['on_day_month']->name = acym_translation('ACYM_ONTHE');
|
||||
$triggers['classic']['on_day_month']->option = '<div class="grid-x grid-margin-x" style="height: 40px;">';
|
||||
$triggers['classic']['on_day_month']->option .= '<div class="cell medium-4">'.acym_select(['first' => acym_translation('ACYM_FIRST'), 'second' => acym_translation('ACYM_SECOND'), 'third' => acym_translation('ACYM_THIRD'), 'last' => acym_translation('ACYM_LAST')], '[triggers][classic][on_day_month][number]', empty($defaultValues['on_day_month']) ? null : $defaultValues['on_day_month']['number'], 'data-class="acym__select"').'</div>';
|
||||
$triggers['classic']['on_day_month']->option .= '<div class="cell medium-4">'.acym_select($days, '[triggers][classic][on_day_month][day]', empty($defaultValues['on_day_month']) ? null : $defaultValues['on_day_month']['day'], 'data-class="acym__select" style="margin: 0 10px;"').'</div>';
|
||||
$triggers['classic']['on_day_month']->option .= '<div class="cell medium-4 acym_vcenter">'.acym_translation('ACYM_DAYOFMONTH').'</div>';
|
||||
$triggers['classic']['on_day_month']->option .= '</div>';
|
||||
|
||||
$every = [
|
||||
'3600' => acym_translation('ACYM_HOURS'),
|
||||
'86400' => acym_translation('ACYM_DAYS'),
|
||||
'604800' => acym_translation('ACYM_WEEKS'),
|
||||
'2628000' => acym_translation('ACYM_MONTHS'),
|
||||
];
|
||||
|
||||
$triggers['classic']['every'] = new stdClass();
|
||||
$triggers['classic']['every']->name = acym_translation('ACYM_EVERY');
|
||||
$triggers['classic']['every']->option = '<div class="grid-x grid-margin-x">';
|
||||
$triggers['classic']['every']->option .= '<div class="cell medium-shrink"><input type="number" name="[triggers][classic][every][number]" class="intext_input" value="'.(empty($defaultValues['every']) ? '1' : $defaultValues['every']['number']).'"></div>';
|
||||
$triggers['classic']['every']->option .= '<div class="cell medium-auto">'.acym_select($every, '[triggers][classic][every][type]', empty($defaultValues['every']) ? '604800' : $defaultValues['every']['type'], 'data-class="intext_select acym__select"').'</div>';
|
||||
$triggers['classic']['every']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymExecuteTrigger(&$step, &$execute, $data)
|
||||
{
|
||||
$time = $data['time'];
|
||||
$triggers = json_decode($step->triggers, true);
|
||||
|
||||
$nextExecutionDate = [];
|
||||
|
||||
$config = acym_config();
|
||||
$dailyHour = $config->get('daily_hour', '12');
|
||||
$dailyMinute = $config->get('daily_minute', '00');
|
||||
|
||||
|
||||
if (!empty($triggers['asap'])) {
|
||||
$execute = true;
|
||||
$nextExecutionDate[] = $time;
|
||||
}
|
||||
|
||||
if (!empty($triggers['day'])) {
|
||||
$todaysDate = strtotime('today '.$triggers['day']['hour'].':'.$triggers['day']['minutes']);
|
||||
if ($time < $todaysDate) {
|
||||
$nextExecutionDate[] = $todaysDate;
|
||||
} else {
|
||||
$nextExecutionDate[] = strtotime('tomorrow '.$triggers['day']['hour'].':'.$triggers['day']['minutes']);
|
||||
|
||||
if (empty($step->last_execution)) $execute = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($triggers['weeks_on'])) {
|
||||
foreach ($triggers['weeks_on']['day'] as $day) {
|
||||
if ($day == strtolower(date('l'))) {
|
||||
$todaysDate = strtotime('today '.$dailyHour.':'.$dailyMinute);
|
||||
if ($time < $todaysDate) {
|
||||
$nextExecutionDate[] = $todaysDate;
|
||||
} elseif (empty($step->last_execution)) {
|
||||
$execute = true;
|
||||
}
|
||||
} else {
|
||||
$nextExecutionDate[] = strtotime('next '.$day.' '.$dailyHour.':'.$dailyMinute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($triggers['on_day_month'])) {
|
||||
$today = strtotime('today '.$dailyHour.':'.$dailyMinute);
|
||||
|
||||
$execution = strtotime($triggers['on_day_month']['number'].' '.$triggers['on_day_month']['day'].' of this month '.$dailyHour.':'.$dailyMinute);
|
||||
|
||||
if ($execution < $today) {
|
||||
$execution = strtotime($triggers['on_day_month']['number'].' '.$triggers['on_day_month']['day'].' of next month '.$dailyHour.':'.$dailyMinute);
|
||||
}
|
||||
|
||||
if ($execution > $time) {
|
||||
$nextExecutionDate[] = $execution;
|
||||
} else {
|
||||
|
||||
|
||||
if (empty($step->last_execution)) {
|
||||
$execute = true;
|
||||
}
|
||||
|
||||
$nextExecutionDate[] = $execution + 2628000;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($triggers['every'])) {
|
||||
if (empty($step->last_execution)) {
|
||||
$execute = true;
|
||||
} else {
|
||||
$nextDate = $step->last_execution + ($triggers['every']['number'] * $triggers['every']['type']);
|
||||
|
||||
if ($nextDate > $time) {
|
||||
$nextExecutionDate[] = $nextDate;
|
||||
} else {
|
||||
$execute = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($execute) {
|
||||
$nextExecutionDate[] = $time + ($triggers['every']['number'] * $triggers['every']['type']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($nextExecutionDate)) {
|
||||
$step->next_execution = min($nextExecutionDate);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_triggers(&$automation)
|
||||
{
|
||||
if (!empty($automation->triggers['type_trigger'])) unset($automation->triggers['type_trigger']);
|
||||
if (!empty($automation->triggers['asap'])) $automation->triggers['asap'] = acym_translation('ACYM_EACH_TIME');
|
||||
if (!empty($automation->triggers['day'])) $automation->triggers['day'] = acym_translation_sprintf('ACYM_TRIGGER_DAY_SUMMARY', $automation->triggers['day']['hour'], $automation->triggers['day']['minutes']);
|
||||
if (!empty($automation->triggers['weeks_on'])) $automation->triggers['weeks_on'] = acym_translation_sprintf('ACYM_TRIGGER_WEEKS_ON_SUMMARY', implode(', ', $automation->triggers['weeks_on']['day']));
|
||||
if (!empty($automation->triggers['on_day_month'])) $automation->triggers['on_day_month'] = acym_translation_sprintf('ACYM_TRIGGER_ON_DAY_MONTH_SUMMARY', $automation->triggers['on_day_month']['number'], $automation->triggers['on_day_month']['day']);
|
||||
if (!empty($automation->triggers['every'])) {
|
||||
if ($automation->triggers['every']['type'] == 3600) $automation->triggers['every']['type'] = acym_translation('ACYM_HOURS');
|
||||
if ($automation->triggers['every']['type'] == 86400) $automation->triggers['every']['type'] = acym_translation('ACYM_DAYS');
|
||||
if ($automation->triggers['every']['type'] == 604800) $automation->triggers['every']['type'] = acym_translation('ACYM_WEEKS');
|
||||
if ($automation->triggers['every']['type'] == 2628000) $automation->triggers['every']['type'] = acym_translation('ACYM_MONTHS');
|
||||
$automation->triggers['every'] = acym_translation_sprintf('ACYM_TRIGGER_EVERY_SUMMARY', $automation->triggers['every']['number'], $automation->triggers['every']['type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,612 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymUser extends acymPlugin
|
||||
{
|
||||
var $sendervalues = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
global $acymCmsUserVars;
|
||||
$this->cmsUserVars = $acymCmsUserVars;
|
||||
}
|
||||
|
||||
public function dynamicText()
|
||||
{
|
||||
$onePlugin = new stdClass();
|
||||
$onePlugin->name = acym_translation_sprintf('ACYM_CMS_USER', 'Joomla');
|
||||
$onePlugin->plugin = __CLASS__;
|
||||
$onePlugin->help = 'plugin-taguser';
|
||||
|
||||
return $onePlugin;
|
||||
}
|
||||
|
||||
public function textPopup()
|
||||
{
|
||||
?>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
var selectedTag;
|
||||
|
||||
function changeUserTag(tagname) {
|
||||
if (!tagname) return;
|
||||
|
||||
selectedTag = tagname;
|
||||
|
||||
var string;
|
||||
var iscf = tagname.toLowerCase().indexOf('custom');
|
||||
|
||||
if (iscf >= 0) string = '{usertag:' + tagname.substr(0, iscf) + '|type:custom'; else string = '{usertag:' + tagname;
|
||||
|
||||
if (tagname.toLowerCase().indexOf('date') >= 0) string += '|type:date';
|
||||
string += '|info:' + jQuery('input[name="typeinfo"]:checked').val() + '}';
|
||||
|
||||
setTag(string, jQuery('#' + tagname + 'option'));
|
||||
}
|
||||
|
||||
-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$isAutomation = acym_getVar('string', 'automation');
|
||||
$text = '<div class="acym__popup__listing text-center grid-x">';
|
||||
|
||||
$typeinfo = [];
|
||||
$typeinfo[] = acym_selectOption('receiver', 'ACYM_RECEIVER_INFORMATION');
|
||||
$typeinfo[] = acym_selectOption('sender', 'ACYM_SENDER_INFORMATION');
|
||||
if (!empty($isAutomation)) $typeinfo[] = acym_selectOption('current', 'ACYM_USER_TRIGGERING_AUTOMATION');
|
||||
|
||||
$text .= acym_radio($typeinfo, 'typeinfo', 'receiver', null, ['onclick' => 'changeUserTag(selectedTag)']);
|
||||
|
||||
$fields = [
|
||||
$this->cmsUserVars->username => 'ACYM_LOGIN_NAME',
|
||||
$this->cmsUserVars->name => 'ACYM_USER_NAME',
|
||||
$this->cmsUserVars->registered => 'ACYM_REGISTRATION_DATE',
|
||||
'groups' => 'ACYM_USER_GROUPS',
|
||||
];
|
||||
|
||||
foreach ($fields as $fieldname => $description) {
|
||||
$text .= '<div class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" id="'.$fieldname.'option" onclick="changeUserTag(\''.$fieldname.'\');" >
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$fieldname.'</div>
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_translation($description).'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (ACYM_CMS == 'joomla' && ACYM_J37) {
|
||||
$groups = acym_loadObjectList('SELECT id, title FROM #__fields_groups WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC');
|
||||
$defaultGroup = new stdClass();
|
||||
$defaultGroup->id = 0;
|
||||
$defaultGroup->title = acym_translation('ACYM_NO_GROUP');
|
||||
array_unshift($groups, $defaultGroup);
|
||||
|
||||
$customFields = acym_loadObjectList('SELECT id, title, group_id FROM #__fields WHERE context = "com_users.user" AND state = 1 ORDER BY title ASC');
|
||||
if (!empty($customFields)) {
|
||||
$text .= '<h1 class="acym__popup__plugin__title cell" style="margin-top: 20px;">'.acym_translation('ACYM_CUSTOM_FIELDS').'</h1>';
|
||||
|
||||
foreach ($groups as $oneGroup) {
|
||||
foreach ($customFields as $oneCF) {
|
||||
if ($oneCF->group_id != $oneGroup->id) {
|
||||
continue;
|
||||
}
|
||||
$text .= '<div class="grid-x medium-12 cell acym__listing__row acym__listing__row__popup text-left" id="'.$oneCF->id.'customoption" onclick="changeUserTag(\''.$oneCF->id.'custom\');" >
|
||||
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.$oneCF->title.'</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
$text .= '</table></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$text .= '</div>';
|
||||
echo $text;
|
||||
}
|
||||
|
||||
public function replaceUserInformation(&$email, &$user, $send = true)
|
||||
{
|
||||
$extractedTags = $this->acympluginHelper->extractTags($email, 'usertag');
|
||||
if (empty($extractedTags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->customFields) && ACYM_CMS == 'joomla' && ACYM_J37) {
|
||||
$this->customFields = acym_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 = [];
|
||||
$receivervalues = [];
|
||||
foreach ($extractedTags as $i => $mytag) {
|
||||
if (isset($tags[$i])) {
|
||||
continue;
|
||||
}
|
||||
$mytag->default = '';
|
||||
|
||||
$values = new stdClass();
|
||||
$idused = 0;
|
||||
$save = false;
|
||||
|
||||
if (!empty($mytag->info) && $mytag->info == 'sender' && !empty($email->creator_id)) {
|
||||
$idused = $email->creator_id;
|
||||
$save = true;
|
||||
}
|
||||
|
||||
if (!empty($mytag->info) && $mytag->info == 'current') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((empty($mytag->info) || $mytag->info == 'receiver') && !empty($user->cms_id)) {
|
||||
$idused = $user->cms_id;
|
||||
}
|
||||
|
||||
if (!empty($idused) && empty($this->sendervalues[$idused]) && empty($receivervalues[$idused])) {
|
||||
$receivervalues[$idused] = acym_loadObject('SELECT * FROM '.$this->cmsUserVars->table.' WHERE '.$this->cmsUserVars->id.' = '.intval($idused).' LIMIT 1');
|
||||
|
||||
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 == 'groups') {
|
||||
$groups = acym_getGroupsByUser($idused, true, true);
|
||||
$values->groups = implode(', ', $groups);
|
||||
}
|
||||
|
||||
if (empty($mytag->type)) {
|
||||
$mytag->type = '';
|
||||
}
|
||||
|
||||
if ($mytag->type == 'custom' && ACYM_CMS == 'joomla') {
|
||||
$mytag->id = intval($mytag->id);
|
||||
if (empty($mytag->id)) {
|
||||
$replaceme = '';
|
||||
} else {
|
||||
$userFieldVals = acym_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 = acym_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 = [$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 = acym_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 = acym_loadObjectList($this->customFields[$mytag->id]->fieldparams['query'], 'value');
|
||||
}
|
||||
|
||||
$oneFieldVal = $this->customFields[$mytag->id]->options[$oneFieldVal]->text;
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$oneFieldVal = acym_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 = acym_date(strtotime($oneFieldVal), $format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$replaceme = implode(', ', $userFieldVals);
|
||||
}
|
||||
} else {
|
||||
$replaceme = isset($values->{$mytag->id}) ? $values->{$mytag->id} : $mytag->default;
|
||||
}
|
||||
|
||||
$tags[$i] = $replaceme;
|
||||
$this->acympluginHelper->formatString($tags[$i], $mytag);
|
||||
}
|
||||
|
||||
$this->acympluginHelper->replaceTags($email, $tags);
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
|
||||
$allGroups = acym_getGroups();
|
||||
$groups = [];
|
||||
foreach ($allGroups as $group) {
|
||||
$groups[$group->id] = $group->text;
|
||||
}
|
||||
$operatorIn = acym_get('type.operatorin');
|
||||
|
||||
$conditions['user']['acy_group'] = new stdClass();
|
||||
$conditions['user']['acy_group']->name = acym_translation('ACYM_GROUP');
|
||||
$conditions['user']['acy_group']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_group']->option .= $operatorIn->display('acym_condition[conditions][__numor__][__numand__][acy_group][in]');
|
||||
$conditions['user']['acy_group']->option .= '</div>';
|
||||
$conditions['user']['acy_group']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_group']->option .= acym_select($groups, 'acym_condition[conditions][__numor__][__numand__][acy_group][group]', null, 'class="acym__select"');
|
||||
$conditions['user']['acy_group']->option .= '</div>';
|
||||
|
||||
if (ACYM_CMS == 'joomla') {
|
||||
$conditions['user']['acy_group']->option .= '<div class="cell grid-x medium-3">';
|
||||
$conditions['user']['acy_group']->option .= acym_switch('acym_condition[conditions][__numor__][__numand__][acy_group][subgroup]', 1, acym_translation('ACYM_INCLUDE_SUB_GROUPS'));
|
||||
$conditions['user']['acy_group']->option .= '</div>';
|
||||
}
|
||||
|
||||
|
||||
$cmsFields = [];
|
||||
foreach (acym_getColumns('users', false) as $key => $column) {
|
||||
$cmsFields[$column] = $column;
|
||||
}
|
||||
|
||||
if (ACYM_CMS == 'joomla' && ACYM_J37) {
|
||||
$query = 'SELECT id, title
|
||||
FROM #__fields
|
||||
WHERE context = "com_users.user"
|
||||
AND state = 1
|
||||
AND type IN ("calendar", "checkboxes", "color", "integer", "list", "radio", "sql", "text", "url")
|
||||
ORDER BY title ASC';
|
||||
$customFields = acym_loadObjectList($query);
|
||||
foreach ($customFields as $oneCF) {
|
||||
$cmsFields['cf_'.$oneCF->id] = $oneCF->title;
|
||||
}
|
||||
}
|
||||
$excluded = ['password', 'params', 'activation', 'lastResetTime', 'resetCount', 'optKey', 'otep', 'requireReset', 'user_pass', 'user_activation_key'];
|
||||
foreach ($excluded as $oneExcluded) {
|
||||
unset($cmsFields[$oneExcluded]);
|
||||
}
|
||||
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$conditions['user']['acy_cmsfield'] = new stdClass();
|
||||
$conditions['user']['acy_cmsfield']->name = acym_translation('ACYM_ACCOUNT_USER_FIELD');
|
||||
$conditions['user']['acy_cmsfield']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_cmsfield']->option .= acym_select($cmsFields, 'acym_condition[conditions][__numor__][__numand__][acy_cmsfield][field]', null, 'class="acym__select"');
|
||||
$conditions['user']['acy_cmsfield']->option .= '</div>';
|
||||
$conditions['user']['acy_cmsfield']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['acy_cmsfield']->option .= $operator->display('acym_condition[conditions][__numor__][__numand__][acy_cmsfield][operator]');
|
||||
$conditions['user']['acy_cmsfield']->option .= '</div>';
|
||||
$conditions['user']['acy_cmsfield']->option .= '<input class="intext_input_automation cell" type="text" name="acym_condition[conditions][__numor__][__numand__][acy_cmsfield][value]">';
|
||||
|
||||
$conditions['classic']['acy_totaluser'] = new stdClass();
|
||||
$conditions['classic']['acy_totaluser']->name = acym_translation('ACYM_NUMBER_OF_USERS');
|
||||
$conditions['classic']['acy_totaluser']->option = '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_THERE_IS').'</div>';
|
||||
$conditions['classic']['acy_totaluser']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['classic']['acy_totaluser']->option .= acym_select(['=' => acym_translation('ACYM_EXACTLY'), '>' => acym_translation('ACYM_MORE_THAN'), '<' => acym_translation('ACYM_LESS_THAN')], 'acym_condition[conditions][__numor__][__numand__][acy_totaluser][operator]', null, 'class="intext_select_automation acym__select"');
|
||||
$conditions['classic']['acy_totaluser']->option .= '</div>';
|
||||
$conditions['classic']['acy_totaluser']->option .= '<input type="number" min="0" class="intext_input_automation cell" name="acym_condition[conditions][__numor__][__numand__][acy_totaluser][number]">';
|
||||
$conditions['classic']['acy_totaluser']->option .= '<div class="cell shrink acym__automation__inner__text">'.acym_translation('ACYM_ACYMAILING_USERS').'</div>';
|
||||
|
||||
$conditions['both']['acy_toss'] = new stdClass();
|
||||
$conditions['both']['acy_toss']->name = acym_translation('ACYM_TOSS');
|
||||
$conditions['both']['acy_toss']->option = '<input type="hidden" name="acym_condition[conditions][__numor__][__numand__][acy_toss][toss]" value="true"><div class="acym__automation__inner__text">'.acym_translation('ACYM_TOSS_DESC').'</div>';
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$allGroups = acym_getGroups();
|
||||
$groups = [];
|
||||
foreach ($allGroups as $group) {
|
||||
$groups[$group->id] = $group->text;
|
||||
}
|
||||
$operatorIn = acym_get('type.operatorin');
|
||||
|
||||
$filters['acy_group'] = new stdClass();
|
||||
$filters['acy_group']->name = acym_translation('ACYM_GROUP');
|
||||
$filters['acy_group']->option = '<div class="intext_select_automation cell">';
|
||||
$filters['acy_group']->option .= $operatorIn->display('acym_action[filters][__numor__][__numand__][acy_group][in]');
|
||||
$filters['acy_group']->option .= '</div>';
|
||||
$filters['acy_group']->option .= '<div class="intext_select_automation cell">';
|
||||
$filters['acy_group']->option .= acym_select($groups, 'acym_action[filters][__numor__][__numand__][acy_group][group]', null, 'class="acym__select"');
|
||||
$filters['acy_group']->option .= '</div>';
|
||||
|
||||
if (ACYM_CMS == 'joomla') {
|
||||
$filters['acy_group']->option .= '<div class="cell grid-x medium-3">';
|
||||
$filters['acy_group']->option .= acym_switch('acym_action[filters][__numor__][__numand__][acy_group][subgroup]', 1, acym_translation('ACYM_INCLUDE_SUB_GROUPS'));
|
||||
$filters['acy_group']->option .= '</div>';
|
||||
}
|
||||
|
||||
|
||||
$cmsFields = [];
|
||||
foreach (acym_getColumns('users', false) as $key => $column) {
|
||||
$cmsFields[$column] = $column;
|
||||
}
|
||||
|
||||
if (ACYM_CMS == 'joomla' && ACYM_J37) {
|
||||
$query = 'SELECT id, title
|
||||
FROM #__fields
|
||||
WHERE context = "com_users.user"
|
||||
AND state = 1
|
||||
AND type IN ("calendar", "checkboxes", "color", "integer", "list", "radio", "sql", "text", "url")
|
||||
ORDER BY title ASC';
|
||||
$customFields = acym_loadObjectList($query);
|
||||
foreach ($customFields as $oneCF) {
|
||||
$cmsFields['cf_'.$oneCF->id] = $oneCF->title;
|
||||
}
|
||||
}
|
||||
$excluded = ['password', 'params', 'activation', 'lastResetTime', 'resetCount', 'optKey', 'otep', 'requireReset', 'user_pass', 'user_activation_key'];
|
||||
foreach ($excluded as $oneExcluded) {
|
||||
unset($cmsFields[$oneExcluded]);
|
||||
}
|
||||
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$filters['acy_cmsfield'] = new stdClass();
|
||||
$filters['acy_cmsfield']->name = acym_translation('ACYM_ACCOUNT_USER_FIELD');
|
||||
$filters['acy_cmsfield']->option = '<div class="intext_select_automation cell">';
|
||||
$filters['acy_cmsfield']->option .= acym_select($cmsFields, 'acym_action[filters][__numor__][__numand__][acy_cmsfield][field]', null, 'class="acym__select"');
|
||||
$filters['acy_cmsfield']->option .= '</div>';
|
||||
$filters['acy_cmsfield']->option .= '<div class="intext_select_automation cell">';
|
||||
$filters['acy_cmsfield']->option .= $operator->display('acym_action[filters][__numor__][__numand__][acy_cmsfield][operator]');
|
||||
$filters['acy_cmsfield']->option .= '</div>';
|
||||
$filters['acy_cmsfield']->option .= '<input class="intext_input_automation cell" type="text" name="acym_action[filters][__numor__][__numand__][acy_cmsfield][value]">';
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_toss(&$query, $option, $num, &$conditionNotValid)
|
||||
{
|
||||
if (!mt_rand(0, 1)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_totaluser(&$query, $option, $num, &$conditionNotValid)
|
||||
{
|
||||
$numberUsers = $query->count();
|
||||
$res = false;
|
||||
|
||||
switch ($option['operator']) {
|
||||
case '=' :
|
||||
$res = $numberUsers == $option['number'];
|
||||
break;
|
||||
case '>' :
|
||||
$res = $numberUsers > $option['number'];
|
||||
break;
|
||||
case '<' :
|
||||
$res = $numberUsers < $option['number'];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$res) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_group(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
if (ACYM_CMS == 'joomla') {
|
||||
$operator = (empty($options['in']) || $options['in'] == 'in') ? 'IS NOT NULL AND cmsuser'.$num.'.user_id != 0' : "IS NULL";
|
||||
|
||||
if (empty($options['subgroup'])) {
|
||||
$value = ' = '.intval($options['group']);
|
||||
} else {
|
||||
$lftrgt = acym_loadObject('SELECT lft, rgt FROM #__usergroups WHERE id = '.intval($options['group']));
|
||||
$allGroups = acym_loadResultArray('SELECT id FROM #__usergroups WHERE lft > '.intval($lftrgt->lft).' AND rgt < '.intval($lftrgt->rgt));
|
||||
array_unshift($allGroups, $options['group']);
|
||||
$value = ' IN ('.implode(', ', $allGroups).')';
|
||||
}
|
||||
|
||||
$query->leftjoin['cmsuser'.$num] = "#__user_usergroup_map AS cmsuser$num ON cmsuser$num.user_id = user.cms_id AND cmsuser$num.group_id".$value;
|
||||
$query->where[] = "cmsuser$num.user_id ".$operator;
|
||||
} else {
|
||||
$operator = (empty($options['in']) || $options['in'] == 'in') ? 'IS NOT NULL AND cmsuser'.$num.'.user_id != 0' : "IS NULL";
|
||||
|
||||
$query->leftjoin['cmsuser'.$num] = '#__usermeta AS cmsuser'.$num.' ON cmsuser'.$num.'.user_id = user.cms_id AND cmsuser'.$num.'.meta_key = "#__capabilities" AND cmsuser'.$num.'.meta_value LIKE '.acym_escapeDB('%'.strlen($options['group']).':"'.$options['group'].'"%');
|
||||
$query->where[] = "cmsuser$num.user_id ".$operator;
|
||||
}
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_acy_group(&$query, $options, $num)
|
||||
{
|
||||
if (ACYM_CMS == 'joomla') {
|
||||
$operator = (empty($options['in']) || $options['in'] == 'in') ? 'IS NOT NULL AND cmsuser'.$num.'.user_id != 0' : "IS NULL";
|
||||
|
||||
if (empty($options['subgroup'])) {
|
||||
$value = ' = '.intval($options['group']);
|
||||
} else {
|
||||
$lftrgt = acym_loadObject('SELECT lft, rgt FROM #__usergroups WHERE id = '.intval($options['group']));
|
||||
$allGroups = acym_loadResultArray('SELECT id FROM #__usergroups WHERE lft > '.intval($lftrgt->lft).' AND rgt < '.intval($lftrgt->rgt));
|
||||
array_unshift($allGroups, $options['group']);
|
||||
$value = ' IN ('.implode(', ', $allGroups).')';
|
||||
}
|
||||
|
||||
$query->leftjoin['cmsuser'.$num] = "#__user_usergroup_map AS cmsuser$num ON cmsuser$num.user_id = user.cms_id AND cmsuser$num.group_id".$value;
|
||||
$query->where[] = "cmsuser$num.user_id ".$operator;
|
||||
} else {
|
||||
$operator = (empty($options['in']) || $options['in'] == 'in') ? 'IS NOT NULL AND cmsuser'.$num.'.user_id != 0' : "IS NULL";
|
||||
|
||||
$query->leftjoin['cmsuser'.$num] = '#__usermeta AS cmsuser'.$num.' ON cmsuser'.$num.'.user_id = user.cms_id AND cmsuser'.$num.'.meta_key = "#__capabilities" AND cmsuser'.$num.'.meta_value LIKE '.acym_escapeDB('%'.strlen($options['group']).':"'.$options['group'].'"%');
|
||||
$query->where[] = "cmsuser$num.user_id ".$operator;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_acy_group(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_acy_group($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_acy_cmsfield(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
if (empty($options['field'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($options['field'], 'cf_') !== false) {
|
||||
$query->leftjoin['cmsuserfields'.$num] = '#__fields_values AS cmsuserfields'.$num.' ON cmsuserfields'.$num.'.item_id = user.cms_id AND cmsuserfields'.$num.'.field_id = '.intval($options['field']);
|
||||
$query->where[] = $query->convertQuery('cmsuserfields'.$num, 'value', $options['operator'], $options['value'], '');
|
||||
} else {
|
||||
$type = '';
|
||||
$query->leftjoin['cmsuser'.$num] = '#__users AS cmsuser'.$num.' ON cmsuser'.$num.'.id = user.cms_id';
|
||||
|
||||
if (in_array($options['field'], ['registerDate', 'lastvisitDate', 'user_registered'])) {
|
||||
$type = 'datetime';
|
||||
$options['value'] = acym_replaceDate($options['value']);
|
||||
|
||||
if (!is_numeric($options['value']) && strtotime($options['value']) !== false) {
|
||||
$options['value'] = strtotime($options['value']);
|
||||
}
|
||||
if (is_numeric($options['value'])) {
|
||||
$options['value'] = strftime('%Y-%m-%d %H:%M:%S', $options['value']);
|
||||
}
|
||||
}
|
||||
|
||||
$query->where[] = $query->convertQuery('cmsuser'.$num, $options['field'], $options['operator'], $options['value'], $type);
|
||||
}
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
public function onAcymProcessFilter_acy_cmsfield(&$query, $options, $num)
|
||||
{
|
||||
if (empty($options['field'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($options['field'], 'cf_') !== false) {
|
||||
$query->leftjoin['cmsuserfields'.$num] = '#__fields_values AS cmsuserfields'.$num.' ON cmsuserfields'.$num.'.item_id = user.cms_id AND cmsuserfields'.$num.'.field_id = '.intval($options['field']);
|
||||
$query->where[] = $query->convertQuery('cmsuserfields'.$num, 'value', $options['operator'], $options['value'], '');
|
||||
} else {
|
||||
$type = '';
|
||||
$query->leftjoin['cmsuser'.$num] = '#__users AS cmsuser'.$num.' ON cmsuser'.$num.'.id = user.cms_id';
|
||||
|
||||
if (in_array($options['field'], ['registerDate', 'lastvisitDate', 'user_registered'])) {
|
||||
$type = 'datetime';
|
||||
$options['value'] = acym_replaceDate($options['value']);
|
||||
|
||||
if (!is_numeric($options['value']) && strtotime($options['value']) !== false) {
|
||||
$options['value'] = strtotime($options['value']);
|
||||
}
|
||||
if (is_numeric($options['value'])) {
|
||||
$options['value'] = strftime('%Y-%m-%d %H:%M:%S', $options['value']);
|
||||
}
|
||||
}
|
||||
|
||||
$query->where[] = $query->convertQuery('cmsuser'.$num, $options['field'], $options['operator'], $options['value'], $type);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_acy_cmsfield(&$query, $options, $num)
|
||||
{
|
||||
$this->onAcymProcessFilter_acy_cmsfield($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['acy_group'])) {
|
||||
if ('joomla' === ACYM_CMS) {
|
||||
$allGroups = acym_getGroups();
|
||||
$groups = [];
|
||||
foreach ($allGroups as $group) {
|
||||
if ($automationCondition['acy_group']['group'] == $group->id) $automationCondition['acy_group']['group'] = $group->text;
|
||||
$groups[$group->id] = $group->text;
|
||||
}
|
||||
} else {
|
||||
$groupKey = 'ACYM_'.strtoupper($automationCondition['acy_group']['group']);
|
||||
if (acym_translationExists($groupKey)) {
|
||||
$automationCondition['acy_group']['group'] = $groupKey;
|
||||
}
|
||||
}
|
||||
$finalText = acym_translation_sprintf('ACYM_CONDITION_ACY_GROUP_SUMMARY', acym_translation($automationCondition['acy_group']['in'] == 'in' ? 'ACYM_IS_IN' : 'ACYM_IS_NOT_IN'), acym_translation($automationCondition['acy_group']['group']));
|
||||
if ('joomla' === ACYM_CMS) {
|
||||
$finalText .= $automationCondition['acy_group']['subgroup'] == 1 ? '' : ' '.acym_translation('ACYM_FILTER_ACY_GROUP_SUBGROUP_SUMMARY');
|
||||
}
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
if (!empty($automationCondition['acy_cmsfield'])) {
|
||||
$automationCondition = acym_translation_sprintf('ACYM_CONDITION_ACY_CMS_FIELD_SUMMARY', $automationCondition['acy_cmsfield']['field'], $automationCondition['acy_cmsfield']['operator'], $automationCondition['acy_cmsfield']['value']);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['acy_totaluser'])) {
|
||||
$operators = ['=' => acym_translation('ACYM_EXACTLY'), '>' => acym_translation('ACYM_MORE_THAN'), '<' => acym_translation('ACYM_LESS_THAN')];
|
||||
$automationCondition = acym_translation('ACYM_THERE_IS').' '.strtolower($operators[$automationCondition['acy_totaluser']['operator']]).' '.$automationCondition['acy_totaluser']['number'].' '.acym_translation('ACYM_ACYMAILING_USERS').' ';
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['acy_toss'])) {
|
||||
$automationCondition = acym_translation('ACYM_TOSS_DESC');
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
if (!empty($automationFilter['acy_group'])) {
|
||||
if ('joomla' === ACYM_CMS) {
|
||||
$allGroups = acym_getGroups();
|
||||
$groups = [];
|
||||
foreach ($allGroups as $group) {
|
||||
if ($automationFilter['acy_group']['group'] == $group->id) $automationFilter['acy_group']['group'] = $group->text;
|
||||
$groups[$group->id] = $group->text;
|
||||
}
|
||||
} else {
|
||||
$groupKey = 'ACYM_'.strtoupper($automationFilter['acy_group']['group']);
|
||||
if (acym_translationExists($groupKey)) {
|
||||
$automationFilter['acy_group']['group'] = $groupKey;
|
||||
}
|
||||
}
|
||||
$finalText = acym_translation_sprintf('ACYM_FILTER_ACY_GROUP_SUMMARY', acym_translation($automationFilter['acy_group']['in'] == 'in' ? 'ACYM_IN' : 'ACYM_NOT_IN'), acym_translation($automationFilter['acy_group']['group']));
|
||||
if ('joomla' === ACYM_CMS) {
|
||||
$finalText .= $automationFilter['acy_group']['subgroup'] == 1 ? '' : ' '.acym_translation('ACYM_FILTER_ACY_GROUP_SUBGROUP_SUMMARY');
|
||||
}
|
||||
$automationFilter = $finalText;
|
||||
}
|
||||
if (!empty($automationFilter['acy_cmsfield'])) {
|
||||
$automationFilter = acym_translation_sprintf('ACYM_FILTER_ACY_CMS_FIELD_SUMMARY', $automationFilter['acy_cmsfield']['field'], $automationFilter['acy_cmsfield']['operator'], $automationFilter['acy_cmsfield']['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,453 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 plgAcymVirtuemart extends acymPlugin
|
||||
{
|
||||
var $lang = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cms = 'Joomla';
|
||||
if (!defined('JPATH_ADMINISTRATOR') || !file_exists(rtrim(JPATH_ADMINISTRATOR, DS).DS.'components'.DS.'com_virtuemart'.DS)) {
|
||||
$this->installed = false;
|
||||
} else {
|
||||
$params = JComponentHelper::getParams('com_languages');
|
||||
$this->lang = strtolower(str_replace('-', '_', $params->get('site', 'en-GB')));
|
||||
}
|
||||
}
|
||||
|
||||
public function searchProduct()
|
||||
{
|
||||
$id = acym_getVar('int', 'id');
|
||||
if (!empty($id)) {
|
||||
$value = '';
|
||||
$element = acym_loadResult('SELECT `product_name` FROM #__virtuemart_products_'.$this->lang.' WHERE `virtuemart_product_id` = '.intval($id));
|
||||
if (!empty($element)) $value = $element;
|
||||
echo json_encode(['value' => $value]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$search = acym_getVar('cmd', 'search', '');
|
||||
|
||||
$products = acym_loadObjectList(
|
||||
'SELECT `virtuemart_product_id`, `product_name`
|
||||
FROM #__virtuemart_products_'.$this->lang.'
|
||||
WHERE `product_name` LIKE '.acym_escapeDB('%'.$search.'%').'
|
||||
ORDER BY `product_name` ASC'
|
||||
);
|
||||
foreach ($products as $oneProduct) {
|
||||
$return[] = [$oneProduct->virtuemart_product_id, $oneProduct->product_name];
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function searchCategory()
|
||||
{
|
||||
$id = acym_getVar('int', 'id');
|
||||
if (!empty($id)) {
|
||||
$value = '';
|
||||
$element = acym_loadResult('SELECT `category_name` FROM #__virtuemart_categories_'.$this->lang.' WHERE `virtuemart_category_id` = '.intval($id));
|
||||
if (!empty($element)) $value = $element;
|
||||
echo json_encode(['value' => $value]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$search = acym_getVar('cmd', 'search', '');
|
||||
$categories = acym_loadObjectList(
|
||||
'SELECT `virtuemart_category_id`, `category_name`
|
||||
FROM `#__virtuemart_categories_'.$this->lang.'`
|
||||
WHERE `category_name` LIKE '.acym_escapeDB('%'.$search.'%').'
|
||||
ORDER BY `category_name` ASC'
|
||||
);
|
||||
|
||||
foreach ($categories as $oneCategory) {
|
||||
$return[] = [$oneCategory->virtuemart_category_id, $oneCategory->category_name];
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function onAcymDeclareConditions(&$conditions)
|
||||
{
|
||||
acym_loadLanguageFile('com_virtuemart_orders', JPATH_SITE.'/components/com_virtuemart');
|
||||
acym_loadLanguageFile('com_virtuemart_shoppers', JPATH_SITE.'/components/com_virtuemart');
|
||||
|
||||
$groups = acym_loadObjectList(
|
||||
'SELECT `virtuemart_shoppergroup_id` AS `value`, `shopper_group_name` AS `text`
|
||||
FROM `#__virtuemart_shoppergroups`
|
||||
ORDER BY `ordering` ASC, `shopper_group_name` ASC'
|
||||
);
|
||||
|
||||
if (!empty($groups)) {
|
||||
foreach ($groups as $i => $oneGroup) {
|
||||
$groups[$i]->text = acym_translation($oneGroup->text);
|
||||
}
|
||||
|
||||
$operatorIn = acym_get('type.operatorin');
|
||||
|
||||
$conditions['user']['vmgroups'] = new stdClass();
|
||||
$conditions['user']['vmgroups']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'VirtueMart', acym_translation('ACYM_GROUP'));
|
||||
$conditions['user']['vmgroups']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['vmgroups']->option .= $operatorIn->display('acym_condition[conditions][__numor__][__numand__][vmgroups][type]');
|
||||
$conditions['user']['vmgroups']->option .= '</div>';
|
||||
$conditions['user']['vmgroups']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['vmgroups']->option .= acym_select($groups, 'acym_condition[conditions][__numor__][__numand__][vmgroups][group]', null, 'class="acym__select"');
|
||||
$conditions['user']['vmgroups']->option .= '</div>';
|
||||
}
|
||||
|
||||
$fields = acym_getColumns('virtuemart_userinfos', false);
|
||||
if (!empty($fields)) {
|
||||
$fields = array_combine($fields, $fields);
|
||||
ksort($fields);
|
||||
$operator = acym_get('type.operator');
|
||||
|
||||
$conditions['user']['vmfield'] = new stdClass();
|
||||
$conditions['user']['vmfield']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'VirtueMart', acym_translation('ACYM_FIELDS'));
|
||||
$conditions['user']['vmfield']->option = '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['vmfield']->option .= acym_select($fields, 'acym_condition[conditions][__numor__][__numand__][vmfield][field]', null, 'class="acym__select acym__automation__conditions__fields__dropdown"');
|
||||
$conditions['user']['vmfield']->option .= '</div>';
|
||||
$conditions['user']['vmfield']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['vmfield']->option .= $operator->display('acym_condition[conditions][__numor__][__numand__][vmfield][operator]', '', 'acym__automation__conditions__operator__dropdown');
|
||||
$conditions['user']['vmfield']->option .= '</div>';
|
||||
$conditions['user']['vmfield']->option .= '<input
|
||||
class="acym__automation__one-field intext_input_automation cell acym__automation__condition__regular-field"
|
||||
type="text"
|
||||
name="acym_condition[conditions][__numor__][__numand__][vmfield][value]">';
|
||||
}
|
||||
|
||||
$orderStatuses = ['' => acym_translation('ACYM_ANY_STATUS')];
|
||||
$statuses = acym_loadObjectList('SELECT `order_status_code` AS `code`, `order_status_name` AS `name` FROM `#__virtuemart_orderstates` ORDER BY `ordering` ASC');
|
||||
foreach ($statuses as $status) {
|
||||
$orderStatuses[$status->code] = acym_translation($status->name);
|
||||
}
|
||||
|
||||
$paymentMethods = ['' => acym_translation('ACYM_ANY_PAYMENT_METHOD')];
|
||||
$payments = acym_loadObjectList(
|
||||
'SELECT `method`.`virtuemart_paymentmethod_id` AS `id`, `translation`.`payment_name` AS `name`
|
||||
FROM `#__virtuemart_paymentmethods` AS `method`
|
||||
LEFT JOIN `#__virtuemart_paymentmethods_'.$this->lang.'` AS `translation` ON `method`.`virtuemart_paymentmethod_id` = `translation`.`virtuemart_paymentmethod_id`
|
||||
WHERE `published` = 1
|
||||
ORDER BY `ordering` ASC'
|
||||
);
|
||||
foreach ($payments as $oneMethod) {
|
||||
$paymentMethods[$oneMethod->id] = $oneMethod->name;
|
||||
}
|
||||
|
||||
$conditions['user']['vmreminder'] = new stdClass();
|
||||
$conditions['user']['vmreminder']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'VirtueMart', acym_translation('ACYM_REMINDER'));
|
||||
$conditions['user']['vmreminder']->option = '<div class="cell">';
|
||||
$conditions['user']['vmreminder']->option .= acym_translation_sprintf(
|
||||
'ACYM_ORDER_WITH_STATUS',
|
||||
'<input type="number" name="acym_condition[conditions][__numor__][__numand__][vmreminder][days]" value="1" min="1" class="intext_input"/>',
|
||||
'<div class="intext_select_automation cell margin-right-1">'.acym_select(
|
||||
$orderStatuses,
|
||||
'acym_condition[conditions][__numor__][__numand__][vmreminder][status]',
|
||||
'',
|
||||
'class="acym__select"'
|
||||
).'</div>'
|
||||
);
|
||||
$conditions['user']['vmreminder']->option .= '<div class="intext_select_automation cell">';
|
||||
$conditions['user']['vmreminder']->option .= acym_select(
|
||||
$paymentMethods,
|
||||
'acym_condition[conditions][__numor__][__numand__][vmreminder][payment]',
|
||||
'',
|
||||
'class="acym__select"'
|
||||
);
|
||||
$conditions['user']['vmreminder']->option .= '</div>';
|
||||
$conditions['user']['vmreminder']->option .= '</div>';
|
||||
|
||||
|
||||
$conditions['user']['vmpurchased'] = new stdClass();
|
||||
$conditions['user']['vmpurchased']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'VirtueMart', acym_translation('ACYM_PURCHASED'));
|
||||
$conditions['user']['vmpurchased']->option = '<div class="cell grid-x grid-margin-x">';
|
||||
|
||||
$conditions['user']['vmpurchased']->option .= '<div class="cell acym_vcenter shrink">'.acym_translation('ACYM_BOUGHT').'</div>';
|
||||
|
||||
$conditions['user']['vmpurchased']->option .= '<div class="intext_select_automation cell">';
|
||||
$ajaxParams = json_encode(['plugin' => __CLASS__, 'trigger' => 'searchProduct',]);
|
||||
$conditions['user']['vmpurchased']->option .= acym_select(
|
||||
[],
|
||||
'acym_condition[conditions][__numor__][__numand__][vmpurchased][product]',
|
||||
null,
|
||||
'class="acym__select acym_select2_ajax" data-placeholder="'.acym_translation('ACYM_AT_LEAST_ONE_PRODUCT', true).'" data-params="'.acym_escape($ajaxParams).'"'
|
||||
);
|
||||
$conditions['user']['vmpurchased']->option .= '</div>';
|
||||
|
||||
$conditions['user']['vmpurchased']->option .= '<div class="intext_select_automation cell">';
|
||||
$ajaxParams = json_encode(['plugin' => __CLASS__, 'trigger' => 'searchCategory',]);
|
||||
$conditions['user']['vmpurchased']->option .= acym_select(
|
||||
[],
|
||||
'acym_condition[conditions][__numor__][__numand__][vmpurchased][category]',
|
||||
null,
|
||||
'class="acym__select acym_select2_ajax" data-placeholder="'.acym_translation('ACYM_ANY_CATEGORY', true).'" data-params="'.acym_escape($ajaxParams).'"'
|
||||
);
|
||||
$conditions['user']['vmpurchased']->option .= '</div>';
|
||||
|
||||
$conditions['user']['vmpurchased']->option .= '<div class="cell grid-x grid-margin-x margin-top-1 margin-left-0">';
|
||||
$conditions['user']['vmpurchased']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][vmpurchased][datemin]', '', 'cell shrink');
|
||||
$conditions['user']['vmpurchased']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink"><</span>';
|
||||
$conditions['user']['vmpurchased']->option .= '<span class="acym_vcenter">'.acym_translation('ACYM_DATE_CREATED').'</span>';
|
||||
$conditions['user']['vmpurchased']->option .= '<span class="acym__content__title__light-blue acym_vcenter margin-bottom-0 cell shrink"><</span>';
|
||||
$conditions['user']['vmpurchased']->option .= acym_dateField('acym_condition[conditions][__numor__][__numand__][vmpurchased][datemax]', '', 'cell shrink');
|
||||
$conditions['user']['vmpurchased']->option .= '</div>';
|
||||
|
||||
$conditions['user']['vmpurchased']->option .= '</div>';
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_vmgroups(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_vmgroups($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
private function processConditionFilter_vmgroups(&$query, $options, $num)
|
||||
{
|
||||
$defaultGroups = acym_loadResultArray('SELECT `virtuemart_shoppergroup_id` FROM `#__virtuemart_shoppergroups` WHERE `default` > 0');
|
||||
if (empty($defaultGroups)) $defaultGroups = [0];
|
||||
|
||||
$join = '#__virtuemart_vmuser_shoppergroups AS vmgroup_'.$num.' ON user.cms_id = vmgroup_'.$num.'.virtuemart_user_id';
|
||||
$where = 'vmgroup_'.$num.'.virtuemart_shoppergroup_id = '.intval($options['group']);
|
||||
|
||||
if (empty($options['type']) || $options['type'] == 'in') {
|
||||
$query->where['vmgroups_'.$num] = $where;
|
||||
if (in_array($options['group'], $defaultGroups)) {
|
||||
$query->leftjoin['vmgroups_'.$num] = $join;
|
||||
$query->where['vmgroups_'.$num] .= ' OR vmgroup_'.$num.'.virtuemart_shoppergroup_id IS NULL';
|
||||
} else {
|
||||
$query->join['vmgroups_'.$num] = $join;
|
||||
}
|
||||
} else {
|
||||
if (in_array($options['group'], $defaultGroups)) {
|
||||
$query->leftjoin['vmgroups_'.$num] = $join;
|
||||
$query->leftjoin['vmgroups_'.$num.'_2'] = str_replace('vmgroup_'.$num, 'vmgroup_'.$num.'_2', $join.' AND '.$where);
|
||||
$query->where[] = 'vmgroup_'.$num.'.virtuemart_user_id IS NOT NULL AND vmgroup_'.$num.'_2.virtuemart_user_id IS NULL';
|
||||
} else {
|
||||
$query->leftjoin['vmgroups_'.$num] = $join.' AND '.$where;
|
||||
$query->where[] = 'vmgroup_'.$num.'.virtuemart_user_id IS NULL';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_vmfield(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_vmfield($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
private function processConditionFilter_vmfield(&$query, $options, $num)
|
||||
{
|
||||
$query->join['vmfield_user'] = '#__virtuemart_userinfos AS vmfield_user ON user.cms_id = vmfield_user.virtuemart_user_id';
|
||||
$query->where[] = $query->convertQuery('vmfield_user', $options['field'], $options['operator'], $options['value']);
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_vmreminder(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_vmreminder($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
private function processConditionFilter_vmreminder(&$query, $options, $num)
|
||||
{
|
||||
$options['days'] = intval($options['days']);
|
||||
|
||||
$query->join['vmreminder_user_'.$num] = '`#__virtuemart_order_userinfos` AS vmuserinfos_'.$num.' ON vmuserinfos_'.$num.'.`email` = `user`.`email`';
|
||||
$query->join['vmreminder_orders_'.$num] = '`#__virtuemart_orders` AS vmorders'.$num.' ON vmorders'.$num.'.`virtuemart_order_id` = vmuserinfos_'.$num.'.`virtuemart_order_id`';
|
||||
|
||||
if (!empty($options['status'])) $query->where[] = 'vmorders'.$num.'.`order_status` = '.acym_escapeDB($options['status']);
|
||||
if (!empty($options['payment'])) $query->where[] = 'vmorders'.$num.'.`virtuemart_paymentmethod_id` = '.intval($options['payment']);
|
||||
|
||||
$query->where[] = 'SUBSTR(vmorders'.$num.'.`created_on`, 1, 10) = '.acym_escapeDB(acym_date(time() - ($options['days'] * 86400), 'Y-m-d', false));
|
||||
}
|
||||
|
||||
public function onAcymProcessCondition_vmpurchased(&$query, $options, $num, &$conditionNotValid)
|
||||
{
|
||||
$this->processConditionFilter_vmpurchased($query, $options, $num);
|
||||
$affectedRows = $query->count();
|
||||
if (empty($affectedRows)) $conditionNotValid++;
|
||||
}
|
||||
|
||||
private function processConditionFilter_vmpurchased(&$query, $options, $num)
|
||||
{
|
||||
$query->join['vmpurchased_user_'.$num] = '`#__virtuemart_order_userinfos` AS `vmorderuserinfos_'.$num.'` ON `vmorderuserinfos_'.$num.'`.`email` = `user`.`email`';
|
||||
$query->join['vmpurchased_order_'.$num] = '`#__virtuemart_orders` AS `vmorder_'.$num.'` ON `vmorder_'.$num.'`.`virtuemart_order_id` = `vmorderuserinfos_'.$num.'`.`virtuemart_order_id`';
|
||||
$query->where[] = '`vmorder_'.$num.'`.`order_status` IN ("C", "F", "U")';
|
||||
|
||||
if (!empty($options['datemin'])) {
|
||||
$options['datemin'] = acym_replaceDate($options['datemin']);
|
||||
if (is_numeric($options['datemin'])) $options['datemin'] = acym_date($options['datemin'], 'Y-m-d H:i:s', false);
|
||||
$query->where[] = '`vmorder_'.$num.'`.created_on > '.acym_escapeDB($options['datemin']);
|
||||
}
|
||||
|
||||
if (!empty($options['datemax'])) {
|
||||
$options['datemax'] = acym_replaceDate($options['datemax']);
|
||||
if (is_numeric($options['datemax'])) $options['datemax'] = acym_date($options['datemax'], 'Y-m-d H:i:s', false);
|
||||
$query->where[] = '`vmorder_'.$num.'`.created_on < '.acym_escapeDB($options['datemax']);
|
||||
}
|
||||
|
||||
$join = '`#__virtuemart_order_items` AS `vmorderitem_'.$num.'` ON `vmorderitem_'.$num.'`.`virtuemart_order_id` = `vmorderuserinfos_'.$num.'`.`virtuemart_order_id` ';
|
||||
if (!empty($options['product'])) {
|
||||
$query->join['vmpurchased_item_'.$num] = $join;
|
||||
$query->where[] = '`vmorderitem_'.$num.'`.`virtuemart_product_id` = '.intval($options['product']);
|
||||
} elseif (!empty($options['category'])) {
|
||||
$query->join['vmpurchased_item_'.$num] = $join;
|
||||
$query->join['vmpurchased_products_'.$num] = '`#__virtuemart_products` AS vp'.$num.' ON vmorderitem_'.$num.'.virtuemart_product_id = vp'.$num.'.virtuemart_product_id';
|
||||
$query->join['vmpurchased_order_cat'.$num] = '`#__virtuemart_product_categories` AS vpc'.$num.'
|
||||
ON vp'.$num.'.virtuemart_product_id = vpc'.$num.'.virtuemart_product_id
|
||||
OR vp'.$num.'.product_parent_id = vpc'.$num.'.virtuemart_product_id';
|
||||
$query->where[] = 'vpc'.$num.'.virtuemart_category_id = '.intval($options['category']);
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_conditions(&$automationCondition)
|
||||
{
|
||||
$this->summaryConditionFilters($automationCondition);
|
||||
}
|
||||
|
||||
private function summaryConditionFilters(&$automationCondition)
|
||||
{
|
||||
if (!empty($automationCondition['vmgroups'])) {
|
||||
acym_loadLanguageFile('com_virtuemart_shoppers', JPATH_SITE.'/components/com_virtuemart');
|
||||
|
||||
$groupName = acym_loadResult('SELECT `shopper_group_name` FROM `#__virtuemart_shoppergroups` WHERE `virtuemart_shoppergroup_id` = '.intval($automationCondition['vmgroups']['group']));
|
||||
$automationCondition = acym_translation_sprintf('ACYM_FILTER_ACY_GROUP_SUMMARY', acym_translation($automationCondition['vmgroups']['type'] == 'in' ? 'ACYM_IN' : 'ACYM_NOT_IN'), acym_translation($groupName));
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['vmfield'])) {
|
||||
$automationCondition = acym_translation_sprintf('ACYM_CONDITION_ACY_FIELD_SUMMARY', $automationCondition['vmfield']['field'], $automationCondition['vmfield']['operator'], $automationCondition['vmfield']['value']);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['vmreminder'])) {
|
||||
acym_loadLanguageFile('com_virtuemart_orders', JPATH_SITE.'/components/com_virtuemart');
|
||||
|
||||
$status = acym_loadResult('SELECT `order_status_name` FROM `#__virtuemart_orderstates` WHERE `order_status_code` = '.acym_escapeDB($automationCondition['vmreminder']['status']));
|
||||
if (empty($status)) $status = 'ACYM_ANY_STATUS';
|
||||
|
||||
$payment = acym_loadResult('SELECT `payment_name` FROM `#__virtuemart_paymentmethods_'.$this->lang.'` WHERE `virtuemart_paymentmethod_id` = '.intval($automationCondition['vmreminder']['payment']));
|
||||
if (empty($payment)) $payment = 'ACYM_ANY_PAYMENT_METHOD';
|
||||
|
||||
$automationCondition = acym_translation_sprintf(
|
||||
'ACYM_CONDITION_ECOMMERCE_REMINDER',
|
||||
acym_translation($payment),
|
||||
intval($automationCondition['vmreminder']['days']),
|
||||
acym_translation($status)
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['vmpurchased'])) {
|
||||
if (!empty($automationCondition['vmpurchased']['product'])) {
|
||||
$product = acym_loadResult('SELECT `product_name` FROM #__virtuemart_products_'.$this->lang.' WHERE `virtuemart_product_id` = '.intval($automationCondition['vmpurchased']['product']));
|
||||
}
|
||||
if (empty($product)) $product = acym_translation('ACYM_AT_LEAST_ONE_PRODUCT');
|
||||
|
||||
if (!empty($automationCondition['vmpurchased']['category'])) {
|
||||
$category = acym_loadResult('SELECT `category_name` FROM #__virtuemart_categories_'.$this->lang.' WHERE `virtuemart_category_id` = '.intval($automationCondition['vmpurchased']['category']));
|
||||
}
|
||||
if (empty($category)) $category = acym_translation('ACYM_ANY_CATEGORY');
|
||||
|
||||
$finalText = acym_translation_sprintf('ACYM_CONDITION_PURCHASED', $product, $category);
|
||||
|
||||
$dates = [];
|
||||
if (!empty($automationCondition['vmpurchased']['datemin'])) {
|
||||
$dates[] = acym_translation('ACYM_AFTER').' '.acym_replaceDate($automationCondition['vmpurchased']['datemin'], true);
|
||||
}
|
||||
|
||||
if (!empty($automationCondition['vmpurchased']['datemax'])) {
|
||||
$dates[] = acym_translation('ACYM_BEFORE').' '.acym_replaceDate($automationCondition['vmpurchased']['datemax'], true);
|
||||
}
|
||||
|
||||
if (!empty($dates)) {
|
||||
$finalText .= ' '.implode(' '.acym_translation('ACYM_AND').' ', $dates);
|
||||
}
|
||||
|
||||
$automationCondition = $finalText;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareFilters(&$filters)
|
||||
{
|
||||
$newFilters = [];
|
||||
|
||||
$this->onAcymDeclareConditions($newFilters);
|
||||
foreach ($newFilters as $oneType) {
|
||||
foreach ($oneType as $oneFilterName => $oneFilter) {
|
||||
if (!empty($oneFilter->option)) $oneFilter->option = str_replace(['acym_condition', '[conditions]'], ['acym_action', '[filters]'], $oneFilter->option);
|
||||
$filters[$oneFilterName] = $oneFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_vmgroups(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_vmgroups($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_vmfield(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_vmfield($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_vmreminder(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_vmreminder($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymProcessFilterCount_vmpurchased(&$query, $options, $num)
|
||||
{
|
||||
$this->processConditionFilter_vmpurchased($query, $options, $num);
|
||||
|
||||
return acym_translation_sprintf('ACYM_SELECTED_USERS', $query->count());
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_filters(&$automationFilter)
|
||||
{
|
||||
$this->summaryConditionFilters($automationFilter);
|
||||
}
|
||||
|
||||
public function onAcymDeclareTriggers(&$triggers)
|
||||
{
|
||||
$triggers['user']['vmorder'] = new stdClass();
|
||||
$triggers['user']['vmorder']->name = acym_translation_sprintf('ACYM_COMBINED_TRANSLATIONS', 'VirtueMart', acym_translation('ACYM_WHEN_ORDER'));
|
||||
$triggers['user']['vmorder']->option = '<input type="hidden" name="[triggers][user][vmorder][]" value="">';
|
||||
}
|
||||
|
||||
public function onAcymExecuteTrigger(&$step, &$execute, $data)
|
||||
{
|
||||
if (empty($data['userId'])) return;
|
||||
|
||||
$triggers = json_decode($step->triggers, true);
|
||||
|
||||
if (!empty($triggers['vmorder'])) {
|
||||
$execute = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function onAcymDeclareSummary_triggers(&$automation)
|
||||
{
|
||||
if (!empty($automation->triggers['vmorder'])) $automation->triggers['vmorder'] = acym_translation('ACYM_WHEN_ORDER');
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
File diff suppressed because it is too large
Load Diff
1183
deployed/acym/administrator/components/com_acym/helpers/bounce.php
Normal file
1183
deployed/acym/administrator/components/com_acym/helpers/bounce.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymcaptchaHelper
|
||||
{
|
||||
function display($formName = '')
|
||||
{
|
||||
$config = acym_config();
|
||||
$pubkey = $config->get('recaptcha_sitekey', '');
|
||||
if ($config->get('captcha', '') != 1 || empty($pubkey)) return '';
|
||||
|
||||
acym_addScript(false, 'https://www.google.com/recaptcha/api.js?render=explicit&hl='.acym_getLanguageTag(), 'text/javascript', true, true);
|
||||
|
||||
$id = empty($formName) ? 'acym-captcha' : $formName.'-captcha';
|
||||
|
||||
return '<div id="'.acym_escape($id).'" data-size="invisible" class="g-recaptcha" data-sitekey="'.acym_escape($pubkey).'"></div>';
|
||||
}
|
||||
|
||||
function check()
|
||||
{
|
||||
$config = acym_config();
|
||||
$secKey = acym_getVar('string', 'seckey', 'none');
|
||||
if ($secKey == $config->get('security_key')) return true;
|
||||
|
||||
$privatekey = $config->get('recaptcha_secretkey', '');
|
||||
$response = acym_getVar('string', 'g-recaptcha-response', '');
|
||||
$remoteip = acym_getVar('string', 'REMOTE_ADDR', '', 'SERVER');
|
||||
if (empty($privatekey) || $response === '' || empty($remoteip)) return false;
|
||||
|
||||
$url = 'https://www.google.com/recaptcha/api/siteverify?secret='.urlencode(stripslashes($privatekey));
|
||||
$url .= '&remoteip='.urlencode(stripslashes($remoteip));
|
||||
$url .= '&response='.urlencode(stripslashes($response));
|
||||
$getResponse = acym_fileGetContent($url);
|
||||
|
||||
$answers = json_decode($getResponse, true);
|
||||
|
||||
return (is_array($answers) && !empty($answers['success']) && trim($answers['success']) !== '');
|
||||
}
|
||||
}
|
||||
|
||||
246
deployed/acym/administrator/components/com_acym/helpers/cron.php
Normal file
246
deployed/acym/administrator/components/com_acym/helpers/cron.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymcronHelper
|
||||
{
|
||||
var $report = false;
|
||||
var $messages = [];
|
||||
var $detailMessages = [];
|
||||
|
||||
var $processed = false;
|
||||
|
||||
var $executed = false;
|
||||
|
||||
var $mainmessage = '';
|
||||
|
||||
var $errorDetected = false;
|
||||
|
||||
var $skip = [];
|
||||
|
||||
var $emailtypes = [];
|
||||
|
||||
function cron()
|
||||
{
|
||||
$time = time();
|
||||
$config = acym_config();
|
||||
|
||||
$firstMessage = acym_translation_sprintf('ACYM_CRON_TRIGGERED', acym_date('now', 'd F Y H:i'));
|
||||
$this->messages[] = $firstMessage;
|
||||
if ($this->report) {
|
||||
acym_display($firstMessage, 'info');
|
||||
}
|
||||
|
||||
if ($config->get('cron_next') > $time) {
|
||||
if ($config->get('cron_next') > ($time + $config->get('cron_frequency'))) {
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->cron_next = $time + $config->get('cron_frequency');
|
||||
$config->save($newConfig);
|
||||
}
|
||||
|
||||
$nottime = acym_translation_sprintf('ACYM_CRON_NEXT', acym_getDate($config->get('cron_next')));
|
||||
$this->messages[] = $nottime;
|
||||
if ($this->report) {
|
||||
acym_display($nottime, 'info');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->executed = true;
|
||||
|
||||
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->cron_last = $time;
|
||||
$newConfig->cron_fromip = acym_getIP();
|
||||
$newConfig->cron_next = $config->get('cron_next') + $config->get('cron_frequency');
|
||||
|
||||
if ($newConfig->cron_next <= $time || $newConfig->cron_next > $time + $config->get('cron_frequency')) {
|
||||
$newConfig->cron_next = $time + $config->get('cron_frequency');
|
||||
}
|
||||
|
||||
$config->save($newConfig);
|
||||
|
||||
|
||||
if (!in_array('schedule', $this->skip)) {
|
||||
$queueClass = acym_get('class.queue');
|
||||
$nbScheduled = $queueClass->scheduleReady();
|
||||
if ($nbScheduled) {
|
||||
$this->messages[] = acym_translation_sprintf('ACYM_NB_SCHEDULED', $nbScheduled);
|
||||
$this->detailMessages = array_merge($this->detailMessages, $queueClass->messages);
|
||||
$this->processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($config->get('require_confirmation', 1) == 1) {
|
||||
$deletedNb = $queueClass->removeUnconfirmedUsersEmails();
|
||||
|
||||
if (!empty($deletedNb)) {
|
||||
$this->messages[] = acym_translation_sprintf('ACYM_EMAILS_REMOVED_QUEUE_UNCONFIRMED', $deletedNb);
|
||||
$this->processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($config->get('queue_type') != 'manual' && !in_array('send', $this->skip)) {
|
||||
$queueHelper = acym_get('helper.queue');
|
||||
$queueHelper->send_limit = (int)$config->get('queue_nbmail_auto');
|
||||
$queueHelper->report = false;
|
||||
$queueHelper->emailtypes = $this->emailtypes;
|
||||
$queueHelper->process();
|
||||
if (!empty($queueHelper->messages)) {
|
||||
$this->detailMessages = array_merge($this->detailMessages, $queueHelper->messages);
|
||||
}
|
||||
if (!empty($queueHelper->nbprocess)) {
|
||||
$this->processed = true;
|
||||
}
|
||||
$this->mainmessage = acym_translation_sprintf('ACYM_CRON_PROCESS', $queueHelper->nbprocess, $queueHelper->successSend, $queueHelper->errorSend);
|
||||
$this->messages[] = $this->mainmessage;
|
||||
|
||||
if (!empty($queueHelper->errorSend)) {
|
||||
$this->errorDetected = true;
|
||||
}
|
||||
if (!empty($queueHelper->stoptime) && time() > $queueHelper->stoptime) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('bounce', $this->skip) && acym_level(2) && $config->get('auto_bounce', 0) && $time > (int)$config->get('auto_bounce_next', 0) && (empty($queueHelper->stoptime) || time() < $queueHelper->stoptime - 5)) {
|
||||
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->auto_bounce_next = $time + (int)$config->get('auto_bounce_frequency', 0);
|
||||
$newConfig->auto_bounce_last = $time;
|
||||
$config->save($newConfig);
|
||||
$bounceClass = acym_get('helper.bounce');
|
||||
$bounceClass->report = false;
|
||||
$bounceClass->stoptime = $queueHelper->stoptime;
|
||||
$newConfig = new stdClass();
|
||||
if ($bounceClass->init() && $bounceClass->connect()) {
|
||||
$nbMessages = $bounceClass->getNBMessages();
|
||||
$this->messages[] = acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages);
|
||||
$newConfig->auto_bounce_report = acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages);
|
||||
$this->detailMessages[] = acym_translation_sprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages);
|
||||
if (!empty($nbMessages)) {
|
||||
$bounceClass->handleMessages();
|
||||
$bounceClass->close();
|
||||
$this->processed = true;
|
||||
}
|
||||
$this->detailMessages = array_merge($this->detailMessages, $bounceClass->messages);
|
||||
} else {
|
||||
$bounceErrors = $bounceClass->getErrors();
|
||||
$newConfig->auto_bounce_report = implode('<br />', $bounceErrors);
|
||||
if (!empty($bounceErrors[0])) {
|
||||
$bounceErrors[0] = acym_translation('ACYM_BOUNCE_HANDLING').' : '.$bounceErrors[0];
|
||||
}
|
||||
$this->messages = array_merge($this->messages, $bounceErrors);
|
||||
$this->processed = true;
|
||||
$this->errorDetected = true;
|
||||
}
|
||||
$config->save($newConfig);
|
||||
|
||||
if (!empty($queueHelper->stoptime) && time() > $queueHelper->stoptime) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('automation', $this->skip) && acym_level(2)) {
|
||||
$automationClass = acym_get('class.automation');
|
||||
$automationClass->trigger('classic');
|
||||
if (!empty($automationClass->report)) {
|
||||
if ($automationClass->didAnAction) $this->processed = true;
|
||||
$this->messages = array_merge($this->messages, $automationClass->report);
|
||||
}
|
||||
|
||||
if (!empty($queueHelper->stoptime) && time() > $queueHelper->stoptime) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function report()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
$sendreport = $config->get('cron_sendreport');
|
||||
$mailer = acym_get('helper.mailer');
|
||||
|
||||
if (($sendreport == 2 && $this->processed) || $sendreport == 1 || ($sendreport == 3 && $this->errorDetected)) {
|
||||
$mailer->report = false;
|
||||
$mailer->autoAddUser = true;
|
||||
$mailer->checkConfirmField = false;
|
||||
$mailer->addParam('report', implode('<br />', $this->messages));
|
||||
$mailer->addParam('mainreport', $this->mainmessage);
|
||||
$mailer->addParam('detailreport', implode('<br />', $this->detailMessages));
|
||||
|
||||
$receiverString = $config->get('cron_sendto');
|
||||
$receivers = [];
|
||||
if (substr_count($receiverString, '@') > 1) {
|
||||
$receivers = explode(' ', trim(preg_replace('# +#', ' ', str_replace([';', ','], ' ', $receiverString))));
|
||||
} else {
|
||||
$receivers[] = trim($receiverString);
|
||||
}
|
||||
|
||||
if (!empty($receivers)) {
|
||||
foreach ($receivers as $oneReceiver) {
|
||||
$mailer->sendOne('acy_report', $oneReceiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->executed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->processed) {
|
||||
$this->saveReport();
|
||||
}
|
||||
|
||||
$newConfig = new stdClass();
|
||||
$newConfig->cron_report = implode("\n", $this->messages);
|
||||
if (strlen($newConfig->cron_report) > 800) {
|
||||
$newConfig->cron_report = substr($newConfig->cron_report, 0, 795).'...';
|
||||
}
|
||||
$config->save($newConfig);
|
||||
}
|
||||
|
||||
function saveReport()
|
||||
{
|
||||
$config = acym_config();
|
||||
$saveReport = $config->get('cron_savereport');
|
||||
if (empty($saveReport)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reportPath = $config->get('cron_savepath');
|
||||
if (empty($reportPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reportPath = str_replace(['{year}', '{month}'], [date('Y'), date('m')], $reportPath);
|
||||
|
||||
$reportPath = acym_cleanPath(ACYM_ROOT.trim(html_entity_decode($reportPath)));
|
||||
|
||||
acym_createDir(dirname($reportPath), true, true);
|
||||
|
||||
ob_start();
|
||||
file_put_contents($reportPath, "\r\n"."\r\n".str_repeat('*', 20).str_repeat(' ', 5).acym_getDate(time()).str_repeat(' ', 5).str_repeat('*', 20)."\r\n".implode("\r\n", $this->messages), FILE_APPEND);
|
||||
if ($saveReport == 2 && !empty($this->detailMessages)) {
|
||||
@file_put_contents($reportPath, "\r\n"."---- Details ----"."\r\n".implode("\r\n", $this->detailMessages), FILE_APPEND);
|
||||
}
|
||||
$potentialWarnings = ob_get_clean();
|
||||
|
||||
if (!empty($potentialWarnings)) {
|
||||
$this->messages[] = $potentialWarnings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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
|
||||
|
||||
use Joomla\CMS\Editor\Editor AS Editor;
|
||||
|
||||
class acymeditorHelper
|
||||
{
|
||||
var $width = '95%';
|
||||
var $height = '600';
|
||||
|
||||
var $cols = 100;
|
||||
var $rows = 30;
|
||||
|
||||
var $editor = '';
|
||||
var $name = 'editor_content';
|
||||
var $settings = 'editor_settings';
|
||||
var $stylesheet = 'editor_stylesheet';
|
||||
var $thumbnail = 'editor_thumbnail';
|
||||
var $content = '';
|
||||
var $editorContent = '';
|
||||
var $editorConfig = [];
|
||||
var $mailId = 0;
|
||||
var $automation = false;
|
||||
var $walkThrough = false;
|
||||
|
||||
public function display()
|
||||
{
|
||||
|
||||
if ($this->isDragAndDrop()) {
|
||||
acym_addScript(false, ACYM_JS.'tinymce/tinymce.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'tinymce/tinymce.min.js'));
|
||||
include(ACYM_VIEW.'mails'.DS.'tmpl'.DS.'editor_wysid.php');
|
||||
} else {
|
||||
echo 'joomla' === ACYM_CMS ? '</div></div><div class="acym_no_foundation"><div>' : '</div><div class="acym_no_foundation"><div>';
|
||||
$method = 'displayJoomla';
|
||||
$this->$method();
|
||||
}
|
||||
}
|
||||
|
||||
public function isDragAndDrop()
|
||||
{
|
||||
return strpos($this->content, 'acym__wysid__template') !== false || $this->editor == 'acyEditor';
|
||||
}
|
||||
|
||||
private function displayJoomla()
|
||||
{
|
||||
$this->editor = acym_getCMSConfig('editor', 'tinymce');
|
||||
|
||||
$this->myEditor = Editor::getInstance($this->editor);
|
||||
$this->myEditor->initialise();
|
||||
|
||||
$this->editorConfig['extended_elements'] = 'table[background|cellspacing|cellpadding|width|align|bgcolor|border|style|class|id],tr[background|width|bgcolor|style|class|id|valign],td[background|width|align|bgcolor|valign|colspan|rowspan|height|style|class|id|nowrap]';
|
||||
|
||||
if (!empty($this->mailId)) {
|
||||
$cssurl = acym_completeLink((acym_isAdmin() ? '' : 'front').'mails&task=loadCSS&id='.$this->mailId.'&time='.time());
|
||||
$classMail = acym_get('class.mail');
|
||||
$filepath = $classMail->createTemplateFile($this->mailId);
|
||||
|
||||
if ($this->editor == 'tinymce') {
|
||||
$this->editorConfig['content_css_custom'] = $cssurl.'&local=http';
|
||||
$this->editorConfig['content_css'] = '0';
|
||||
} elseif ($this->editor == 'jckeditor' || $this->editor == 'fckeditor') {
|
||||
$this->editorConfig['content_css_custom'] = $filepath;
|
||||
$this->editorConfig['content_css'] = '0';
|
||||
$this->editorConfig['editor_css'] = '0';
|
||||
} else {
|
||||
$fileurl = ACYM_MEDIA_FOLDER.'/templates/css/template_'.$this->mailId.'.css?time='.time();
|
||||
$this->editorConfig['custom_css_url'] = $cssurl;
|
||||
$this->editorConfig['custom_css_file'] = $fileurl;
|
||||
$this->editorConfig['custom_css_path'] = $filepath;
|
||||
acym_setVar('acycssfile', $fileurl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($this->editorContent)) {
|
||||
$this->content = acym_escape($this->content);
|
||||
ob_start();
|
||||
echo $this->myEditor->display($this->name, $this->content, $this->width, $this->height, $this->cols, $this->rows, ['pagebreak', 'readmore'], null, 'com_content', null, $this->editorConfig);
|
||||
|
||||
$this->editorContent = ob_get_clean();
|
||||
}
|
||||
|
||||
if (method_exists($this->myEditor, 'save')) {
|
||||
acym_addScript(true, 'function acyOnSaveEditor(){'.$this->myEditor->save($this->name).'}');
|
||||
}
|
||||
|
||||
echo $this->editorContent;
|
||||
}
|
||||
|
||||
private function displayWordPress()
|
||||
{
|
||||
add_filter('mce_external_plugins', [$this, 'addPlugins']);
|
||||
add_filter('mce_buttons', [$this, 'addButtons']);
|
||||
add_filter('mce_buttons_2', [$this, 'addButtonsToolbar']);
|
||||
|
||||
$mailClass = acym_get('class.mail');
|
||||
|
||||
$mail = $mailClass->getOneById($this->mailId);
|
||||
$stylesheet = empty($mail) ? '' : trim(preg_replace('/\s\s+/', ' ', $mailClass->buildCSS($mail->stylesheet)));
|
||||
|
||||
$options = [
|
||||
'editor_css' => '<style type="text/css">
|
||||
.alignleft{float:left;margin:0.5em 1em 0.5em 0;}
|
||||
.aligncenter{display: block;margin-left: auto;margin-right: auto;}
|
||||
.alignright{float: right;margin: 0.5em 0 0.5em 1em;}
|
||||
</style>',
|
||||
'editor_height' => $this->height,
|
||||
'textarea_rows' => $this->rows,
|
||||
"wpautop" => false,
|
||||
'tinymce' => [
|
||||
'content_css' => '',
|
||||
'content_style' => '.alignleft{float:left;margin:0.5em 1em 0.5em 0;} .aligncenter{display: block;margin-left: auto;margin-right: auto;} .alignright{float: right;margin: 0.5em 0 0.5em 1em;}'.$stylesheet,
|
||||
],
|
||||
];
|
||||
|
||||
wp_editor($this->content, $this->name, $options);
|
||||
}
|
||||
|
||||
private function getWYSIDSettings()
|
||||
{
|
||||
if ($this->settings != 'editor_settings') return $this->settings;
|
||||
|
||||
$id = acym_getVar('int', 'id');
|
||||
|
||||
if (empty($id)) return null;
|
||||
|
||||
$ctrl = acym_getVar('string', 'ctrl');
|
||||
if ($ctrl == 'mails') {
|
||||
$query = 'SELECT settings FROM #__acym_mail WHERE id = '.intval($id);
|
||||
} elseif ($ctrl == 'campaigns') {
|
||||
$query = 'SELECT settings FROM #__acym_mail AS mail JOIN #__acym_campaign AS campaign ON mail.id = campaign.mail_id WHERE campaign.id = '.intval($id);
|
||||
} else {
|
||||
return '{}';
|
||||
}
|
||||
|
||||
$settings = acym_loadResult($query);
|
||||
|
||||
return empty($settings) ? '{}' : $settings;
|
||||
}
|
||||
|
||||
private function getWYSIDStylesheet()
|
||||
{
|
||||
if ($this->stylesheet != 'editor_stylesheet') return $this->stylesheet;
|
||||
|
||||
$id = acym_getVar('int', 'id');
|
||||
$notification = acym_getVar('string', 'notification');
|
||||
$ctrl = acym_getVar('string', 'ctrl');
|
||||
|
||||
if (!in_array($ctrl, ['mails', 'campaigns'])) return null;
|
||||
|
||||
if (!empty($id)) {
|
||||
if ($ctrl == 'mails') {
|
||||
$query = 'SELECT stylesheet FROM #__acym_mail WHERE id = '.intval($id);
|
||||
} elseif ($ctrl == 'campaigns') {
|
||||
$query = 'SELECT stylesheet FROM #__acym_mail AS mail JOIN #__acym_campaign AS campaign ON mail.id = campaign.mail_id WHERE campaign.id = '.intval($id);
|
||||
}
|
||||
|
||||
$stylesheet = acym_loadResult($query);
|
||||
|
||||
return empty($stylesheet) ? '' : $stylesheet;
|
||||
} elseif (!empty($notification)) {
|
||||
$stylesheet = acym_loadResult('SELECT stylesheet FROM #__acym_mail WHERE `type` = "notification" AND `name` = '.acym_escapeDB($notification));
|
||||
|
||||
return empty($stylesheet) ? '' : $stylesheet;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getWYSIDThumbnail()
|
||||
{
|
||||
if ($this->thumbnail != 'editor_thumbnail') return $this->thumbnail;
|
||||
|
||||
$id = acym_getVar('int', 'id');
|
||||
if (empty($id)) return null;
|
||||
|
||||
$thumbnail = acym_loadResult('SELECT thumbnail FROM #__acym_mail WHERE id = '.intval($id));
|
||||
|
||||
return empty($thumbnail) ? '' : $thumbnail;
|
||||
}
|
||||
|
||||
private function addButtonAtPosition(&$buttons, $newButton, $after)
|
||||
{
|
||||
$position = array_search($after, $buttons);
|
||||
|
||||
if ($position === false) {
|
||||
array_push($buttons, 'separator', $newButton);
|
||||
} else {
|
||||
array_splice($buttons, $position + 1, 0, $newButton);
|
||||
}
|
||||
}
|
||||
|
||||
public function addPlugins($plugins)
|
||||
{
|
||||
$plugins['table'] = ACYM_JS.'tinymce/table.min.js';
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public function addButtons($buttons)
|
||||
{
|
||||
$position = array_search('wp_more', $buttons);
|
||||
if ($position !== false) {
|
||||
$buttons[$position] = '';
|
||||
}
|
||||
|
||||
array_unshift($buttons, 'separator', 'fontsizeselect');
|
||||
array_unshift($buttons, 'separator', 'fontselect');
|
||||
array_push($buttons, 'separator', 'table');
|
||||
|
||||
$this->addButtonAtPosition($buttons, 'alignjustify', 'alignright');
|
||||
$this->addButtonAtPosition($buttons, 'underline', 'italic');
|
||||
$this->addButtonAtPosition($buttons, 'strikethrough', 'underline');
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
public function addButtonsToolbar($buttons)
|
||||
{
|
||||
$position = array_search('strikethrough', $buttons);
|
||||
if ($position !== false) {
|
||||
$buttons[$position] = '';
|
||||
}
|
||||
$this->addButtonAtPosition($buttons, 'backcolor', 'forecolor');
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymencodingHelper
|
||||
{
|
||||
function change($data, $inputCharset, $outputCharset)
|
||||
{
|
||||
$inputCharset = strtoupper(trim($inputCharset));
|
||||
$outputCharset = strtoupper(trim($outputCharset));
|
||||
|
||||
$supportedEncodings = ["BIG5", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-2022-JP", "US-ASCII", "UTF-7", "UTF-8", "UTF-16", "WINDOWS-1251", "WINDOWS-1252", "ARMSCII-8", "ISO-8859-16"];
|
||||
if (!in_array($inputCharset, $supportedEncodings)) {
|
||||
acym_enqueueNotification('Encoding not supported: '.$inputCharset, 'error', 0);
|
||||
} elseif (!in_array($outputCharset, $supportedEncodings)) {
|
||||
acym_enqueueNotification('Encoding not supported: '.$outputCharset, 'error', 0);
|
||||
}
|
||||
|
||||
if ($inputCharset == $outputCharset) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ($inputCharset == 'UTF-8' && $outputCharset == 'ISO-8859-1') {
|
||||
$data = str_replace(['€', '„', '“'], ['EUR', '"', '"'], $data);
|
||||
}
|
||||
|
||||
if (function_exists('iconv')) {
|
||||
set_error_handler('acym_error_handler_encoding');
|
||||
$encodedData = iconv($inputCharset, $outputCharset."//IGNORE", $data);
|
||||
restore_error_handler();
|
||||
if (!empty($encodedData) && !acym_error_handler_encoding('result')) {
|
||||
return $encodedData;
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($data, $outputCharset, $inputCharset);
|
||||
}
|
||||
|
||||
if ($inputCharset == 'UTF-8' && $outputCharset == 'ISO-8859-1') {
|
||||
return utf8_decode($data);
|
||||
}
|
||||
|
||||
if ($inputCharset == 'ISO-8859-1' && $outputCharset == 'UTF-8') {
|
||||
return utf8_encode($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function detectEncoding(&$content)
|
||||
{
|
||||
if (!function_exists('mb_check_encoding')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$toTest = ['UTF-8'];
|
||||
|
||||
$tag = acym_getLanguageTag();
|
||||
|
||||
if ($tag == 'el-GR') {
|
||||
$toTest[] = 'ISO-8859-7';
|
||||
}
|
||||
$toTest[] = 'ISO-8859-1';
|
||||
$toTest[] = 'ISO-8859-2';
|
||||
$toTest[] = 'Windows-1252';
|
||||
|
||||
foreach ($toTest as $oneEncoding) {
|
||||
if (mb_check_encoding($content, $oneEncoding)) {
|
||||
return $oneEncoding;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function encodingField($name, $selected, $attribs = 'style="max-width:200px;"')
|
||||
{
|
||||
$encodings = [
|
||||
'binary' => 'Binary',
|
||||
'quoted' => 'Quoted-printable',
|
||||
'7bit' => '7 Bit',
|
||||
'8bit' => '8 Bit',
|
||||
'base64' => 'Base 64',
|
||||
];
|
||||
$attribs .= 'style="max-width:200px;"';
|
||||
echo acym_select($encodings, $name, $selected, $attribs, '', '', 'config_encoding');
|
||||
}
|
||||
|
||||
function charsetField($name, $selected, $attribs = null)
|
||||
{
|
||||
$charsets = [
|
||||
'BIG5' => 'BIG5',//Iconv,mbstring
|
||||
'ISO-8859-1' => 'ISO-8859-1',//Iconv,mbstring
|
||||
'ISO-8859-2' => 'ISO-8859-2',//Iconv,mbstring
|
||||
'ISO-8859-3' => 'ISO-8859-3',//Iconv,mbstring
|
||||
'ISO-8859-4' => 'ISO-8859-4',//Iconv,mbstring
|
||||
'ISO-8859-5' => 'ISO-8859-5',//Iconv,mbstring
|
||||
'ISO-8859-6' => 'ISO-8859-6',//Iconv,mbstring
|
||||
'ISO-8859-7' => 'ISO-8859-7',//Iconv,mbstring
|
||||
'ISO-8859-8' => 'ISO-8859-8',//Iconv,mbstring
|
||||
'ISO-8859-9' => 'ISO-8859-9',//Iconv,mbstring
|
||||
'ISO-8859-10' => 'ISO-8859-10',//Iconv,mbstring
|
||||
'ISO-8859-13' => 'ISO-8859-13',//Iconv,mbstring
|
||||
'ISO-8859-14' => 'ISO-8859-14',//Iconv,mbstring
|
||||
'ISO-8859-15' => 'ISO-8859-15',//Iconv,mbstring
|
||||
'ISO-2022-JP' => 'ISO-2022-JP',//mbstring for sure... not sure about Iconv
|
||||
'US-ASCII' => 'US-ASCII', //Iconv,mbstring
|
||||
'UTF-7' => 'UTF-7',//Iconv,mbstring
|
||||
'UTF-8' => 'UTF-8',//Iconv,mbstring
|
||||
'UTF-16' => 'UTF-16',//Iconv,mbstring
|
||||
'Windows-1251' => 'Windows-1251', //Iconv,mbstring
|
||||
'Windows-1252' => 'Windows-1252' //Iconv,mbstring
|
||||
];
|
||||
|
||||
if (function_exists('iconv')) {
|
||||
$charsets['ARMSCII-8'] = 'ARMSCII-8';
|
||||
$charsets['ISO-8859-16'] = 'ISO-8859-16';
|
||||
}
|
||||
|
||||
echo acym_select($charsets, $name, $selected, $attribs, '', '');
|
||||
}
|
||||
}
|
||||
|
||||
function acym_error_handler_encoding($errno, $errstr = '')
|
||||
{
|
||||
static $error = false;
|
||||
if (is_string($errno) && $errno == 'result') {
|
||||
$currentError = $error;
|
||||
$error = false;
|
||||
|
||||
return $currentError;
|
||||
}
|
||||
$error = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymexportHelper
|
||||
{
|
||||
public function setDownloadHeaders($filename = 'export', $extension = 'csv')
|
||||
{
|
||||
header("Pragma: public");
|
||||
header("Expires: 0");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Type: application/download");
|
||||
|
||||
header("Content-Disposition: attachment; filename=".$filename.".".$extension);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
}
|
||||
|
||||
public function exportCSV($query, $fieldsToExport, $customFieldsToExport, $separator = ',', $charset = 'UTF-8')
|
||||
{
|
||||
@ob_clean();
|
||||
|
||||
$filename = "export_".date('Y-m-d');
|
||||
$this->setDownloadHeaders($filename);
|
||||
$nbExport = $this->getExportLimit();
|
||||
|
||||
acym_displayErrors();
|
||||
$encodingClass = acym_get('helper.encoding');
|
||||
$config = acym_config();
|
||||
|
||||
$eol = "\r\n";
|
||||
$before = '"';
|
||||
$separator = '"'.$separator.'"';
|
||||
$after = '"';
|
||||
|
||||
echo $before.implode($separator, array_merge($fieldsToExport, $customFieldsToExport)).$after.$eol;
|
||||
|
||||
$start = 0;
|
||||
do {
|
||||
$users = acym_loadObjectList($query.' LIMIT '.intval($start).', '.intval($nbExport), 'id');
|
||||
$start += $nbExport;
|
||||
|
||||
if ($users === false) {
|
||||
echo $eol.$eol.'Error : '.acym_getDBError();
|
||||
}
|
||||
|
||||
if (empty($users)) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($users as $userID => $oneUser) {
|
||||
unset($oneUser->id);
|
||||
|
||||
$data = get_object_vars($oneUser);
|
||||
|
||||
if (!empty($customFieldsToExport)) {
|
||||
$userCustomFields = acym_loadObjectList(
|
||||
'SELECT field_id, value
|
||||
FROM #__acym_user_has_field
|
||||
WHERE user_id = '.intval($userID).' AND field_id IN ('.implode(',', array_keys($customFieldsToExport)).')
|
||||
ORDER BY field_id',
|
||||
'field_id'
|
||||
);
|
||||
|
||||
foreach ($customFieldsToExport as $fieldID => $fieldName) {
|
||||
$data[] = empty($userCustomFields[$fieldID]) ? '' : $userCustomFields[$fieldID]->value;
|
||||
}
|
||||
}
|
||||
|
||||
$excelSecure = $config->get('export_excelsecurity', 0);
|
||||
foreach ($data as &$oneData) {
|
||||
if ($excelSecure == 1) {
|
||||
$firstcharacter = substr($oneData, 0, 1);
|
||||
if (in_array($firstcharacter, ['=', '+', '-', '@'])) {
|
||||
$oneData = ' '.$oneData;
|
||||
}
|
||||
}
|
||||
|
||||
$oneData = acym_escape($oneData);
|
||||
}
|
||||
|
||||
$dataexport = implode($separator, $data);
|
||||
|
||||
echo $before.$encodingClass->change($dataexport, 'UTF-8', $charset).$after.$eol;
|
||||
}
|
||||
|
||||
unset($users);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
private function getExportLimit()
|
||||
{
|
||||
$serverLimit = acym_bytes(ini_get('memory_limit'));
|
||||
if ($serverLimit > 150000000) {
|
||||
return 50000;
|
||||
} elseif ($serverLimit > 80000000) {
|
||||
return 15000;
|
||||
} else {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymheaderHelper
|
||||
{
|
||||
function display($breadcrumb)
|
||||
{
|
||||
$news = @simplexml_load_file(ACYM_ACYWEBSITE.'acymnews.xml');
|
||||
$config = acym_config();
|
||||
$header = '';
|
||||
if (!empty($news->news)) {
|
||||
|
||||
$currentLanguage = acym_getLanguageTag();
|
||||
|
||||
$latestNews = null;
|
||||
$doNotRemind = json_decode($config->get('remindme', '[]'));
|
||||
foreach ($news->news as $oneNews) {
|
||||
if (!empty($latestNews) && strtotime($latestNews->date) > strtotime($oneNews->date)) break;
|
||||
|
||||
if (empty($oneNews->published) || (strtolower($oneNews->language) != strtolower($currentLanguage) && (strtolower($oneNews->language) != 'default' || !empty($latestNews)))) continue;
|
||||
|
||||
if (!empty($oneNews->extension) && strtolower($oneNews->extension) != 'acymailing') continue;
|
||||
|
||||
if (!empty($oneNews->cms) && strtolower($oneNews->cms) != 'Joomla') continue;
|
||||
|
||||
if (!empty($oneNews->level) && strtolower($oneNews->level) != strtolower($config->get('level'))) continue;
|
||||
|
||||
if (!empty($oneNews->version)) {
|
||||
list($version, $operator) = explode('_', $oneNews->version);
|
||||
if (!version_compare($config->get('version'), $version, $operator)) continue;
|
||||
}
|
||||
|
||||
if (in_array($oneNews->name, $doNotRemind)) continue;
|
||||
|
||||
$latestNews = $oneNews;
|
||||
}
|
||||
|
||||
if (!empty($latestNews)) {
|
||||
$header .= '<div id="acym__header__banner__news" data-news="'.acym_escape($latestNews->name).'">';
|
||||
|
||||
if (!empty($latestNews)) {
|
||||
$header .= $latestNews->content;
|
||||
}
|
||||
|
||||
$header .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$links = [];
|
||||
foreach ($breadcrumb as $oneLevel => $link) {
|
||||
if (!empty($link)) {
|
||||
$oneLevel = '<a href="'.$link.'">'.$oneLevel.'</a>';
|
||||
}
|
||||
$links[] = '<li>'.$oneLevel.'</li>';
|
||||
}
|
||||
|
||||
if (count($links) > 1) {
|
||||
$links[count($links) - 1] = str_replace('<li>', '<li class="last_link cell auto"><span class="show-for-sr">Current: </span>', $links[count($links) - 1]);
|
||||
}
|
||||
|
||||
|
||||
$header .= '<div id="acym_header" class="grid-x hide-for-small-only margin-bottom-1">';
|
||||
|
||||
$header .= '<i class="cell medium-shrink acym-logo"></i>';
|
||||
|
||||
$header .= '<div id="acym_global_navigation" class="cell medium-auto"><nav aria-label="You are here:" role="navigation"><ul class="breadcrumbs grid-x">';
|
||||
$header .= implode('', $links);
|
||||
$header .= '</ul></nav></div>';
|
||||
|
||||
$header .= '<div id="checkVersionArea" class="cell grid-x align-right large-auto check-version-area acym_vcenter margin-right-1">';
|
||||
$header .= $this->checkVersionArea();
|
||||
$header .= '</div>';
|
||||
|
||||
$config = acym_config();
|
||||
|
||||
$lastLicenseCheck = $config->get('lastlicensecheck', 0);
|
||||
$time = time();
|
||||
$checking = '0';
|
||||
if ($time > $lastLicenseCheck + 604800) $checking = '1';
|
||||
if (empty($lastLicenseCheck)) $lastLicenseCheck = $time;
|
||||
|
||||
$header .= '<div class="cell grid-x align-right large-shrink">';
|
||||
$header .= acym_tooltip(
|
||||
'<a id="checkVersionButton" type="button" class="button button-secondary medium-shrink" data-check="'.$checking.'">'.acym_translation('ACYM_CHECK_MY_VERSION').'</a>',
|
||||
acym_translation('ACYM_LAST_CHECK').' <span id="acym__check__version__last__check">'.acym_date($lastLicenseCheck, 'Y/m/d H:i').'</span>'
|
||||
);
|
||||
|
||||
$url = ACYM_UPDATEMEURL.'doc&task=doc&product=acymailing&for='.(empty($_REQUEST['ctrl']) ? 'dashboard' : $_REQUEST['ctrl']).'-'.$_REQUEST['layout'];
|
||||
$header .= '<a type="button" class="button medium-shrink" target="_blank" href="'.$url.'">'.acym_translation('ACYM_DOCUMENTATION').'</a>';
|
||||
$header .= '</div></div>';
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function checkVersionArea()
|
||||
{
|
||||
$config = acym_config();
|
||||
|
||||
$currentLevel = $config->get('level', '');
|
||||
$currentVersion = $config->get('version', '');
|
||||
$latestVersion = $config->get('latestversion', '');
|
||||
|
||||
$version = '<div id="acym_level_version_area" class="text-right">';
|
||||
$version .= '<div id="acym_level">'.ACYM_NAME.' '.$currentLevel.' ';
|
||||
|
||||
if (version_compare($currentVersion, $latestVersion, '>=')) {
|
||||
$version .= acym_tooltip('<span class="acym__color__green">'.$currentVersion.'</span>', acym_translation('ACYM_UP_TO_DATE'));
|
||||
} elseif (!empty($latestVersion)) {
|
||||
if ('wordpress' === ACYM_CMS) {
|
||||
$downloadLink = admin_url().'update-core.php';
|
||||
} else {
|
||||
$downloadLink = ACYM_REDIRECT.'update-acymailing-'.$currentLevel.'&version='.$config->get('version').'" target="_blank';
|
||||
}
|
||||
$version .= acym_tooltip(
|
||||
'<span class="acy_updateversion acym__color__red">'.$currentVersion.'</span>',
|
||||
acym_translation_sprintf('ACYM_CLICK_UPDATE', $latestVersion),
|
||||
'',
|
||||
acym_translation('ACYM_OLD_VERSION'),
|
||||
$downloadLink
|
||||
);
|
||||
}
|
||||
|
||||
$version .= '</div></div>';
|
||||
|
||||
if (!acym_level(1)) return $version;
|
||||
|
||||
$expirationDate = $config->get('expirationdate', 0);
|
||||
if (empty($expirationDate) || $expirationDate == -1) return $version;
|
||||
|
||||
$version .= '<div id="acym_expiration" class="text-right cell">';
|
||||
if ($expirationDate == -2) {
|
||||
$version .= '<div class="acylicence_expired">
|
||||
<a class="acy_attachlicence acymbuttons acym__color__red" href="'.ACYM_REDIRECT.'acymailing-assign" target="_blank">'.acym_translation('ACYM_ATTACH_LICENCE').'</a>
|
||||
</div>';
|
||||
} elseif ($expirationDate < time()) {
|
||||
$version .= acym_tooltip(
|
||||
'<span class="acy_subscriptionexpired acym__color__red">'.acym_translation('ACYM_SUBSCRIPTION_EXPIRED').'</span>',
|
||||
acym_translation('ACYM_SUBSCRIPTION_EXPIRED_LINK'),
|
||||
'',
|
||||
'',
|
||||
ACYM_REDIRECT.'renew-acymailing-'.$currentLevel
|
||||
);
|
||||
} else {
|
||||
$version .= '<div class="acylicence_valid">
|
||||
<span class="acy_subscriptionok acym__color__green">'.acym_translation_sprintf('ACYM_VALID_UNTIL', acym_getDate($expirationDate, acym_translation('ACYM_DATE_FORMAT_LC4'))).'</span>
|
||||
</div>';
|
||||
}
|
||||
$version .= '</div>';
|
||||
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
|
||||
3406
deployed/acym/administrator/components/com_acym/helpers/helper.php
Normal file
3406
deployed/acym/administrator/components/com_acym/helpers/helper.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymimageHelper
|
||||
{
|
||||
var $error;
|
||||
var $maxHeight;
|
||||
var $maxWidth;
|
||||
var $destination;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function removePictures($text)
|
||||
{
|
||||
$return = preg_replace('#< *img[^>]*>#Ui', '', $text);
|
||||
$return = preg_replace('#< *div[^>]*class="jce_caption"[^>]*>[^<]*(< *div[^>]*>[^<]*<\/div>)*[^<]*<\/div>#Ui', '', $return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function available()
|
||||
{
|
||||
if (!function_exists('gd_info')) {
|
||||
$this->error = 'The GD library is not installed.';
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!function_exists('getimagesize')) {
|
||||
$this->error = 'Cound not find getimagesize function';
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!function_exists('imagealphablending')) {
|
||||
$this->error = "Please make sure you're using GD 2.0.1 or later version";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function resizePictures($input)
|
||||
{
|
||||
$this->destination = ACYM_MEDIA.'resized'.DS;
|
||||
acym_createDir($this->destination);
|
||||
$content = acym_absoluteURL($input);
|
||||
|
||||
preg_match_all('#<img([^>]*)>#Ui', $content, $results);
|
||||
if (empty($results[1])) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
$replace = [];
|
||||
|
||||
foreach ($results[1] as $onepicture) {
|
||||
if (strpos($onepicture, 'donotresize') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) {
|
||||
continue;
|
||||
}
|
||||
$imageUrl = $path[1];
|
||||
|
||||
$base = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', ACYM_LIVE);
|
||||
$replacements = ['https://www.'.$base, 'http://www.'.$base, 'https://'.$base, 'http://'.$base];
|
||||
foreach ($replacements as $oneReplacement) {
|
||||
if (strpos($imageUrl, $oneReplacement) === false) {
|
||||
continue;
|
||||
}
|
||||
$imageUrl = str_replace([$oneReplacement, '/'], [ACYM_ROOT, DS], urldecode($imageUrl));
|
||||
break;
|
||||
}
|
||||
|
||||
$newPicture = $this->generateThumbnail($imageUrl);
|
||||
|
||||
if (!$newPicture) {
|
||||
$newDimension = 'max-width:'.$this->maxWidth.'px;max-height:'.$this->maxHeight.'px;';
|
||||
if (strpos($onepicture, 'style="') !== false) {
|
||||
$replace[$onepicture] = preg_replace('#style="([^"]*)"#Uis', 'style="'.$newDimension.'$1"', $onepicture);
|
||||
} else {
|
||||
$replace[$onepicture] = ' style="'.$newDimension.'" '.$onepicture;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$newPicture['file'] = preg_replace('#^'.preg_quote(ACYM_ROOT, '#').'#i', ACYM_LIVE, $newPicture['file']);
|
||||
$newPicture['file'] = str_replace(DS, '/', $newPicture['file']);
|
||||
$replaceImage = [];
|
||||
$replaceImage[$path[1]] = $newPicture['file'];
|
||||
if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) {
|
||||
foreach ($resultsSize[0] as $i => $oneArg) {
|
||||
$newVal = (strtolower($resultsSize[1][$i]) == 'width') ? $newPicture['width'] : $newPicture['height'];
|
||||
if ($newVal > $resultsSize[3][$i]) {
|
||||
continue;
|
||||
}
|
||||
$replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg);
|
||||
}
|
||||
}
|
||||
|
||||
$replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture);
|
||||
}
|
||||
|
||||
if (!empty($replace)) {
|
||||
$input = str_replace(array_keys($replace), $replace, $content);
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
function generateThumbnail($picturePath)
|
||||
{
|
||||
|
||||
list($currentwidth, $currentheight) = getimagesize($picturePath);
|
||||
if (empty($currentwidth) || empty($currentheight)) {
|
||||
return false;
|
||||
}
|
||||
$factor = min($this->maxWidth / $currentwidth, $this->maxHeight / $currentheight);
|
||||
if ($factor >= 1) {
|
||||
return false;
|
||||
}
|
||||
$newWidth = round($currentwidth * $factor);
|
||||
$newHeight = round($currentheight * $factor);
|
||||
|
||||
if (strpos($picturePath, 'http') === 0) {
|
||||
$filename = substr($picturePath, strrpos($picturePath, '/') + 1);
|
||||
} else {
|
||||
$filename = basename($picturePath);
|
||||
}
|
||||
|
||||
if (substr($picturePath, 0, 10) == 'data:image') {
|
||||
preg_match('#data:image/([^;]{1,5});#', $picturePath, $resultextension);
|
||||
if (empty($resultextension[1])) {
|
||||
return false;
|
||||
}
|
||||
$extension = $resultextension[1];
|
||||
$name = md5($picturePath);
|
||||
} else {
|
||||
$extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
|
||||
$name = strtolower(substr($filename, 0, strrpos($filename, '.')));
|
||||
$name .= substr(@filemtime($picturePath), -4);
|
||||
}
|
||||
|
||||
$newImage = md5($picturePath).'-'.$name.'thumb'.$this->maxWidth.'x'.$this->maxHeight.'.'.$extension;
|
||||
if (empty($this->destination)) {
|
||||
$newFile = dirname($picturePath).DS.$newImage;
|
||||
} else {
|
||||
$newFile = $this->destination.$newImage;
|
||||
}
|
||||
|
||||
if (file_exists($newFile)) {
|
||||
return ['file' => $newFile, 'width' => $newWidth, 'height' => $newHeight];
|
||||
}
|
||||
|
||||
switch ($extension) {
|
||||
case 'gif':
|
||||
$img = ImageCreateFromGIF($picturePath);
|
||||
break;
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$img = ImageCreateFromJPEG($picturePath);
|
||||
break;
|
||||
case 'png':
|
||||
$img = ImageCreateFromPNG($picturePath);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
$thumb = ImageCreateTrueColor($newWidth, $newHeight);
|
||||
|
||||
if (in_array($extension, ['gif', 'png'])) {
|
||||
imagealphablending($thumb, false);
|
||||
imagesavealpha($thumb, true);
|
||||
}
|
||||
|
||||
if (function_exists("imagecopyresampled")) {
|
||||
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newWidth, $newHeight, $currentwidth, $currentheight);
|
||||
} else {
|
||||
ImageCopyResized($thumb, $img, 0, 0, 0, 0, $newWidth, $newHeight, $currentwidth, $currentheight);
|
||||
}
|
||||
ob_start();
|
||||
switch ($extension) {
|
||||
case 'gif':
|
||||
$status = imagegif($thumb);
|
||||
break;
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$status = imagejpeg($thumb, null, 100);
|
||||
break;
|
||||
case 'png':
|
||||
$status = imagepng($thumb, null, 0);
|
||||
break;
|
||||
}
|
||||
$imageContent = ob_get_clean();
|
||||
$status = $status && acym_writeFile($newFile, $imageContent);
|
||||
imagedestroy($thumb);
|
||||
imagedestroy($img);
|
||||
|
||||
if (!$status) {
|
||||
$newFile = $picturePath;
|
||||
}
|
||||
|
||||
return ['file' => $newFile, 'width' => $newWidth, 'height' => $newHeight];
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,915 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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 acymimportHelper
|
||||
{
|
||||
var $importUserInLists = [];
|
||||
var $totalInserted = 0;
|
||||
var $totalTry = 0;
|
||||
var $totalValid = 0;
|
||||
var $allSubid = [];
|
||||
var $db;
|
||||
var $dispatcher;
|
||||
var $forceconfirm = false;
|
||||
var $charsetConvert;
|
||||
var $generatename = true;
|
||||
var $overwrite = false;
|
||||
var $importblocked = false;
|
||||
var $removeSep = 0;
|
||||
var $dispresults = true;
|
||||
|
||||
var $tablename = '';
|
||||
var $equFields = [];
|
||||
var $dbwhere = []; //handle where on import via filter to only import new users for example
|
||||
|
||||
var $subscribedUsers = [];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
acym_increasePerf();
|
||||
|
||||
global $acymCmsUserVars;
|
||||
$this->cmsUserVars = $acymCmsUserVars;
|
||||
}
|
||||
|
||||
|
||||
function file()
|
||||
{
|
||||
$importFile = acym_getVar('array', 'import_file', [], 'files');
|
||||
|
||||
if (empty($importFile['name'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_PLEASE_BROWSE_FILE_IMPORT'), 'error', 7000);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$extension = strtolower(acym_fileGetExt($importFile['name']));
|
||||
$config = acym_config();
|
||||
|
||||
if (!preg_match('#^(csv)$#Ui', $extension) || preg_match('#\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)$#Ui', $importFile['name'])) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACCEPTED_TYPE', acym_escape($extension), $config->get('allowed_files')), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$fileError = $importFile['error'];
|
||||
if ($fileError > 0) {
|
||||
switch ($fileError) {
|
||||
case 1:
|
||||
case 2:
|
||||
acym_enqueueNotification(acym_translation('ACYM_UPLOADED_FILE_EXCEED_MAX_FILESIZE_PHP'), 'error');
|
||||
|
||||
return false;
|
||||
case 3:
|
||||
acym_enqueueNotification(acym_translation('ACYM_FILE_UPLOADED_PARTIALLY'), 'error');
|
||||
|
||||
return false;
|
||||
case 4:
|
||||
acym_enqueueNotification(acym_translation('ACYM_NO_FILE_WAS_UPLOADED'), 'error');
|
||||
|
||||
return false;
|
||||
default:
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_UNKNOWN_ERROR_UPLOADING_FILE', $fileError), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$uploadPath = $this->_createUploadFolder();
|
||||
|
||||
$attachment = new stdClass();
|
||||
$attachment->filename = uniqid('import_').'.csv';
|
||||
acym_setVar('filename', $attachment->filename);
|
||||
|
||||
$attachment->size = $importFile['size'];
|
||||
|
||||
if (!acym_uploadFile($importFile['tmp_name'], $uploadPath.$attachment->filename)) {
|
||||
if (!move_uploaded_file($importFile['tmp_name'], $uploadPath.$attachment->filename)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_FAIL_UPLOAD', '<b><i>'.acym_escape($importFile['tmp_name']).'</i></b>', '<b><i>'.acym_escape($uploadPath.$attachment->filename).'</i></b>'), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function textarea()
|
||||
{
|
||||
$content = acym_getVar('string', 'acym__users__import__from_text__textarea');
|
||||
$path = $this->_createUploadFolder();
|
||||
$filename = uniqid('import_').'.csv';
|
||||
|
||||
acym_writeFile($path.$filename, $content);
|
||||
acym_setVar('filename', $filename);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function cms()
|
||||
{
|
||||
$query = 'UPDATE IGNORE '.$this->cmsUserVars->table.' as b, #__acym_user as a SET a.email = b.'.$this->cmsUserVars->email.', a.name = b.'.$this->cmsUserVars->name.', a.active = 1 - b.'.$this->cmsUserVars->blocked.' WHERE a.cms_id = b.'.$this->cmsUserVars->id.' AND a.cms_id IS NOT NULL';
|
||||
$nbUpdated = acym_query($query);
|
||||
|
||||
$query = 'UPDATE IGNORE '.$this->cmsUserVars->table.' as b, #__acym_user as a SET a.cms_id = b.'.$this->cmsUserVars->id.' WHERE a.email = b.'.$this->cmsUserVars->email;
|
||||
$affected = acym_query($query);
|
||||
$nbUpdated += intval($affected);
|
||||
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_UPDATE', $nbUpdated), 'success', 7000);
|
||||
|
||||
$query = 'SELECT a.id FROM #__acym_user as a LEFT JOIN '.$this->cmsUserVars->table.' as b on a.cms_id = b.'.$this->cmsUserVars->id.' WHERE b.'.$this->cmsUserVars->id.' IS NULL AND a.cms_id > 0';
|
||||
$deletedSubid = acym_loadResultArray($query);
|
||||
|
||||
$query = 'SELECT a.id FROM #__acym_user as a LEFT JOIN '.$this->cmsUserVars->table.' as b on a.email = b.'.$this->cmsUserVars->email.' WHERE b.'.$this->cmsUserVars->id.' IS NULL AND a.cms_id > 0';
|
||||
$deletedSubid = array_merge(acym_loadResultArray($query), $deletedSubid);
|
||||
|
||||
if (!empty($deletedSubid)) {
|
||||
$userClass = acym_get('class.user');
|
||||
$deletedUsers = $userClass->delete($deletedSubid);
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_DELETE', $deletedUsers), 'success', 7000);
|
||||
}
|
||||
|
||||
|
||||
$time = time();
|
||||
$query = 'INSERT IGNORE INTO #__acym_user (`name`,`email`,`creation_date`,`active`,`cms_id`, `source`) SELECT `'.$this->cmsUserVars->name.'`,`'.$this->cmsUserVars->email.'`,`'.$this->cmsUserVars->registered.'`,1 - '.$this->cmsUserVars->blocked.',`'.$this->cmsUserVars->id.'`,\'import_'.$time.'\' FROM '.$this->cmsUserVars->table;
|
||||
$insertedUsers = acym_query($query);
|
||||
|
||||
acym_query('UPDATE #__acym_configuration SET `value` = '.intval($time).' WHERE `name` = \'last_import\'');
|
||||
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_NEW', $insertedUsers), 'success', 7000);
|
||||
|
||||
$lists = $this->getImportedLists();
|
||||
$listsSubscribe = [];
|
||||
if (!empty($lists)) {
|
||||
foreach ($lists as $listid => $val) {
|
||||
if (!empty($val)) {
|
||||
$listsSubscribe[] = intval($listid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($listsSubscribe)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = 'INSERT IGNORE INTO #__acym_user_has_list (`user_id`,`list_id`,`status`,`subscription_date`) ';
|
||||
$query .= 'SELECT user.`id`, list.`id`, 1, '.acym_escapeDB(date('Y-m-d H:i:s', time())).' FROM #__acym_list AS list, #__acym_user AS user WHERE list.`id` IN ('.implode(',', $listsSubscribe).') AND user.`cms_id` > 0';
|
||||
$nbsubscribed = acym_query($query);
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_SUBSCRIPTION', $nbsubscribed), 5000);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function database()
|
||||
{
|
||||
$this->forceconfirm = acym_getVar('int', 'import_confirmed_database');
|
||||
|
||||
$table = trim(acym_getVar('string', 'tablename'));
|
||||
$time = time();
|
||||
|
||||
if (empty($table)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SPECIFYTABLE'), 'warning', 5000);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = acym_getColumns($table, false, false);
|
||||
if (empty($fields)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SPECIFYTABLE'), 'warning', 5000);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$equivalentFields = acym_getVar('array', 'fields', []);
|
||||
|
||||
if (empty($equivalentFields['email'])) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_SPECIFYFIELDEMAIL'), 'warning', 5000);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$select = [];
|
||||
foreach ($equivalentFields as $acyField => $tableField) {
|
||||
$tableField = trim($tableField);
|
||||
if (empty($tableField)) {
|
||||
continue;
|
||||
}
|
||||
if (!in_array($tableField, $fields)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_SPECIFYFIELD', $tableField, implode(' <br> ', $fields)), 'warning', 5000);
|
||||
|
||||
return false;
|
||||
}
|
||||
$select['`'.acym_secureDBColumn($acyField).'`'] = acym_secureDBColumn($tableField);
|
||||
}
|
||||
|
||||
if (empty($select['`creation_date`'])) {
|
||||
$select['`creation_date`'] = acym_escapeDB(acym_date('now', 'Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
if ($this->forceconfirm && empty($select['`confirmed`'])) {
|
||||
$select['`confirmed`'] = 1;
|
||||
}
|
||||
|
||||
$select['`source`'] = acym_escapeDB("import_".$time);
|
||||
|
||||
$query = 'INSERT IGNORE INTO #__acym_user ('.implode(' , ', array_keys($select)).') SELECT '.implode(' , ', $select).' FROM '.acym_secureDBColumn($table).' WHERE '.acym_secureDBColumn($select['`email`']).' LIKE "%@%"';
|
||||
if (!empty($this->dbwhere)) {
|
||||
$query .= ' AND ( '.implode(' ) AND (', $this->dbwhere).' )';
|
||||
}
|
||||
|
||||
$affectedRows = acym_query($query);
|
||||
|
||||
acym_query('UPDATE #__acym_configuration SET `value` = '.intval($time).' WHERE `name` = "last_import"');
|
||||
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_NEW', $affectedRows), "success", 5000);
|
||||
|
||||
$lists = $this->getImportedLists();
|
||||
$listsSubscribe = [];
|
||||
if (!empty($lists)) {
|
||||
foreach ($lists as $listid => $val) {
|
||||
if (!empty($val)) {
|
||||
$listsSubscribe[] = intval($listid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($listsSubscribe)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = 'INSERT IGNORE INTO #__acym_user_has_list (`user_id`,`list_id`,`status`,`subscription_date`) ';
|
||||
$query .= 'SELECT user.`id`, list.`id`, 1, '.acym_escapeDB(date('Y-m-d H:i:s', time())).' FROM #__acym_list AS list, #__acym_user AS user WHERE list.`id` IN ('.implode(',', $listsSubscribe).') AND user.`source` LIKE "%'.$time.'%"';
|
||||
$nbsubscribed = acym_query($query);
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_SUBSCRIPTION', $nbsubscribed), 5000);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _createUploadFolder()
|
||||
{
|
||||
$folderPath = acym_cleanPath(ACYM_ROOT.trim(html_entity_decode(str_replace('/', DS, ACYM_MEDIA_FOLDER).DS.'import'))).DS;
|
||||
if (!is_dir($folderPath)) {
|
||||
acym_createDir($folderPath, true, true);
|
||||
}
|
||||
|
||||
if (!is_writable($folderPath)) {
|
||||
@chmod($folderPath, '0755');
|
||||
if (!is_writable($folderPath)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_WRITABLE_FOLDER', $folderPath), 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
return $folderPath;
|
||||
}
|
||||
|
||||
function finalizeImport()
|
||||
{
|
||||
$filename = strtolower(acym_getVar('cmd', 'filename'));
|
||||
$extension = '.'.acym_fileGetExt($filename);
|
||||
$this->forceconfirm = acym_getVar('int', 'import_confirmed_generic');
|
||||
$this->generatename = acym_getVar('int', 'import_generate_generic');
|
||||
$this->overwrite = acym_getVar('int', 'import_overwrite_generic');
|
||||
$filename = str_replace(['.', ' '], '_', substr($filename, 0, strpos($filename, $extension))).$extension;
|
||||
$uploadPath = ACYM_MEDIA.'import'.DS.$filename;
|
||||
|
||||
if (!file_exists($uploadPath)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_UPLOADED_FILE_NOT_FOUND').' '.$uploadPath, 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$importColumns = acym_getVar('string', 'import_columns');
|
||||
if (empty($importColumns)) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_COLUMNS_NOT_FOUND'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$contentFile = file_get_contents($uploadPath);
|
||||
|
||||
if (acym_getVar('cmd', 'acyencoding', '') != '') {
|
||||
$encodingHelper = acym_get('helper.encoding');
|
||||
$contentFile = $encodingHelper->change($contentFile, acym_getVar('cmd', 'acyencoding'), 'UTF-8');
|
||||
}
|
||||
|
||||
$cutContent = str_replace(["\r\n", "\r"], "\n", $contentFile);
|
||||
$allLines = explode("\n", $cutContent);
|
||||
|
||||
$listSeparators = ["\t", ';', ','];
|
||||
$separator = ',';
|
||||
foreach ($listSeparators as $sep) {
|
||||
if (strpos($allLines[0], $sep) !== false) {
|
||||
$separator = $sep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($listsId)) {
|
||||
$allLines[0] .= $sep.'';
|
||||
}
|
||||
|
||||
$importColumns = str_replace(',', $separator, $importColumns);
|
||||
|
||||
if (strpos($allLines[0], '@')) {
|
||||
$contentFile = $importColumns."\n".$contentFile;
|
||||
} else {
|
||||
$allLines[0] = $importColumns;
|
||||
$contentFile = implode("\n", $allLines);
|
||||
}
|
||||
|
||||
$this->_handleContent($contentFile);
|
||||
|
||||
unlink($uploadPath);
|
||||
$this->_cleanImportFolder();
|
||||
}
|
||||
|
||||
public function _handleContent(&$contentFile)
|
||||
{
|
||||
$success = true;
|
||||
$timestamp = time();
|
||||
|
||||
$contentFile = str_replace(["\r\n", "\r"], "\n", $contentFile);
|
||||
$importLines = explode("\n", $contentFile);
|
||||
|
||||
$i = 0;
|
||||
$this->header = '';
|
||||
$this->allSubid = [];
|
||||
while (empty($this->header) && $i < 10) {
|
||||
$this->header = trim($importLines[$i]);
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (strpos($this->header, '@') && !strpos($this->header, ',') && !strpos($this->header, ';') && !strpos($this->header, "\t")) {
|
||||
$this->header = 'email';
|
||||
$i--;
|
||||
}
|
||||
|
||||
if (!$this->_autoDetectHeader()) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_HEADER', acym_escape($this->header)), 'error');
|
||||
acym_enqueueNotification(acym_translation('ACYM_IMPORT_EMAIL'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$numberColumns = count($this->columns);
|
||||
|
||||
$encodingHelper = acym_get('helper.encoding');
|
||||
|
||||
$importUsers = [];
|
||||
|
||||
$errorLines = [];
|
||||
|
||||
$errorMessageInvalidEmails = "";
|
||||
|
||||
$userClass = acym_get('class.user');
|
||||
|
||||
$countUsersBeforeImport = $userClass->getCountTotalUsers();
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$allLists = $listClass->getAll('name');
|
||||
|
||||
while (isset($importLines[$i])) {
|
||||
if (strpos($importLines[$i], '"') !== false) {
|
||||
$data = [];
|
||||
$j = $i + 1;
|
||||
$position = -1;
|
||||
|
||||
while ($j < ($i + 30)) {
|
||||
|
||||
$quoteOpened = substr($importLines[$i], $position + 1, 1) == '"';
|
||||
|
||||
if ($quoteOpened) {
|
||||
$nextQuotePosition = strpos($importLines[$i], '"', $position + 2);
|
||||
while ($nextQuotePosition !== false && $nextQuotePosition + 1 != strlen($importLines[$i]) && substr($importLines[$i], $nextQuotePosition + 1, 1) != $this->separator) {
|
||||
$nextQuotePosition = strpos($importLines[$i], '"', $nextQuotePosition + 1);
|
||||
}
|
||||
if ($nextQuotePosition === false) {
|
||||
if (!isset($importLines[$j])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$importLines[$i] .= "\n".$importLines[$j];
|
||||
$importLines[$i] = rtrim($importLines[$i], $this->separator);
|
||||
unset($importLines[$j]);
|
||||
$j++;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
if (strlen($importLines[$i]) - 1 == $nextQuotePosition) {
|
||||
$data[] = substr($importLines[$i], $position + 1);
|
||||
break;
|
||||
}
|
||||
$data[] = substr($importLines[$i], $position + 1, $nextQuotePosition + 1 - ($position + 1));
|
||||
$position = $nextQuotePosition + 1;
|
||||
}
|
||||
} else {
|
||||
$nextSeparatorPosition = strpos($importLines[$i], $this->separator, $position + 1);
|
||||
if ($nextSeparatorPosition === false) {
|
||||
$data[] = substr($importLines[$i], $position + 1);
|
||||
break;
|
||||
} else { // If found the next separator, add the value in $data and change the position
|
||||
$data[] = substr($importLines[$i], $position + 1, $nextSeparatorPosition - ($position + 1));
|
||||
$position = $nextSeparatorPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$importLines = array_merge($importLines);
|
||||
} else {
|
||||
$data = explode($this->separator, rtrim(trim($importLines[$i]), $this->separator));
|
||||
}
|
||||
|
||||
if (!empty($this->removeSep)) {
|
||||
for ($b = $numberColumns + $this->removeSep - 1 ; $b >= $numberColumns ; $b--) {
|
||||
if (isset($data[$b]) && (strlen($data[$b]) == 0 || $data[$b] == ' ')) {
|
||||
unset($data[$b]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
if (empty($importLines[$i - 1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->totalTry++;
|
||||
if (count($data) > $numberColumns) {
|
||||
$copy = $data;
|
||||
foreach ($copy as $oneelem => $oneval) {
|
||||
if (!empty($oneval[0]) && $oneval[0] == '"' && $oneval[strlen($oneval) - 1] != '"' && isset($copy[$oneelem + 1]) && $copy[$oneelem + 1][strlen($copy[$oneelem + 1]) - 1] == '"') {
|
||||
$data[$oneelem] = $copy[$oneelem].$this->separator.$copy[$oneelem + 1];
|
||||
unset($data[$oneelem + 1]);
|
||||
}
|
||||
}
|
||||
$data = array_values($data);
|
||||
}
|
||||
|
||||
if (count($data) < $numberColumns) {
|
||||
for ($a = count($data) ; $a < $numberColumns ; $a++) {
|
||||
$data[$a] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($data) != $numberColumns) {
|
||||
$success = false;
|
||||
static $errorcount = 0;
|
||||
if (empty($errorcount)) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_ARGUMENTS', $numberColumns), 'warning');
|
||||
}
|
||||
$errorcount++;
|
||||
|
||||
if ($this->totalTry == 1) {
|
||||
return false;
|
||||
}
|
||||
if (empty($errorLines)) {
|
||||
$errorLines[] = 'error,'.$importLines[0];
|
||||
}
|
||||
$errorLines[] = acym_translation('ACYM_IMPORT_ERROR_WRONG_NUMBER_ARGUMENTS').','.$importLines[$i - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
$newUser = new stdClass();
|
||||
$newUser->customfields = [];
|
||||
|
||||
$emailKey = array_search('email', $this->columns);
|
||||
$newUser->email = trim(strip_tags($data[$emailKey]), '\'" ');
|
||||
if (!empty($newUser->email)) {
|
||||
$newUser->email = acym_punycode($newUser->email);
|
||||
}
|
||||
$newUser->email = trim(str_replace([' ', "\t"], '', $encodingHelper->change($newUser->email, 'UTF-8', 'ISO-8859-1')));
|
||||
|
||||
|
||||
if (!acym_isValidEmail($newUser->email)) {
|
||||
$success = false;
|
||||
static $errorcountfail = 0;
|
||||
if ($errorcountfail == 0) {
|
||||
acym_enqueueNotification(acym_translation('ACYM_ADDRESSES_INVALID'), 'warning');
|
||||
}
|
||||
$errorcountfail++;
|
||||
if (empty($errorLines)) {
|
||||
$errorLines[] = 'error,'.$importLines[0];
|
||||
}
|
||||
$errorLines[] = acym_translation('ACYM_INVALID_EMAIL_ADDRESS').','.$importLines[$i - 1];
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($data as $num => $value) {
|
||||
if ($num == $emailKey) continue;
|
||||
|
||||
$field = $this->columns[$num];
|
||||
|
||||
if ($field == 1) continue;
|
||||
|
||||
if ($field == 'listids') {
|
||||
$liststosub = explode('-', trim($value, '\'" '));
|
||||
foreach ($liststosub as $onelistid) {
|
||||
$this->importUserInLists[intval(trim($onelistid))][] = acym_escapeDB($newUser->email);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'listname') {
|
||||
$liststosub = explode('-', trim($value, '\'" '));
|
||||
foreach ($liststosub as $onelistName) {
|
||||
if (empty($onelistName)) {
|
||||
continue;
|
||||
}
|
||||
$onelistName = trim($onelistName);
|
||||
if (empty($allLists[$onelistName])) {
|
||||
$newList = new stdClass();
|
||||
$newList->name = $onelistName;
|
||||
$newList->active = 1;
|
||||
$colors = ['#3366ff', '#7240A4', '#7A157D', '#157D69', '#ECE649'];
|
||||
$newList->color = $colors[rand(0, count($colors) - 1)];
|
||||
$listid = $listClass->save($newList);
|
||||
$newList->id = $listid;
|
||||
$allLists[$onelistName] = $newList;
|
||||
}
|
||||
$this->importUserInLists[intval($allLists[$onelistName]->id)][] = acym_escapeDB($newUser->email);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($field, 'cf_') === 0) {
|
||||
$newUser->customfields[substr($field, 3)] = trim(strip_tags($value), '\'" ');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value == 'null') {
|
||||
$newUser->$field = '';
|
||||
} else {
|
||||
$newUser->$field = trim(strip_tags($value), '\'" ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$importUsers[] = $newUser;
|
||||
$this->totalValid++;
|
||||
|
||||
if ($this->totalValid % 50 == 0) {
|
||||
$this->_insertUsers($importUsers, $timestamp);
|
||||
$importUsers = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errorLines)) {
|
||||
$filename = strtolower(acym_getVar('cmd', 'filename', ''));
|
||||
if (!empty($filename)) {
|
||||
$extension = '.'.acym_fileGetExt($filename);
|
||||
$filename = str_replace(['.', ' '], '_', substr($filename, 0, strpos($filename, $extension))).$extension;
|
||||
$errorFile = implode("\n", $errorLines);
|
||||
acym_writeFile(ACYM_MEDIA.'import'.DS.'error_'.$filename, $errorFile);
|
||||
acym_enqueueNotification('<a target="_blank" href="'.acym_completeLink('users&task=downloadImport').'&filename=error_'.preg_replace('#\.[^.]*$#', '', $filename).'&'.acym_noTemplate().'" >'.acym_translation('ACYM_DOWNLOAD_IMPORT_ERRORS').'</a>', 'notice');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_insertUsers($importUsers, $timestamp);
|
||||
|
||||
$countUsersAfterImport = $userClass->getCountTotalUsers();
|
||||
$this->totalInserted = $countUsersAfterImport - $countUsersBeforeImport;
|
||||
|
||||
if ($this->dispresults) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_REPORT', $this->totalTry, $this->totalInserted, $this->totalTry - $this->totalValid, $this->totalValid - $this->totalInserted));
|
||||
}
|
||||
|
||||
$this->_subscribeUsers();
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
function _insertUsers($users, $timestamp)
|
||||
{
|
||||
if (empty($users)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$importedCols = array_keys(get_object_vars($users[0]));
|
||||
unset($importedCols[array_search('customfields', $importedCols)]);
|
||||
if ($this->forceconfirm) $importedCols[] = 'confirmed';
|
||||
|
||||
foreach ($users as $a => $oneUser) {
|
||||
$this->_checkData($users[$a], $timestamp);
|
||||
}
|
||||
|
||||
$columns = reset($users);
|
||||
$colNames = array_keys(get_object_vars($columns));
|
||||
unset($colNames[array_search('customfields', $colNames)]);
|
||||
|
||||
if (!in_array('key', $colNames)) $colNames[] = 'key';
|
||||
|
||||
foreach ($colNames as $oneColumn) {
|
||||
acym_secureDBColumn($oneColumn);
|
||||
}
|
||||
|
||||
$queryInsertUsers = 'INSERT'.($this->overwrite ? '' : ' IGNORE').' INTO #__acym_user (`'.implode('`,`', $colNames).'`) VALUES (';
|
||||
$values = [];
|
||||
$customFieldsvalues = [];
|
||||
$allemails = [];
|
||||
foreach ($users as $a => $oneUser) {
|
||||
$value = [];
|
||||
|
||||
acym_trigger('onAcymBeforeUserImport', [&$oneUser]);
|
||||
foreach ($oneUser as $map => $oneValue) {
|
||||
if ($map == 'customfields') continue;
|
||||
|
||||
$oneValue = htmlspecialchars_decode($oneValue, ENT_QUOTES);
|
||||
|
||||
if ($map == 'active' && !empty($this->importblocked) && $this->importblocked == true) {
|
||||
$value[] = 0;
|
||||
} else {
|
||||
if ($map != 'id') {
|
||||
$oneValue = acym_escapeDB($oneValue);
|
||||
if ($map == 'email') $allemails[] = $oneValue;
|
||||
} else {
|
||||
$oneValue = intval($oneValue);
|
||||
}
|
||||
|
||||
$value[] = $oneValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($oneUser->key)) $value[] = acym_escapeDB(acym_generateKey(14));
|
||||
$values[] = implode(',', $value);
|
||||
|
||||
if (!empty($oneUser->customfields)) $customFieldsvalues[$oneUser->email] = $oneUser->customfields;
|
||||
}
|
||||
|
||||
$queryInsertUsers .= implode('),(', $values).')';
|
||||
|
||||
if ($this->overwrite) {
|
||||
$queryInsertUsers .= ' ON DUPLICATE KEY UPDATE ';
|
||||
foreach ($importedCols as &$oneColumn) {
|
||||
acym_secureDBColumn($oneColumn);
|
||||
if ($oneColumn == 'key') {
|
||||
$oneColumn = '`'.$oneColumn.'` = `'.$oneColumn.'`';
|
||||
} else {
|
||||
$oneColumn = '`'.$oneColumn.'` = VALUES(`'.$oneColumn.'`)';
|
||||
}
|
||||
}
|
||||
$queryInsertUsers .= implode(',', $importedCols);
|
||||
}
|
||||
|
||||
acym_query($queryInsertUsers);
|
||||
|
||||
acym_query('UPDATE #__acym_configuration SET `value` = '.intval($timestamp).' WHERE `name` = \'last_import\'');
|
||||
|
||||
$importedUsers = acym_loadObjectList('SELECT id, email FROM #__acym_user WHERE email IN ('.implode(',', $allemails).')', 'id');
|
||||
|
||||
if (!empty($customFieldsvalues)) {
|
||||
$insertValues = [];
|
||||
foreach ($importedUsers as $one) {
|
||||
if (empty($customFieldsvalues[$one->email])) continue;
|
||||
|
||||
foreach ($customFieldsvalues[$one->email] as $fieldId => $value) {
|
||||
$value = htmlspecialchars_decode($value, ENT_QUOTES);
|
||||
$insertValues[] = '('.intval($one->id).','.intval($fieldId).','.acym_escapeDB($value).')';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($insertValues)) {
|
||||
$queryInsertCustomFields = 'INSERT'.($this->overwrite ? '' : ' IGNORE').' INTO #__acym_user_has_field (`user_id`, `field_id`, `value`) VALUES '.implode(',', $insertValues);
|
||||
if ($this->overwrite) $queryInsertCustomFields .= ' ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)';
|
||||
acym_query($queryInsertCustomFields);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->allSubid = array_merge($this->allSubid, array_keys($importedUsers));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _checkData(&$user, $timestamp)
|
||||
{
|
||||
if (empty($user->creation_date)) {
|
||||
$user->creation_date = time();
|
||||
}
|
||||
|
||||
if (is_numeric($user->creation_date)) {
|
||||
$user->creation_date = date('Y-m-d H:i:s', $user->creation_date);
|
||||
}
|
||||
|
||||
if (!isset($user->active) || strlen($user->active) == 0) {
|
||||
$user->active = 1;
|
||||
}
|
||||
|
||||
if ((!isset($user->confirmed) || strlen($user->confirmed) == 0) && $this->forceconfirm) {
|
||||
$user->confirmed = 1;
|
||||
}
|
||||
|
||||
if (empty($user->source)) {
|
||||
$user->source = 'import_'.$timestamp;
|
||||
}
|
||||
|
||||
if (empty($user->name) && $this->generatename) {
|
||||
$user->name = ucwords(trim(str_replace(['.', '_', '-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], ' ', substr($user->email, 0, strpos($user->email, '@')))));
|
||||
}
|
||||
}
|
||||
|
||||
function _autoDetectHeader()
|
||||
{
|
||||
$this->separator = ',';
|
||||
|
||||
$this->header = str_replace("\xEF\xBB\xBF", "", $this->header);
|
||||
|
||||
$listSeparators = ["\t", ';', ','];
|
||||
foreach ($listSeparators as $sep) {
|
||||
if (strpos($this->header, $sep) !== false) {
|
||||
$this->separator = $sep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->columns = explode($this->separator, $this->header);
|
||||
|
||||
for ($i = count($this->columns) - 1 ; $i >= 0 ; $i--) {
|
||||
if (strlen($this->columns[$i]) == 0) {
|
||||
unset($this->columns[$i]);
|
||||
$this->removeSep++;
|
||||
}
|
||||
}
|
||||
|
||||
$columns = acym_getColumns('user');
|
||||
foreach ($columns as $i => $oneColumn) {
|
||||
$columns[$i] = strtolower($oneColumn);
|
||||
}
|
||||
|
||||
foreach ($this->columns as $i => $oneColumn) {
|
||||
$this->columns[$i] = strtolower(trim($oneColumn, '\'" '));
|
||||
if (in_array($this->columns[$i], ['listids', 'listname'])) continue;
|
||||
if (strpos($this->columns[$i], 'cf_') === 0) continue;
|
||||
|
||||
if (!in_array($this->columns[$i], $columns) && $this->columns[$i] != 1) {
|
||||
acym_enqueueNotification(acym_translation_sprintf('ACYM_IMPORT_ERROR_FIELD', '<b>'.acym_escape($this->columns[$i]).'</b>', '<b>'.implode('</b> | <b>', array_diff($columns, ['id', 'cms_id'])).'</b>'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('email', $this->columns)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function _cleanImportFolder()
|
||||
{
|
||||
|
||||
$files = acym_getFiles(ACYM_MEDIA.'import', '.', false, true, []);
|
||||
foreach ($files as $oneFile) {
|
||||
if (acym_fileGetExt($oneFile) != 'csv') {
|
||||
continue;
|
||||
}
|
||||
if (filectime($oneFile) < time() - 86400) {
|
||||
unlink($oneFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getImportedLists()
|
||||
{
|
||||
$listClass = acym_get('class.list');
|
||||
$listsId = json_decode(acym_getVar('string', 'lists_selected'));
|
||||
$newListName = acym_getVar('string', 'new_list');
|
||||
|
||||
if (empty($listsId) && empty($newListName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lists = [];
|
||||
|
||||
if (!empty($newListName)) {
|
||||
$newList = new stdClass();
|
||||
$newList->name = $newListName;
|
||||
$newList->active = 1;
|
||||
$colors = '#'.substr(str_shuffle('ABCDEF0123456789'), 0, 6);
|
||||
$newList->color = $colors;
|
||||
$listid = $listClass->save($newList);
|
||||
$lists[$listid] = 1;
|
||||
}
|
||||
|
||||
if (!empty($listsId)) {
|
||||
foreach ($listsId as $id) {
|
||||
$lists[$id] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($lists)) {
|
||||
return $lists;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _subscribeUsers()
|
||||
{
|
||||
|
||||
if (empty($this->allSubid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$subdate = date('Y-m-d H:i:s', time());
|
||||
|
||||
$listClass = acym_get('class.list');
|
||||
$lists = $this->getImportedLists();
|
||||
|
||||
if (!empty($this->importUserInLists)) {
|
||||
foreach ($this->importUserInLists as $listid => $arrayEmails) {
|
||||
if (empty($listid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$listid = (int)$listid;
|
||||
$query = 'INSERT IGNORE INTO #__acym_user_has_list (`list_id`,`user_id`,`subscription_date`,`status`) ';
|
||||
$query .= 'SELECT '.intval($listid).',`id`,'.acym_escapeDB($subdate).',1 FROM #__acym_user WHERE `email` IN (';
|
||||
$query .= implode(',', $arrayEmails).')';
|
||||
$nbsubscribed = acym_query($query);
|
||||
$nbsubscribed = intval($nbsubscribed);
|
||||
|
||||
if (isset($this->subscribedUsers[$listid])) {
|
||||
$this->subscribedUsers[$listid]->nbusers += $nbsubscribed;
|
||||
} else {
|
||||
$myList = $listClass->getOneById($listid);
|
||||
$this->subscribedUsers[$listid] = $myList;
|
||||
$this->subscribedUsers[$listid]->nbusers = $nbsubscribed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($lists)) {
|
||||
|
||||
foreach ($lists as $listid => $val) {
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($val == -1) {
|
||||
$dateColumn = 'unsubscribe_date';
|
||||
$status = -1;
|
||||
} else {
|
||||
$dateColumn = 'subscription_date';
|
||||
$status = 1;
|
||||
}
|
||||
|
||||
$nbsubscribed = 0;
|
||||
$listid = intval($listid);
|
||||
$query = 'INSERT IGNORE INTO #__acym_user_has_list (`list_id`,`user_id`,`'.$dateColumn.'`,`status`) VALUES ';
|
||||
$b = 0;
|
||||
$currentSubids = [];
|
||||
foreach ($this->allSubid as $subid) {
|
||||
$subid = intval($subid);
|
||||
$currentSubids[] = $subid;
|
||||
$b++;
|
||||
|
||||
if ($b > 200) {
|
||||
$query = rtrim($query, ',');
|
||||
if ($val == -1) {
|
||||
$query .= ' ON DUPLICATE KEY UPDATE status = -1';
|
||||
$nbsubscribed = -acym_loadResult('SELECT COUNT(*) FROM #__acym_listsub WHERE `list_id` = '.intval($listid).' AND status != -1 AND `user_id` IN ('.implode(',', $currentSubids).')');
|
||||
}
|
||||
$affected = acym_query($query);
|
||||
$nbsubscribed += intval($affected);
|
||||
$b = 0;
|
||||
$currentSubids = [];
|
||||
$query = 'INSERT IGNORE INTO #__acym_user_has_list (`list_id`,`user_id`,`'.$dateColumn.'`,`status`) VALUES ';
|
||||
}
|
||||
|
||||
$query .= '('.intval($listid).','.intval($subid).','.acym_escapeDB($subdate).','.$status.'),';
|
||||
}
|
||||
$query = rtrim($query, ',');
|
||||
if ($val == -1) {
|
||||
$query .= ' ON DUPLICATE KEY UPDATE status = -1';
|
||||
if (!empty($currentSubids)) {
|
||||
$nbsubscribed = -acym_loadResult('SELECT COUNT(*) FROM #__acym_listsub WHERE `list_id` = '.intval($listid).' AND status != -1 AND `user_id` IN ('.implode(',', $currentSubids).')');
|
||||
}
|
||||
}
|
||||
|
||||
$affected = acym_query($query);
|
||||
$nbsubscribed += intval($affected);
|
||||
|
||||
if (isset($this->subscribedUsers[$listid])) {
|
||||
$this->subscribedUsers[$listid]->nbusers += $nbsubscribed;
|
||||
} else {
|
||||
$myList = $listClass->getOneById($listid);
|
||||
$myList->status = $val;
|
||||
$this->subscribedUsers[$listid] = $myList;
|
||||
$this->subscribedUsers[$listid]->nbusers = $nbsubscribed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,935 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AcyMailing for Joomla
|
||||
* @version 6.2.0
|
||||
* @author acyba.com
|
||||
* @copyright (C) 2009-2019 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
|
||||
|
||||
require_once(ACYM_INC.'phpmailer'.DS.'exception.php');
|
||||
require_once(ACYM_INC.'phpmailer'.DS.'smtp.php');
|
||||
require_once(ACYM_INC.'phpmailer'.DS.'phpmailer.php');
|
||||
require_once(ACYM_INC.'emogrifier.php');
|
||||
|
||||
use acyPHPMailer\acyException;
|
||||
use acyPHPMailer\acySMTP;
|
||||
use acyPHPMailer\acyPHPMailer;
|
||||
use acymEmogrifier\acymEmogrifier;
|
||||
|
||||
class acymmailerHelper extends acyPHPMailer
|
||||
{
|
||||
var $report = true;
|
||||
var $alreadyCheckedAddresses = false;
|
||||
var $errorNewTry = [1, 6];
|
||||
var $autoAddUser = false;
|
||||
var $reportMessage = '';
|
||||
|
||||
var $trackEmail = false;
|
||||
|
||||
public $From = '';
|
||||
public $FromName = '';
|
||||
public $SMTPAutoTLS = false;
|
||||
|
||||
public $to = [];
|
||||
public $cc = [];
|
||||
public $bcc = [];
|
||||
public $ReplyTo = [];
|
||||
public $attachment = [];
|
||||
public $CustomHeader = [];
|
||||
|
||||
public $stylesheet = '';
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->encodingHelper = acym_get('helper.encoding');
|
||||
$this->userClass = acym_get('class.user');
|
||||
$this->config = acym_config();
|
||||
$this->setFrom($this->config->get('from_email'), $this->config->get('from_name'));
|
||||
$this->Sender = $this->cleanText($this->config->get('bounce_email'));
|
||||
if (empty($this->Sender)) {
|
||||
$this->Sender = '';
|
||||
}
|
||||
|
||||
switch ($this->config->get('mailer_method', 'phpmail')) {
|
||||
case 'smtp' :
|
||||
$this->isSMTP();
|
||||
$this->Host = trim($this->config->get('smtp_host'));
|
||||
$port = $this->config->get('smtp_port');
|
||||
if (empty($port) && $this->config->get('smtp_secured') == 'ssl') {
|
||||
$port = 465;
|
||||
}
|
||||
if (!empty($port)) {
|
||||
$this->Host .= ':'.$port;
|
||||
}
|
||||
$this->SMTPAuth = (bool)$this->config->get('smtp_auth', true);
|
||||
$this->Username = trim($this->config->get('smtp_username'));
|
||||
$this->Password = trim($this->config->get('smtp_password'));
|
||||
$this->SMTPSecure = trim((string)$this->config->get('smtp_secured'));
|
||||
|
||||
if (empty($this->Sender)) {
|
||||
$this->Sender = strpos($this->Username, '@') ? $this->Username : $this->config->get('from_email');
|
||||
}
|
||||
break;
|
||||
case 'sendmail' :
|
||||
$this->isSendmail();
|
||||
$this->Sendmail = trim($this->config->get('sendmail_path'));
|
||||
if (empty($this->Sendmail)) {
|
||||
$this->Sendmail = '/usr/sbin/sendmail';
|
||||
}
|
||||
break;
|
||||
case 'qmail' :
|
||||
$this->isQmail();
|
||||
break;
|
||||
case 'elasticemail' :
|
||||
$port = $this->config->get('elasticemail_port', 'rest');
|
||||
if (is_numeric($port)) {
|
||||
$this->isSMTP();
|
||||
if ($port == '25') {
|
||||
$this->Host = 'smtp25.elasticemail.com:25';
|
||||
} else {
|
||||
$this->Host = 'smtp.elasticemail.com:2525';
|
||||
}
|
||||
$this->Username = trim($this->config->get('elasticemail_username'));
|
||||
$this->Password = trim($this->config->get('elasticemail_password'));
|
||||
$this->SMTPAuth = true;
|
||||
} else {
|
||||
include_once(ACYM_INC.'phpmailer'.DS.'elasticemail.php');
|
||||
$this->Mailer = 'elasticemail';
|
||||
$this->{$this->Mailer} = new acyElasticemail();
|
||||
$this->{$this->Mailer}->Username = trim($this->config->get('elasticemail_username'));
|
||||
$this->{$this->Mailer}->Password = trim($this->config->get('elasticemail_password'));
|
||||
}
|
||||
|
||||
break;
|
||||
default :
|
||||
$this->isMail();
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->config->get('dkim', 0) && $this->Mailer != 'elasticemail') {
|
||||
$this->DKIM_domain = $this->config->get('dkim_domain');
|
||||
$this->DKIM_selector = $this->config->get('dkim_selector', 'acy');
|
||||
if (empty($this->DKIM_selector)) $this->DKIM_selector = 'acy';
|
||||
$this->DKIM_passphrase = $this->config->get('dkim_passphrase');
|
||||
$this->DKIM_identity = $this->config->get('dkim_identity');
|
||||
$this->DKIM_private = trim($this->config->get('dkim_private'));
|
||||
$this->DKIM_private_string = trim($this->config->get('dkim_private'));
|
||||
}
|
||||
|
||||
$this->CharSet = strtolower($this->config->get('charset'));
|
||||
if (empty($this->CharSet)) {
|
||||
$this->CharSet = 'utf-8';
|
||||
}
|
||||
|
||||
$this->clearAll();
|
||||
|
||||
$this->Encoding = $this->config->get('encoding_format');
|
||||
if (empty($this->Encoding)) {
|
||||
$this->Encoding = '8bit';
|
||||
}
|
||||
|
||||
@ini_set('pcre.backtrack_limit', 1000000);
|
||||
|
||||
$this->SMTPOptions = ["ssl" => ["verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true]];
|
||||
}
|
||||
|
||||
protected function elasticemailSend($MIMEHeader, $MIMEBody)
|
||||
{
|
||||
$result = $this->elasticemail->sendMail($this);
|
||||
if (!$result) {
|
||||
$this->setError($this->elasticemail->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
if (!file_exists(ACYM_INC.'phpmailer'.DS.'phpmailer.php')) {
|
||||
$this->reportMessage = acym_translation_sprintf('ACYM_X_FILE_MISSING', 'phpmailer', ACYM_INC.'phpmailer'.DS);
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (empty($this->Subject) || empty($this->Body)) {
|
||||
$this->reportMessage = acym_translation('ACYM_SEND_EMPTY');
|
||||
$this->errorNumber = 8;
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->ReplyTo) && empty($this->ReplyToQueue)) {
|
||||
if (!empty($this->replyemail)) {
|
||||
$replyToEmail = $this->replyemail;
|
||||
} elseif ($this->config->get('from_as_replyto', 1) == 1) {
|
||||
$replyToEmail = $this->config->get('from_email');
|
||||
} else {
|
||||
$replyToEmail = $this->config->get('replyto_email');
|
||||
}
|
||||
|
||||
if (!empty($this->replyname)) {
|
||||
$replyToName = $this->replyname;
|
||||
} elseif ($this->config->get('from_as_replyto', 1) == 1) {
|
||||
$replyToName = $this->config->get('from_name');
|
||||
} else {
|
||||
$replyToName = $this->config->get('replyto_name');
|
||||
}
|
||||
|
||||
$this->_addReplyTo($replyToEmail, $replyToName);
|
||||
}
|
||||
|
||||
if ((bool)$this->config->get('embed_images', 0) && $this->Mailer != 'elasticemail') {
|
||||
$this->embedImages();
|
||||
}
|
||||
|
||||
if (!$this->alreadyCheckedAddresses) {
|
||||
$this->alreadyCheckedAddresses = true;
|
||||
|
||||
$replyToTmp = '';
|
||||
if (!empty($this->ReplyTo)) {
|
||||
$replyToTmp = reset($this->ReplyTo);
|
||||
$replyToTmp = $replyToTmp[0];
|
||||
} elseif (!empty($this->ReplyToQueue)) {
|
||||
$replyToTmp = reset($this->ReplyToQueue);
|
||||
$replyToTmp = $replyToTmp[1];
|
||||
}
|
||||
|
||||
if (empty($replyToTmp) || !acym_isValidEmail($replyToTmp)) {
|
||||
$this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_REPLYTO_EMAIL').' : '.(empty($this->ReplyTo) ? '' : $replyToTmp).' ) ';
|
||||
$this->errorNumber = 9;
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->From) || !acym_isValidEmail($this->From)) {
|
||||
$this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_FROM_EMAIL').' : '.$this->From.' ) ';
|
||||
$this->errorNumber = 9;
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->Sender) && !acym_isValidEmail($this->Sender)) {
|
||||
$this->reportMessage = acym_translation('ACYM_VALID_EMAIL').' ( '.acym_translation('ACYM_BOUNCE_EMAIL').' : '.$this->Sender.' ) ';
|
||||
$this->errorNumber = 9;
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$this->Body = mb_convert_encoding($this->Body, 'HTML-ENTITIES', 'UTF-8');
|
||||
$this->Body = str_replace(['&', 'ς'], ['&', 'ς'], $this->Body);
|
||||
}
|
||||
|
||||
if ($this->CharSet != 'utf-8') {
|
||||
$this->Body = $this->encodingHelper->change($this->Body, 'UTF-8', $this->CharSet);
|
||||
$this->Subject = $this->encodingHelper->change($this->Subject, 'UTF-8', $this->CharSet);
|
||||
}
|
||||
|
||||
if (strpos($this->Host, 'elasticemail')) {
|
||||
$this->addCustomHeader('referral:2f0447bb-173a-459d-ab1a-ab8cbebb9aab');
|
||||
}
|
||||
|
||||
$this->Subject = str_replace(['’', '“', '”', '–'], ["'", '"', '"', '-'], $this->Subject);
|
||||
|
||||
$this->Body = str_replace(" ", ' ', $this->Body);
|
||||
|
||||
if ($this->ContentType != 'text/plain') {
|
||||
static $foundationCSS = null;
|
||||
$style = [];
|
||||
if (empty($foundationCSS)) {
|
||||
$foundationCSS = acym_fileGetContent(ACYM_MEDIA.'css'.DS.'libraries'.DS.'foundation_email.min.css');
|
||||
$foundationCSS = str_replace('#acym__wysid__template ', '', $foundationCSS);
|
||||
}
|
||||
|
||||
if (strpos($this->Body, 'acym__wysid__template') !== false) $style['foundation'] = $foundationCSS;
|
||||
|
||||
static $emailFixes = null;
|
||||
if (empty($emailFixes)) {
|
||||
$emailFixes = acym_fileGetContent(ACYM_MEDIA.'css'.DS.'email.min.css');
|
||||
}
|
||||
$style[] = $emailFixes;
|
||||
|
||||
if (!empty($this->stylesheet)) $style[] = $this->stylesheet;
|
||||
|
||||
preg_match('@<[^>"t]*body[^>]*>@', $this->Body, $matches);
|
||||
if (empty($matches[0])) $this->Body = '<body>'.$this->Body.'</body>';
|
||||
|
||||
$styleFoundInBody = preg_match_all('/<\s*style[^>]*>(.*?)<\s*\/\s*style>/s', $this->Body, $matches);
|
||||
if ($styleFoundInBody) {
|
||||
foreach ($matches[1] as $match) {
|
||||
$style[] = $match;
|
||||
}
|
||||
}
|
||||
|
||||
$emogrifier = new \acymEmogrifier\acymEmogrifier($this->Body, implode('', $style));
|
||||
$this->Body = $emogrifier->emogrifyBodyContent();
|
||||
|
||||
$style[] = $emogrifier->mediaCSS;
|
||||
|
||||
preg_match('@<[^>"t]*/body[^>]*>@', $this->Body, $matches);
|
||||
if (empty($matches[0])) $this->Body = $this->Body.'</body>';
|
||||
|
||||
unset($style['foundation']);
|
||||
|
||||
$finalContent = '<html><head>';
|
||||
$finalContent .= '<meta http-equiv="Content-Type" content="text/html; charset='.strtolower($this->config->get('charset')).'" />'."\n";
|
||||
$finalContent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n";
|
||||
$finalContent .= '<title>'.$this->Subject.'</title>'."\n";
|
||||
$finalContent .= '<style type="text/css">'.implode('</style><style type="text/css">', $style).'</style>';
|
||||
if (!empty($this->headers)) $finalContent .= $this->headers;
|
||||
$finalContent .= '</head>'.$this->Body.'</html>';
|
||||
|
||||
$this->Body = $finalContent;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$result = parent::send();
|
||||
$warnings = ob_get_clean();
|
||||
|
||||
if (!empty($warnings) && strpos($warnings, 'bloque')) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
$receivers = [];
|
||||
foreach ($this->to as $oneReceiver) {
|
||||
$receivers[] = $oneReceiver[0];
|
||||
}
|
||||
if (!$result) {
|
||||
$this->reportMessage = acym_translation_sprintf('ACYM_SEND_ERROR', '<b>'.$this->Subject.'</b>', '<b>'.implode(' , ', $receivers).'</b>');
|
||||
if (!empty($this->ErrorInfo)) {
|
||||
$this->reportMessage .= " \n\n ".$this->ErrorInfo;
|
||||
}
|
||||
if (!empty($warnings)) {
|
||||
$this->reportMessage .= " \n\n ".$warnings;
|
||||
}
|
||||
$this->errorNumber = 1;
|
||||
if ($this->report) {
|
||||
$this->reportMessage = str_replace('Could not instantiate mail function', '<a target="_blank" href="'.ACYM_REDIRECT.'could-not-instantiate-mail-function">Could not instantiate mail function</a>', $this->reportMessage);
|
||||
acym_enqueueMessage(nl2br($this->reportMessage), 'error');
|
||||
}
|
||||
} else {
|
||||
$this->reportMessage = acym_translation_sprintf('ACYM_SEND_SUCCESS', '<b>'.$this->Subject.'</b>', '<b>'.implode(' , ', $receivers).'</b>');
|
||||
if (!empty($warnings)) {
|
||||
$this->reportMessage .= " \n\n ".$warnings;
|
||||
}
|
||||
if ($this->report) {
|
||||
if (acym_isAdmin()) {
|
||||
acym_enqueueMessage(preg_replace('#(<br( ?/)?>){2}#', '<br />', nl2br($this->reportMessage)), 'message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function clearAll()
|
||||
{
|
||||
$this->Subject = '';
|
||||
$this->Body = '';
|
||||
$this->AltBody = '';
|
||||
$this->ClearAllRecipients();
|
||||
$this->ClearAttachments();
|
||||
$this->ClearCustomHeaders();
|
||||
$this->ClearReplyTos();
|
||||
$this->errorNumber = 0;
|
||||
$this->MessageID = '';
|
||||
$this->ErrorInfo = '';
|
||||
|
||||
$this->setFrom($this->config->get('from_email'), $this->config->get('from_name'));
|
||||
}
|
||||
|
||||
public function load($mailId)
|
||||
{
|
||||
$mailClass = acym_get('class.mail');
|
||||
$this->defaultMail[$mailId] = $mailClass->getOneById($mailId);
|
||||
|
||||
if (empty($this->defaultMail[$mailId])) {
|
||||
$this->defaultMail[$mailId] = $mailClass->getOneByName($mailId);
|
||||
}
|
||||
|
||||
if (empty($this->defaultMail[$mailId]->id)) {
|
||||
unset($this->defaultMail[$mailId]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->defaultMail[$mailId]->altbody = $this->textVersion($this->defaultMail[$mailId]->body);
|
||||
|
||||
if (!empty($this->defaultMail[$mailId]->attachments)) {
|
||||
$this->defaultMail[$mailId]->attach = [];
|
||||
|
||||
$attachments = json_decode($this->defaultMail[$mailId]->attachments);
|
||||
foreach ($attachments as $oneAttach) {
|
||||
$attach = new stdClass();
|
||||
$attach->name = basename($oneAttach->filename);
|
||||
$attach->filename = str_replace(['/', '\\'], DS, ACYM_ROOT).$oneAttach->filename;
|
||||
$attach->url = ACYM_LIVE.$oneAttach->filename;
|
||||
$this->defaultMail[$mailId]->attach[] = $attach;
|
||||
}
|
||||
}
|
||||
|
||||
acym_trigger('replaceContent', [&$this->defaultMail[$mailId], true]);
|
||||
|
||||
$this->defaultMail[$mailId]->body = acym_absoluteURL($this->defaultMail[$mailId]->body);
|
||||
|
||||
return $this->defaultMail[$mailId];
|
||||
}
|
||||
|
||||
public function sendOne($mailId, $user, $isTest = false)
|
||||
{
|
||||
$this->clearAll();
|
||||
|
||||
if (!isset($this->defaultMail[$mailId]) && !$this->load($mailId)) {
|
||||
$this->reportMessage = 'Can not load the e-mail : '.acym_escape($mailId);
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
$this->errorNumber = 2;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_string($user) && strpos($user, '@')) {
|
||||
$receiver = $this->userClass->getOneByEmail($user);
|
||||
|
||||
if (empty($receiver) && $this->autoAddUser && acym_isValidEmail($user)) {
|
||||
$newUser = new stdClass();
|
||||
$newUser->email = $user;
|
||||
$this->userClass->checkVisitor = false;
|
||||
$this->userClass->sendConf = false;
|
||||
$userId = $this->userClass->save($newUser);
|
||||
$receiver = $this->userClass->getOneById($userId);
|
||||
}
|
||||
} elseif (is_object($user)) {
|
||||
$receiver = $user;
|
||||
} else {
|
||||
$receiver = $this->userClass->getOneById($user);
|
||||
}
|
||||
|
||||
if (empty($receiver->email)) {
|
||||
$this->reportMessage = acym_translation_sprintf('ACYM_SEND_ERROR_USER', '<b><i>'.acym_escape($user).'</i></b>');
|
||||
if ($this->report) {
|
||||
acym_enqueueNotification($this->reportMessage, 'error');
|
||||
}
|
||||
$this->errorNumber = 4;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->MessageID = "<".preg_replace("|[^a-z0-9+_]|i", '', base64_encode(rand(0, 9999999))."AC".$receiver->id."Y".$this->defaultMail[$mailId]->id."BA".base64_encode(time().rand(0, 99999)))."@".$this->serverHostname().">";
|
||||
|
||||
$addedName = '';
|
||||
if ($this->config->get('add_names', true)) {
|
||||
$addedName = $this->cleanText($receiver->name);
|
||||
if ($addedName == $this->cleanText($receiver->email)) {
|
||||
$addedName = '';
|
||||
}
|
||||
}
|
||||
$this->addAddress($this->cleanText($receiver->email), $addedName);
|
||||
|
||||
$this->isHTML(true);
|
||||
|
||||
$this->Subject = $this->defaultMail[$mailId]->subject;
|
||||
$this->Body = $this->defaultMail[$mailId]->body;
|
||||
$this->Preheader = $this->defaultMail[$mailId]->preheader;
|
||||
|
||||
if ($this->config->get('multiple_part', false)) {
|
||||
$this->AltBody = $this->defaultMail[$mailId]->altbody;
|
||||
}
|
||||
|
||||
if (!empty($this->defaultMail[$mailId]->stylesheet)) {
|
||||
$this->stylesheet = $this->defaultMail[$mailId]->stylesheet;
|
||||
}
|
||||
|
||||
if (!empty($this->defaultMail[$mailId]->headers)) {
|
||||
$this->headers = $this->defaultMail[$mailId]->headers;
|
||||
}
|
||||
|
||||
$this->setFrom($this->defaultMail[$mailId]->from_email, $this->defaultMail[$mailId]->from_name);
|
||||
$this->_addReplyTo($this->defaultMail[$mailId]->reply_to_email, $this->defaultMail[$mailId]->reply_to_name);
|
||||
|
||||
if (!empty($this->defaultMail[$mailId]->bcc)) {
|
||||
$bcc = trim(str_replace([',', ' '], ';', $this->defaultMail[$mailId]->bcc));
|
||||
$allBcc = explode(';', $bcc);
|
||||
foreach ($allBcc as $oneBcc) {
|
||||
if (empty($oneBcc)) continue;
|
||||
$this->AddBCC($oneBcc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->defaultMail[$mailId]->attach)) {
|
||||
if ($this->config->get('embed_files')) {
|
||||
foreach ($this->defaultMail[$mailId]->attach as $attachment) {
|
||||
$this->addAttachment($attachment->filename);
|
||||
}
|
||||
} else {
|
||||
$attachStringHTML = '<br /><fieldset><legend>'.acym_translation('ATTACHMENTS').'</legend><table>';
|
||||
$attachStringText = "\n"."\n".'------- '.acym_translation('ATTACHMENTS').' -------';
|
||||
foreach ($this->defaultMail[$mailId]->attach as $attachment) {
|
||||
$attachStringHTML .= '<tr><td><a href="'.$attachment->url.'" target="_blank">'.$attachment->name.'</a></td></tr>';
|
||||
$attachStringText .= "\n".'-- '.$attachment->name.' ( '.$attachment->url.' )';
|
||||
}
|
||||
$attachStringHTML .= '</table></fieldset>';
|
||||
|
||||
$this->Body .= $attachStringHTML;
|
||||
if (!empty($this->AltBody)) {
|
||||
$this->AltBody .= "\n".$attachStringText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->introtext)) {
|
||||
$this->Body = $this->introtext.$this->Body;
|
||||
$this->AltBody = $this->textVersion($this->introtext).$this->AltBody;
|
||||
}
|
||||
|
||||
$preheader = '';
|
||||
if (!empty($this->Preheader)) {
|
||||
$spacing = '';
|
||||
|
||||
for ($x = 0 ; $x < 100 ; $x++) {
|
||||
$spacing .= ' ‌';
|
||||
}
|
||||
$preheader = '<!--[if !mso 9]><!--><div style="visibility:hidden;mso-hide:all;font-size:0;color:transparent;height:0;line-height:0;max-height:0;max-width:0;opacity:0;overflow:hidden;">'.$this->Preheader.$spacing.'</div><!--<![endif]-->';
|
||||
}
|
||||
|
||||
if (!empty($preheader)) {
|
||||
$this->Body = $preheader.$this->Body;
|
||||
$this->AltBody = $this->textVersion($preheader).$this->AltBody;
|
||||
}
|
||||
|
||||
|
||||
$this->replaceParams();
|
||||
|
||||
$this->body = &$this->Body;
|
||||
$this->altbody = &$this->AltBody;
|
||||
$this->subject = &$this->Subject;
|
||||
$this->from = &$this->From;
|
||||
$this->fromName = &$this->FromName;
|
||||
$this->replyto = &$this->ReplyTo;
|
||||
$this->replyname = $this->defaultMail[$mailId]->reply_to_name;
|
||||
$this->replyemail = $this->defaultMail[$mailId]->reply_to_email;
|
||||
$this->id = $this->defaultMail[$mailId]->id;
|
||||
$this->type = $this->defaultMail[$mailId]->type;
|
||||
$this->stylesheet = &$this->stylesheet;
|
||||
|
||||
if (!$isTest) {
|
||||
$this->statPicture($this->id, $receiver->id);
|
||||
$this->statClick($this->id, $receiver->id);
|
||||
}
|
||||
|
||||
$this->replaceParams();
|
||||
|
||||
if (strpos($receiver->email, '@mail-tester.com') !== false) {
|
||||
$currentUser = $this->userClass->getOneByEmail(acym_currentUserEmail());
|
||||
if (empty($currentUser)) {
|
||||
$currentUser = $receiver;
|
||||
}
|
||||
acym_trigger('replaceUserInformation', [&$this, &$currentUser, true]);
|
||||
} else {
|
||||
acym_trigger('replaceUserInformation', [&$this, &$receiver, true]);
|
||||
}
|
||||
|
||||
$status = $this->send();
|
||||
if ($this->trackEmail) {
|
||||
$helperQueue = acym_get('helper.queue');
|
||||
$statsAdd = [];
|
||||
$statsAdd[$this->id][$status][] = $receiver->id;
|
||||
$helperQueue->statsAdd($statsAdd);
|
||||
$this->trackEmail = false;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function statPicture($mailId, $userId)
|
||||
{
|
||||
$pictureLink = acym_frontendLink('frontstats&action=acymailing_frontrouter&task=openStats&id='.$mailId.'&userid='.$userId);
|
||||
|
||||
$widthsize = 50;
|
||||
$heightsize = 1;
|
||||
$width = empty($widthsize) ? '' : ' width="'.$widthsize.'" ';
|
||||
$height = empty($heightsize) ? '' : ' height="'.$heightsize.'" ';
|
||||
|
||||
$statPicture = '<img class="spict" alt="" src="'.$pictureLink.'" border="0" '.$height.$width.'/>';
|
||||
|
||||
if (strpos($this->body, '</body>')) {
|
||||
$this->body = str_replace('</body>', $statPicture.'</body>', $this->body);
|
||||
} else {
|
||||
$this->body .= $statPicture;
|
||||
}
|
||||
}
|
||||
|
||||
public function statClick($mailId, $userid)
|
||||
{
|
||||
if (!in_array($this->type, ['standard', 'automation'])) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$urlClass = acym_get('class.url');
|
||||
|
||||
if ($urlClass === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$urls = [];
|
||||
|
||||
$config = acym_config();
|
||||
$trackingSystemExternalWebsite = $config->get('trackingsystemexternalwebsite', 1);
|
||||
|
||||
preg_match_all('#href[ ]*=[ ]*"(?!mailto:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:|tel:)([^"]+)"#Ui', $this->body, $results);
|
||||
|
||||
if (empty($results)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$countLinks = array_count_values($results[1]);
|
||||
if (array_product($countLinks) != 1) {
|
||||
foreach ($results[1] as $key => $url) {
|
||||
if ($countLinks[$url] == 1) {
|
||||
continue;
|
||||
}
|
||||
$countLinks[$url]--;
|
||||
|
||||
$toAddUrl = (strpos($url, '?') === false ? '?' : '&').'idU='.$countLinks[$url];
|
||||
|
||||
$posHash = strpos($url, '#');
|
||||
if ($posHash !== false) {
|
||||
$newURL = substr($url, 0, $posHash).$toAddUrl.substr($url, $posHash);
|
||||
} else {
|
||||
$newURL = $url.$toAddUrl;
|
||||
}
|
||||
|
||||
$this->body = preg_replace('#href="('.preg_quote($url, '#').')"#Uis', 'href="'.$newURL.'"', $this->body, 1);
|
||||
$this->altbody = preg_replace('#\( ('.preg_quote($url, '#').') \)#Uis', '( '.$newURL.' )', $this->altbody, 1);
|
||||
|
||||
$results[0][$key] = 'href="'.$newURL.'"';
|
||||
$results[1][$key] = $newURL;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($results[1] as $i => $url) {
|
||||
if (isset($urls[$results[0][$i]]) || strpos($url, 'task=unsub')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$simplifiedUrl = str_replace(['https://', 'http://', 'www.'], '', $url);
|
||||
$simplifiedWebsite = str_replace(['https://', 'http://', 'www.'], '', ACYM_LIVE);
|
||||
$internalUrl = strpos($simplifiedUrl, rtrim($simplifiedWebsite, '/')) === 0;
|
||||
|
||||
$isFile = false;
|
||||
|
||||
$subfolder = false;
|
||||
if ($internalUrl) {
|
||||
$urlWithoutBase = str_replace($simplifiedWebsite, '', $simplifiedUrl);
|
||||
if (strpos($urlWithoutBase, '/') || strpos($urlWithoutBase, '?')) {
|
||||
$folderName = substr($urlWithoutBase, 0, strpos($urlWithoutBase, '/') == false ? strpos($urlWithoutBase, '?') : strpos($urlWithoutBase, '/'));
|
||||
if (strpos($folderName, '.') === false) {
|
||||
$subfolder = @is_dir(ACYM_ROOT.$folderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$trackingSystem = $config->get('trackingsystem', 'acymailing');
|
||||
|
||||
if (strpos($url, 'utm_source') === false && !$isFile && strpos($trackingSystem, 'google') !== false) {
|
||||
if ((!$internalUrl || $subfolder) && $trackingSystemExternalWebsite != 1) {
|
||||
continue;
|
||||
}
|
||||
$args = [];
|
||||
$args[] = 'utm_source=newsletter_'.$mailId;
|
||||
$args[] = 'utm_medium=email';
|
||||
$args[] = 'utm_campaign='.@$this->alias;
|
||||
$anchor = '';
|
||||
if (strpos($url, '#') !== false) {
|
||||
$anchor = substr($url, strpos($url, '#'));
|
||||
$url = substr($url, 0, strpos($url, '#'));
|
||||
}
|
||||
|
||||
if (strpos($url, '?')) {
|
||||
$mytracker = $url.'&'.implode('&', $args);
|
||||
} else {
|
||||
$mytracker = $url.'?'.implode('&', $args);
|
||||
}
|
||||
$mytracker .= $anchor;
|
||||
$urls[$results[0][$i]] = str_replace($results[1][$i], $mytracker, $results[0][$i]);
|
||||
|
||||
$url = $mytracker;
|
||||
}
|
||||
|
||||
if (strpos($trackingSystem, 'acymailing') !== false) {
|
||||
if ($trackingSystemExternalWebsite != 1) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match('#subid|passw|modify|\{|%7B#i', $url)) {
|
||||
continue;
|
||||
}
|
||||
$mytracker = $urlClass->getUrl($url, $mailId, $userid);
|
||||
|
||||
if (empty($mytracker)) {
|
||||
continue;
|
||||
}
|
||||
$urls[$results[0][$i]] = str_replace($results[1][$i], $mytracker, $results[0][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->body = str_replace(array_keys($urls), $urls, $this->body);
|
||||
}
|
||||
|
||||
public function textVersion($html, $fullConvert = true)
|
||||
{
|
||||
$html = acym_absoluteURL($html);
|
||||
|
||||
if ($fullConvert) {
|
||||
$html = preg_replace('# +#', ' ', $html);
|
||||
$html = str_replace(["\n", "\r", "\t"], '', $html);
|
||||
}
|
||||
|
||||
$removepictureslinks = "#< *a[^>]*> *< *img[^>]*> *< *\/ *a *>#isU";
|
||||
$removeScript = "#< *script(?:(?!< */ *script *>).)*< */ *script *>#isU";
|
||||
$removeStyle = "#< *style(?:(?!< */ *style *>).)*< */ *style *>#isU";
|
||||
$removeStrikeTags = '#< *strike(?:(?!< */ *strike *>).)*< */ *strike *>#iU';
|
||||
$replaceByTwoReturnChar = '#< *(h1|h2)[^>]*>#Ui';
|
||||
$replaceByStars = '#< *li[^>]*>#Ui';
|
||||
$replaceByReturnChar1 = '#< */ *(li|td|dt|tr|div|p)[^>]*> *< *(li|td|dt|tr|div|p)[^>]*>#Ui';
|
||||
$replaceByReturnChar = '#< */? *(br|p|h1|h2|legend|h3|li|ul|dd|dt|h4|h5|h6|tr|td|div)[^>]*>#Ui';
|
||||
$replaceLinks = '/< *a[^>]*href *= *"([^#][^"]*)"[^>]*>(.+)< *\/ *a *>/Uis';
|
||||
|
||||
$text = preg_replace([$removepictureslinks, $removeScript, $removeStyle, $removeStrikeTags, $replaceByTwoReturnChar, $replaceByStars, $replaceByReturnChar1, $replaceByReturnChar, $replaceLinks], ['', '', '', '', "\n\n", "\n* ", "\n", "\n", '${2} ( ${1} )'], $html);
|
||||
|
||||
$text = preg_replace('#(<|&\#60;)([^ \n\r\t])#i', '< ${2}', $text);
|
||||
|
||||
$text = str_replace([" ", " "], ' ', strip_tags($text));
|
||||
|
||||
$text = trim(@html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
|
||||
|
||||
if ($fullConvert) {
|
||||
$text = preg_replace('# +#', ' ', $text);
|
||||
$text = preg_replace('#\n *\n\s+#', "\n\n", $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
protected function embedImages()
|
||||
{
|
||||
preg_match_all('/(src|background)=[\'|"]([^"\']*)[\'|"]/Ui', $this->Body, $images);
|
||||
$result = true;
|
||||
|
||||
if (empty($images[2])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$mimetypes = ['bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff'];
|
||||
|
||||
$allimages = [];
|
||||
|
||||
foreach ($images[2] as $i => $url) {
|
||||
if (isset($allimages[$url])) {
|
||||
continue;
|
||||
}
|
||||
$allimages[$url] = 1;
|
||||
|
||||
$path = $url;
|
||||
$base = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', ACYM_LIVE);
|
||||
$replacements = ['https://www.'.$base, 'http://www.'.$base, 'https://'.$base, 'http://'.$base];
|
||||
foreach ($replacements as $oneReplacement) {
|
||||
if (strpos($url, $oneReplacement) === false) {
|
||||
continue;
|
||||
}
|
||||
$path = str_replace([$oneReplacement, '/'], [ACYM_ROOT, DS], urldecode($url));
|
||||
break;
|
||||
}
|
||||
|
||||
$filename = str_replace(['%', ' '], '_', basename($url));
|
||||
$md5 = md5($filename);
|
||||
$cid = 'cid:'.$md5;
|
||||
$fileParts = explode(".", $filename);
|
||||
if (empty($fileParts[1])) {
|
||||
continue;
|
||||
}
|
||||
$ext = strtolower($fileParts[1]);
|
||||
if (!isset($mimetypes[$ext])) {
|
||||
continue;
|
||||
}
|
||||
$mimeType = $mimetypes[$ext];
|
||||
if ($this->addEmbeddedImage($path, $md5, $filename, 'base64', $mimeType)) {
|
||||
$this->Body = preg_replace("/".preg_quote($images[0][$i], '/')."/Ui", $images[1][$i]."=\"".$cid."\"", $this->Body);
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function cleanText($text)
|
||||
{
|
||||
return trim(preg_replace('/(%0A|%0D|\n+|\r+)/i', '', (string)$text));
|
||||
}
|
||||
|
||||
protected function _addReplyTo($email, $name)
|
||||
{
|
||||
if (empty($email)) {
|
||||
return;
|
||||
}
|
||||
$replyToName = $this->config->get('add_names', true) ? $this->cleanText(trim($name)) : '';
|
||||
$replyToEmail = trim($email);
|
||||
if (substr_count($replyToEmail, '@') > 1) {
|
||||
$replyToEmailArray = explode(';', str_replace([';', ','], ';', $replyToEmail));
|
||||
$replyToNameArray = explode(';', str_replace([';', ','], ';', $replyToName));
|
||||
foreach ($replyToEmailArray as $i => $oneReplyTo) {
|
||||
$this->addReplyTo($this->cleanText($oneReplyTo), @$replyToNameArray[$i]);
|
||||
}
|
||||
} else {
|
||||
$this->addReplyTo($this->cleanText($replyToEmail), $replyToName);
|
||||
}
|
||||
}
|
||||
|
||||
private function replaceParams()
|
||||
{
|
||||
if (empty($this->parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$helperPlugin = acym_get('helper.plugin');
|
||||
|
||||
$this->generateAllParams();
|
||||
$this->Subject = $helperPlugin->replaceDText($this->Subject, $this->parameters);
|
||||
$this->Body = $helperPlugin->replaceDText($this->Body, $this->parameters);
|
||||
if (!empty($this->AltBody)) {
|
||||
$this->AltBody = $helperPlugin->replaceDText($this->AltBody, $this->parameters);
|
||||
}
|
||||
|
||||
if (!empty($this->From)) {
|
||||
$this->From = $helperPlugin->replaceDText($this->From, $this->parameters);
|
||||
}
|
||||
if (!empty($this->FromName)) {
|
||||
$this->FromName = $helperPlugin->replaceDText($this->FromName, $this->parameters);
|
||||
}
|
||||
|
||||
if (!empty($this->replyname)) {
|
||||
$this->replyname = $helperPlugin->replaceDText($this->replyname, $this->parameters);
|
||||
}
|
||||
if (!empty($this->replyemail)) {
|
||||
$this->replyemail = $helperPlugin->replaceDText($this->replyemail, $this->parameters);
|
||||
}
|
||||
if (!empty($this->ReplyTo)) {
|
||||
foreach ($this->ReplyTo as $i => $replyto) {
|
||||
foreach ($replyto as $a => $oneval) {
|
||||
$this->ReplyTo[$i][$a] = $helperPlugin->replaceDText($this->ReplyTo[$i][$a], $this->parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function generateAllParams()
|
||||
{
|
||||
$result = '<table style="border:1px solid;border-collapse:collapse;" border="1" cellpadding="10"><tr><td>Tag</td><td>Value</td></tr>';
|
||||
foreach ($this->parameters as $name => $value) {
|
||||
if (!is_string($value)) {
|
||||
continue;
|
||||
}
|
||||
$result .= '<tr><td>'.$name.'</td><td>'.$value.'</td></tr>';
|
||||
}
|
||||
$result .= '</table>';
|
||||
$this->addParam('alltags', $result);
|
||||
}
|
||||
|
||||
public function addParamInfo()
|
||||
{
|
||||
if (!empty($_SERVER)) {
|
||||
$serverinfo = [];
|
||||
foreach ($_SERVER as $oneKey => $oneInfo) {
|
||||
$serverinfo[] = $oneKey.' => '.strip_tags(print_r($oneInfo, true));
|
||||
}
|
||||
$this->addParam('serverinfo', implode('<br />', $serverinfo));
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST)) {
|
||||
$postinfo = [];
|
||||
foreach ($_REQUEST as $oneKey => $oneInfo) {
|
||||
$postinfo[] = $oneKey.' => '.strip_tags(print_r($oneInfo, true));
|
||||
}
|
||||
$this->addParam('postinfo', implode('<br />', $postinfo));
|
||||
}
|
||||
}
|
||||
|
||||
public function addParam($name, $value)
|
||||
{
|
||||
$tagName = '{'.$name.'}';
|
||||
$this->parameters[$tagName] = $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setFrom($email, $name = '', $auto = false)
|
||||
{
|
||||
|
||||
if (!empty($email)) {
|
||||
$this->From = $this->cleanText($email);
|
||||
}
|
||||
if (!empty($name) && $this->config->get('add_names', true)) {
|
||||
$this->FromName = $this->cleanText($name);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSMTPInstance()
|
||||
{
|
||||
if (!is_object($this->smtp)) {
|
||||
$this->smtp = new acySMTP();
|
||||
}
|
||||
|
||||
return $this->smtp;
|
||||
}
|
||||
|
||||
protected function edebug($str)
|
||||
{
|
||||
if (strpos($this->ErrorInfo, $str) === false) {
|
||||
$this->ErrorInfo .= ' '.$str;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMailMIME()
|
||||
{
|
||||
$result = parent::getMailMIME();
|
||||
|
||||
$result = rtrim($result, static::$LE);
|
||||
|
||||
if ($this->Mailer != 'mail') {
|
||||
$result .= static::$LE.static::$LE;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function validateAddress($address, $patternselect = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user