first commit
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
require_once(_PS_MODULE_DIR_ . 'ets_cfultimate/classes/ETS_CFU_Pagination.php');
|
||||
|
||||
class AdminContactFormUltimateContactFormController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
if (($conf = Tools::getValue('conf')) && !(isset($this->context->controller->_conf[$conf])) && $conf == 99) {
|
||||
$this->context->controller->_conf[$conf] = $this->module->l('Imported successfully');
|
||||
}
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
parent::initContent();
|
||||
if (Tools::getValue('action') == 'etsCfuUpdateContactFormOrdering' && $formcontact = Tools::getValue('formcontact')) {
|
||||
$page = Tools::getValue('page', 1);
|
||||
foreach ($formcontact as $key => $form) {
|
||||
$position = $key + ($page - 1) * 20;
|
||||
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'ets_cfu_contact SET position="' . (int)$position . '" WHERE id_contact=' . (int)$form);
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode(
|
||||
array(
|
||||
'page' => $page,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$filter = '';
|
||||
$url_extra = '';
|
||||
$values_submit = array();
|
||||
if (Tools::getValue('id_contact')) {
|
||||
$filter .= ' AND c.id_contact="' . (int)Tools::getValue('id_contact') . '"';
|
||||
$url_extra .= '&id_contact=' . (int)Tools::getValue('id_contact');
|
||||
$values_submit['id_contact'] = Tools::getValue('id_contact');
|
||||
}
|
||||
if (Tools::getValue('contact_title')) {
|
||||
$filter .= ' AND cl.title like "' . pSQL(Tools::getValue('contact_title')) . '"';
|
||||
$url_extra .= '&contact_title=' . Tools::getValue('contact_title');
|
||||
$values_submit['contact_title'] = Tools::getValue('contact_title');
|
||||
}
|
||||
if (Tools::getValue('hook')) {
|
||||
$filter .= ' AND c.hook like "%' . pSQL(Tools::getValue('hook')) . '%"';
|
||||
$url_extra .= '&hook=' . Tools::getValue('hook');
|
||||
$values_submit['hook'] = Tools::getValue('hook');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_dateadd_from')) {
|
||||
$filter .= ' AND c.date_add >="' . pSQL(Tools::getValue('messageFilter_dateadd_from')) . '"';
|
||||
$url_extra .= '&messageFilter_dateadd_from=' . Tools::getValue('messageFilter_dateadd_from');
|
||||
$values_submit['messageFilter_dateadd_from'] = Tools::getValue('messageFilter_dateadd_from');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_dateadd_to')) {
|
||||
$filter .= ' AND c.date_add <= "' . pSQL(Tools::getValue('messageFilter_dateadd_to')) . '"';
|
||||
$url_extra .= '&messageFilter_dateadd_to=' . Tools::getValue('messageFilter_dateadd_to');
|
||||
$values_submit['messageFilter_dateadd_to'] = Tools::getValue('messageFilter_dateadd_to');
|
||||
}
|
||||
if (Tools::getValue('save_message') != '') {
|
||||
$filter .= ' AND c.save_message = "' . (int)Tools::getValue('save_message') . '"';
|
||||
$url_extra .= '&save_message=' . Tools::getValue('save_message');
|
||||
$values_submit['save_message'] = Tools::getValue('save_message');
|
||||
}
|
||||
if (Tools::getValue('active_contact') != '') {
|
||||
$filter .= ' AND c.active = "' . (int)Tools::getValue('active_contact') . '"';
|
||||
$url_extra .= '&active_contact=' . Tools::getValue('active_contact');
|
||||
$values_submit['active_contact'] = Tools::getValue('active_contact');
|
||||
}
|
||||
if (Tools::getValue('sort') == 'id_contact')
|
||||
$sort = 'c.id_contact';
|
||||
else
|
||||
$sort = Tools::getValue('sort', 'position');
|
||||
$sort_type = Tools::getValue('sort_type', 'asc');
|
||||
$total = $this->module->getContacts(false, $filter, 0, 0, true);
|
||||
$limit = 20;
|
||||
$page = Tools::getValue('page', 1);
|
||||
$start = ($page - 1) * $limit;
|
||||
$pagination = new ETS_CFU_Pagination();
|
||||
$pagination->url = $this->context->link->getAdminLink('AdminContactFormUltimateContactForm', true) . $url_extra . '&page=_page_';
|
||||
$pagination->limit = $limit;
|
||||
$pagination->page = $page;
|
||||
$pagination->total = $total;
|
||||
$contacts = $this->module->getContacts(false, $filter, $start, $limit, false, $sort, $sort_type);
|
||||
if ($contacts) {
|
||||
foreach ($contacts as &$contact) {
|
||||
$contact['hooks'] = explode(',', $contact['hook']);
|
||||
if ($contact['enable_form_page'])
|
||||
$contact['link'] = Ets_CfUltimate::getLinkContactForm($contact['id_contact']);
|
||||
$contact['count_views'] = Db::getInstance()->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE id_contact=' . (int)$contact['id_contact']);
|
||||
$contact['count_message'] = Db::getInstance()->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_contact=' . (int)$contact['id_contact']);
|
||||
}
|
||||
}
|
||||
$hooks = array(
|
||||
'nav_top' => $this->module->l('Header - top navigation'),
|
||||
'header' => $this->module->l('Header - main header'),
|
||||
'displayTop' => $this->module->l('Top'),
|
||||
'home' => $this->module->l('Home'),
|
||||
'left_column' => $this->module->l('Left column'),
|
||||
'footer' => $this->module->l('Footer'),
|
||||
'right_column' => $this->module->l('Right column'),
|
||||
'product_thumbs' => $this->module->l('Product page - below product image'),
|
||||
'product_right' => $this->module->l('Product page - right column'),
|
||||
'product_left' => $this->module->l('Product page - left column'),
|
||||
'checkout_page' => $this->module->l('Checkout page'),
|
||||
'register_page' => $this->module->l('Register page'),
|
||||
'login_page' => $this->module->l('Login page'),
|
||||
);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'ets_cfu_contacts' => $contacts,
|
||||
'url_module' => $this->context->link->getAdminLink('AdminModules', true) . '&configure=' . $this->module->name . '&tab_module=' . $this->module->tab . '&module_name=' . $this->module->name,
|
||||
'ets_cfu_pagination_text' => $pagination->render(),
|
||||
'filter' => $filter,
|
||||
'filter_params' => $url_extra,
|
||||
'is_ps15' => version_compare(_PS_VERSION_, '1.6', '<') ? true : false,
|
||||
'etsCfuOkImport' => Tools::getValue('etsCfuOkImport'),
|
||||
'hooks' => $hooks,
|
||||
'sort' => Tools::getValue('sort', 'position'),
|
||||
'sort_type' => Tools::getValue('sort_type', 'asc'),
|
||||
'_PS_JS_DIR_' => _PS_JS_DIR_,
|
||||
'ETS_CFU_ENABLE_TMCE' => Configuration::get('ETS_CFU_ENABLE_TMCE'),
|
||||
'showShortcodeHook' =>Configuration::get('ETS_CFU_ENABLE_HOOK_SHORTCODE')
|
||||
)
|
||||
);
|
||||
return $this->module->display($this->module->getLocalPath(), 'list-contact.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateContactForm'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateDashboardController extends AdminModuleAdapterController
|
||||
{
|
||||
public $_html;
|
||||
public $filters = array();
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
parent::__construct();
|
||||
$this->filters = array(
|
||||
'mon' => array(
|
||||
'label' => $this->l('This month'),
|
||||
'id' => 'month',
|
||||
),
|
||||
'yea' => array(
|
||||
'label' => $this->l('This year'),
|
||||
'id' => 'year',
|
||||
),
|
||||
'all' => array(
|
||||
'label' => $this->l('All time'),
|
||||
'id' => 'all',
|
||||
),
|
||||
);
|
||||
$this->charts = array(
|
||||
'mes' => array(
|
||||
'label' => $this->l('Messages'),
|
||||
),
|
||||
'vie' => array(
|
||||
'label' => $this->l('Views'),
|
||||
),
|
||||
'rep' => array(
|
||||
'label' => $this->l('Replies'),
|
||||
),
|
||||
'use' => array(
|
||||
'label' => $this->l('Users'),
|
||||
),
|
||||
);
|
||||
}
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$this->getCharts(Tools::getValue('ajax'));
|
||||
}
|
||||
public function renderList()
|
||||
{
|
||||
$assigns = $this->getCharts();
|
||||
$contacts = Db::getInstance()->executeS('
|
||||
SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_contact c, ' . _DB_PREFIX_ . 'ets_cfu_contact_lang cl
|
||||
WHERE c.id_contact=cl.id_contact AND cl.id_lang=' . (int)$this->context->language->id
|
||||
);
|
||||
$sql = "SELECT l.* FROM " . _DB_PREFIX_ . "ets_cfu_log l
|
||||
INNER JOIN " . _DB_PREFIX_ . "ets_cfu_contact c ON (l.id_contact=c.id_contact)
|
||||
LEFT JOIN " . _DB_PREFIX_ . "ets_cfu_contact_lang cl ON (c.id_contact=cl.id_contact AND cl.id_lang='" . (int)$this->context->language->id . "')
|
||||
LEFT JOIN " . _DB_PREFIX_ . "customer cu ON (l.id_customer=cu.id_customer)
|
||||
GROUP BY l.ip, l.id_contact, l.datetime_added
|
||||
ORDER BY l.datetime_added DESC LIMIT 0, 6";
|
||||
if (($logs = Db::getInstance()->executeS($sql))) {
|
||||
$black_list = explode("\n", Configuration::get('ETS_CFU_IP_BLACK_LIST'));
|
||||
foreach ($logs as &$log) {
|
||||
if (in_array($log['ip'], $black_list))
|
||||
$log['black_list'] = true;
|
||||
else
|
||||
$log['black_list'] = false;
|
||||
$browser = explode(' ', $log['browser']);
|
||||
if (isset($browser[0]))
|
||||
$log['class'] = Tools::strtolower($browser[0]);
|
||||
else
|
||||
$log['class'] = 'default';
|
||||
}
|
||||
}
|
||||
/*new*/
|
||||
$assigns = array_merge($assigns, array(
|
||||
'ets_cfu_month' => (string)Tools::getValue('ets_cfu_months', date('m')),
|
||||
'action' => $this->context->link->getAdminLink('AdminContactFormUltimateDashboard'),
|
||||
'ets_cfu_contacts' => $contacts,
|
||||
'ets_cfu_year' => Tools::getValue('years', date('Y')),
|
||||
'ets_cfu_cfu_contact' => (int)Tools::getValue('id_contact'),
|
||||
'ets_cfu_js_dir_path' => $this->module->getPathUri() . 'views/js/',
|
||||
'ets_cfu_img_dir_path' => $this->module->getPathUri() . 'views/img/',
|
||||
'ets_cfu_logs' => $logs,
|
||||
'cfu_tab_ets' => Tools::getValue('cfu_tab_ets', 'chart'),
|
||||
'ets_cfu_show_reset' => Tools::isSubmit('etsCfuSubmitFilterChart'),
|
||||
'ets_cfu_link' => $this->context->link,
|
||||
'ets_cfu_total_message' => $this->module->getCountUnreadMessage(),
|
||||
'ets_cfu_stats' => $this->getDashboardStats(),
|
||||
'filters' => $this->filters
|
||||
));
|
||||
$this->context->smarty->assign($assigns);
|
||||
$this->_html .= $this->module->display($this->module->getLocalPath(), 'dashboard.tpl');
|
||||
return $this->_html;
|
||||
}
|
||||
public function getDashboardStats()
|
||||
{
|
||||
$stats = array();
|
||||
//1.Messages received
|
||||
$sql = 'SELECT COUNT(%1$s) FROM ' . _DB_PREFIX_ . 'ets_cfu_contact%3$s b
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact%2$s_shop a ON (a.id_contact%2$s = b.id_contact%2$s)
|
||||
WHERE a.id_contact%2$s is NOT NULL AND a.id_shop = ' . (int)$this->context->shop->id;
|
||||
|
||||
$sql_forms = sprintf($sql, '*', '', '');
|
||||
$total_forms = (int)Db::getInstance()->getValue($sql_forms);
|
||||
|
||||
$query_msg = sprintf($sql, '*', '_message', '_message');
|
||||
$total_msg = (int)Db::getInstance()->getValue($query_msg);
|
||||
|
||||
$query_forms = sprintf($sql, 'DISTINCT a.id_contact', '', '_message');
|
||||
$msg_in_forms = (int)Db::getInstance()->getValue($query_forms);
|
||||
|
||||
$stats[] = array(
|
||||
'label' => $this->l('Messages received'),
|
||||
'color' => 'blue',
|
||||
'icon' => 'sign-in',
|
||||
'value1' => $total_msg,
|
||||
'value2' => sprintf(($total_forms > 1? $this->l('From %s forms') : $this->l('From %s form')), $msg_in_forms),
|
||||
'percent' => Tools::ps_round(($total_forms > 0 ? $msg_in_forms / $total_forms : 0) * 100, 0),
|
||||
'link' => $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true),
|
||||
);
|
||||
//2.Replied messages
|
||||
$query_reps = '
|
||||
SELECT COUNT(DISTINCT m.id_contact_message)
|
||||
FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message m
|
||||
INNER JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact_message_shop ms ON (ms.id_contact_message = m.id_contact_message AND ms.id_shop = 1)
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'ets_cfu_message_reply r ON (r.id_contact_message = m.id_contact_message)
|
||||
WHERE r.id_ets_cfu_message_reply is NOT NULL AND r.id_ets_cfu_message_reply != 0
|
||||
';
|
||||
$total_reps = (int)Db::getInstance()->getValue($query_reps);
|
||||
$stats[] = array(
|
||||
'label' => $this->l('Replied messages'),
|
||||
'color' => 'green',
|
||||
'icon' => 'share',
|
||||
'value1' => $total_reps,
|
||||
'value2' => Tools::ps_round(($percent = ($total_msg > 0 ? $total_reps / $total_msg : 0) * 100), 0) . '%',
|
||||
'percent' => $percent,
|
||||
'link' => $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true),
|
||||
);
|
||||
//3.Unread messages
|
||||
$query_reads = $query_msg . ' AND b.readed <= 0';
|
||||
$total_reads = (int)Db::getInstance()->getValue($query_reads);
|
||||
$stats[] = array(
|
||||
'label' => $this->l('Unread messages'),
|
||||
'color' => 'brown',
|
||||
'icon' => 'envelope',
|
||||
'value1' => $total_reads,
|
||||
'value2' => Tools::ps_round(($percent = ($total_msg > 0 ? $total_reads / $total_msg : 0) * 100), 0) . '%',
|
||||
'percent' => $percent,
|
||||
'link' => $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true),
|
||||
);
|
||||
//4.Users contacted
|
||||
$contact_is_reg = (int)Db::getInstance()->getValue('
|
||||
SELECT COUNT(DISTINCT m.id_customer) FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message m
|
||||
INNER JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact_message_shop ms ON (m.id_contact_message = ms.id_contact_message)
|
||||
WHERE id_customer is NOT NULL AND id_customer != 0
|
||||
GROUP BY id_customer
|
||||
');
|
||||
$total_contacts = (int)Db::getInstance()->getValue('
|
||||
SELECT COUNT(m.id_customer) FROM (
|
||||
SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_customer is NOT NULL AND id_customer != 0 GROUP BY id_customer
|
||||
UNION
|
||||
SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_customer is NULL OR id_customer = 0) as `m`
|
||||
INNER JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact_message_shop ms ON (m.id_contact_message = ms.id_contact_message)
|
||||
WHERE ms.id_shop = ' . (int)$this->context->shop->id . '
|
||||
');
|
||||
$stats[] = array(
|
||||
'label' => $this->l('Users contacted'),
|
||||
'color' => 'yellow',
|
||||
'icon' => 'users',
|
||||
'value1' => $total_contacts,
|
||||
'value2' => sprintf($this->l('%s registered'), $contact_is_reg),
|
||||
'percent' => Tools::ps_round(($total_contacts > 0 ? $contact_is_reg / $total_contacts : 0) * 100, 0),
|
||||
'link' => $this->context->link->getAdminLink('AdminCustomers', true),
|
||||
);
|
||||
//5.
|
||||
$sql_form_enabled = $sql_forms . ' AND b.active > 0';
|
||||
$total_form_enabled = (int)Db::getInstance()->getValue($sql_form_enabled);
|
||||
$stats[] = array(
|
||||
'label' => $this->l('Contact forms'),
|
||||
'color' => 'pink',
|
||||
'icon' => 'th-large',
|
||||
'value1' => $total_forms,
|
||||
'value2' => sprintf($this->l('%s enabled'), ($total_form_enabled != $total_forms ? $total_form_enabled : $this->l('All'))),
|
||||
'percent' => Tools::ps_round(($total_forms > 0 ? $total_form_enabled / $total_forms : 0) * 100, 0),
|
||||
'link' => $this->context->link->getAdminLink('AdminContactFormUltimateContactForm', true),
|
||||
);
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateEmailController extends ModuleAdminController
|
||||
{
|
||||
public $_html;
|
||||
public $_fields_form;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
$this->_fields_form = Ets_cfudefines::getInstance($this->module)->getFields('email');
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$errors = array();
|
||||
$id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$inputs = $this->_fields_form['form']['input'];
|
||||
$languages = Language::getLanguages(false);
|
||||
if (Tools::isSubmit('etsCfuBtnSubmit')) {
|
||||
if ($inputs) {
|
||||
foreach ($inputs as $input) {
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
if (isset($input['required']) && $input['required'] && !Tools::getValue($key . '_' . $id_lang_default))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate'])) {
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key . '_' . $id_lang_default))))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
else {
|
||||
if ($languages) {
|
||||
foreach ($languages as $lang) {
|
||||
if (Tools::getValue($key . '_' . $lang['id_lang']) && !Validate::$validate(trim(Tools::getValue($key . '_' . $lang['id_lang']))))
|
||||
$errors[] = $input['label'] . ' ' . $lang['iso_code'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($validate);
|
||||
}
|
||||
} elseif (isset($input['required']) && $input['required'] && !Tools::getValue($key))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate'])) {
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key))))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
unset($validate);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$errors)
|
||||
{
|
||||
if ($inputs) {
|
||||
foreach ($inputs as $input) {
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
$vals = array();
|
||||
foreach ($languages as $language) {
|
||||
$vals[$language['id_lang']] = Tools::getValue($key . '_' . $language['id_lang']) ? Tools::getValue($key . '_' . $language['id_lang']) : Tools::getValue($key . '_' . $id_lang_default);
|
||||
}
|
||||
Configuration::updateValue($key, $vals, true);
|
||||
} else {
|
||||
Configuration::updateValue($key, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateEmail') . '&conf=4');
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'form_config' => $this->module->renderFormEmail(),
|
||||
'errors' => $errors? $this->module->displayError($errors) : false,
|
||||
)
|
||||
);
|
||||
$this->_html .= $this->module->display($this->module->getLocalPath(), 'form.tpl');
|
||||
return $this->_html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateHelpController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'link_doc' => $this->module->getPathUri().'help/document.pdf',
|
||||
));
|
||||
return $this->module->display($this->module->getLocalPath(), 'help.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateImportExportController extends ModuleAdminController
|
||||
{
|
||||
public $_html;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$errors = array();
|
||||
if (Tools::isSubmit('etsCfuImportContactSubmit')) {
|
||||
$this->module->processImport();
|
||||
$errors = $this->module->getErrors();
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'controller' => Tools::getValue('controller'),
|
||||
'link' => $this->context->link,
|
||||
'errors' => $errors?$this->module->displayError($errors) : false,
|
||||
));
|
||||
$this->_html .= $this->module->display($this->module->getLocalPath(), 'form_import.tpl');
|
||||
return $this->_html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateIntegrationController extends ModuleAdminController
|
||||
{
|
||||
public $_html;
|
||||
public $_fields_form;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
$this->_fields_form = Ets_cfudefines::getInstance($this->module)->getFields('config');
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function renderList()
|
||||
{
|
||||
$errors = array();
|
||||
$id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$inputs = $this->_fields_form['form']['input'];
|
||||
$languages = Language::getLanguages(false);
|
||||
if (Tools::isSubmit('etsCfuImportContactSubmit')) {
|
||||
$this->module->processImport();
|
||||
$errors = $this->module->getErrors();
|
||||
} else {
|
||||
if (Tools::isSubmit('etsCfuBtnSubmit')) {
|
||||
if ($inputs) {
|
||||
foreach ($inputs as $input)
|
||||
{
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang'])
|
||||
{
|
||||
if (isset($input['required']) && $input['required'] && !Tools::getValue($key . '_' . $id_lang_default))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
}
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate']))
|
||||
{
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key . '_' . $id_lang_default))))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
elseif ($languages)
|
||||
{
|
||||
foreach ($languages as $lang)
|
||||
{
|
||||
if (Tools::getValue($key . '_' . $lang['id_lang']) && !Validate::$validate(trim(Tools::getValue($key . '_' . $lang['id_lang']))))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $lang['iso_code'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($validate);
|
||||
}
|
||||
}
|
||||
elseif (isset($input['required']) && $input['required'] && $this->fieldRequired($input))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
}
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate']))
|
||||
{
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key))))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
unset($validate);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$errors)
|
||||
{
|
||||
if ($inputs)
|
||||
{
|
||||
foreach ($inputs as $input)
|
||||
{
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang'])
|
||||
{
|
||||
$values = array();
|
||||
foreach ($languages as $language) {
|
||||
$values[$language['id_lang']] = Tools::getValue($key . '_' . $language['id_lang']) ? Tools::getValue($key . '_' . $language['id_lang']) : Tools::getValue($key . '_' . $id_lang_default);
|
||||
}
|
||||
Configuration::updateValue($key, $values, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Configuration::updateValue($key, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateIntegration') . '&conf=4¤t_tab=' . Tools::getValue('current_tab'));
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'form_config' => $this->module->renderFormConfig(),
|
||||
'errors' => $errors? $this->module->displayError($errors) : false,
|
||||
));
|
||||
$this->_html .= $this->module->display($this->module->getLocalPath(), 'form.tpl');
|
||||
return $this->_html;
|
||||
}
|
||||
|
||||
public function fieldRequired($input)
|
||||
{
|
||||
switch ($input['name']) {
|
||||
case 'ETS_CFU_SITE_KEY' :
|
||||
if ( Tools::getValue('ETS_CFU_ENABLE_RECAPTCHA') && Tools::getValue('ETS_CFU_RECAPTCHA_TYPE') == 'v2' && !Tools::getValue('ETS_CFU_SITE_KEY'))
|
||||
return true;
|
||||
break;
|
||||
case 'ETS_CFU_SECRET_KEY' :
|
||||
if (Tools::getValue('ETS_CFU_ENABLE_RECAPTCHA') && Tools::getValue('ETS_CFU_RECAPTCHA_TYPE') == 'v2' && !Tools::getValue('ETS_CFU_SECRET_KEY'))
|
||||
return true;
|
||||
break;
|
||||
case 'ETS_CFU_SITE_KEY_V3' :
|
||||
if ( Tools::getValue('ETS_CFU_ENABLE_RECAPTCHA') && Tools::getValue('ETS_CFU_RECAPTCHA_TYPE') == 'v3' && !Tools::getValue('ETS_CFU_SITE_KEY_V3'))
|
||||
return true;
|
||||
break;
|
||||
case 'ETS_CFU_SECRET_KEY_V3' :
|
||||
if (Tools::getValue('ETS_CFU_ENABLE_RECAPTCHA') && Tools::getValue('ETS_CFU_RECAPTCHA_TYPE') == 'v3' && !Tools::getValue('ETS_CFU_SECRET_KEY_V3'))
|
||||
return true;
|
||||
break;
|
||||
default :
|
||||
if (!Tools::getValue($input['name']))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class AdminContactFormUltimateIpBlacklistController extends ModuleAdminController
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $_html;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $_fields_form;
|
||||
|
||||
/**
|
||||
* AdminContactFormUltimateIpBlacklistController constructor.
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
$this->_fields_form = Ets_cfudefines::getInstance($this->module)->getFields('ip_black_list');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see parent::initContent();
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function renderList()
|
||||
{
|
||||
$errors = array();
|
||||
$id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$languages = Language::getLanguages(false);
|
||||
if (($inputs = $this->_fields_form['form']['input']) && Tools::isSubmit('etsCfuBtnSubmit'))
|
||||
{
|
||||
foreach ($inputs as $input)
|
||||
{
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang'])
|
||||
{
|
||||
if (isset($input['required']) && $input['required'] && !Tools::getValue($key . '_' . $id_lang_default))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
}
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate']))
|
||||
{
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key . '_' . $id_lang_default))))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
elseif ($languages)
|
||||
{
|
||||
foreach ($languages as $lang)
|
||||
{
|
||||
if (Tools::getValue($key . '_' . $lang['id_lang']) && !Validate::$validate(trim(Tools::getValue($key . '_' . $lang['id_lang']))))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $lang['iso_code'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($validate);
|
||||
}
|
||||
}
|
||||
elseif (isset($input['required']) && $input['required'] && !Tools::getValue($key))
|
||||
{
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is required');
|
||||
}
|
||||
elseif (isset($input['validate']) && method_exists('Validate', $input['validate']))
|
||||
{
|
||||
$validate = $input['validate'];
|
||||
if (!Validate::$validate(trim(Tools::getValue($key))))
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
unset($validate);
|
||||
}elseif ($key == 'ETS_CFU_IP_BLACK_LIST' && ($ip_blacklist = trim(Tools::getValue($key))) != '' && !preg_match('/^(([0-9A-Fa-f\.\*:])+(\n|(\r\n))*)+$/', $ip_blacklist)) {
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
} elseif($key == 'ETS_CFU_EMAIL_BLACK_LIST' && ($email_blacklist = trim(Tools::getValue($key))) != '' && !preg_match('/^(([a-z0-9\*@\-\._])+(\n|(\r\n))*)+$/i', $email_blacklist)) {
|
||||
$errors[] = $input['label'] . ' ' . $this->module->l('is invalid');
|
||||
}
|
||||
}
|
||||
if (!$errors)
|
||||
{
|
||||
foreach ($inputs as $input)
|
||||
{
|
||||
$key = $input['name'];
|
||||
if (isset($input['lang']) && $input['lang'])
|
||||
{
|
||||
$values = array();
|
||||
foreach ($languages as $language) {
|
||||
$values[$language['id_lang']] = Tools::getValue($key . '_' . $language['id_lang']) ? Tools::getValue($key . '_' . $language['id_lang']) : Tools::getValue($key . '_' . $id_lang_default);
|
||||
}
|
||||
Configuration::updateValue($key, $values, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Configuration::updateValue($key, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$errors)
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateIpBlacklist') . '&conf=4');
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'form_config' => $this->module->renderFormIpBlackList(),
|
||||
'errors' => $errors? $this->module->displayError($errors) : '',
|
||||
));
|
||||
$this->_html .= $this->module->display($this->module->getLocalPath(), 'form.tpl');
|
||||
return $this->_html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
require_once(_PS_MODULE_DIR_ . 'ets_cfultimate/classes/ETS_CFU_Contact_Reply.php');
|
||||
require_once(_PS_MODULE_DIR_ . 'ets_cfultimate/classes/ETS_CFU_Pagination.php');
|
||||
|
||||
class AdminContactFormUltimateMessageController extends ModuleAdminController
|
||||
{
|
||||
public $is170 =false;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->bootstrap = true;
|
||||
if (Ets_cfultimate::checkVersionPs('1.7.0','>=')){
|
||||
$this->is170 = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
if (Tools::isSubmit('etsCfuSubmitSpecialActionMessage') && $id_message = Tools::getValue('id_contact_message')) {
|
||||
$messages = array();
|
||||
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'ets_cfu_contact_message SET special="' . (int)Tools::getValue('etsCfuSubmitSpecialActionMessage') . '" WHERE id_contact_message ="' . (int)$id_message . '"');
|
||||
$messages[$id_message] = $this->displayRowMessage($id_message);
|
||||
die(
|
||||
Tools::jsonEncode(
|
||||
array(
|
||||
'ok' => true,
|
||||
'messages' => $messages,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (Tools::isSubmit('etsCfuSubmitBulkActionMessage')) {
|
||||
$bulk_action_message = Tools::getValue('bulk_action_message');
|
||||
if ($bulk_action_message && Tools::getValue('etsCfuMessageReaded')) {
|
||||
if ($bulk_action_message == 'mark_as_read') {
|
||||
$messages = array();
|
||||
foreach (Tools::getValue('etsCfuMessageReaded') as $key => $value) {
|
||||
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'ets_cfu_contact_message SET readed=1 WHERE id_contact_message ="' . (int)$key . '"');
|
||||
unset($value);
|
||||
$messages[$key] = $this->displayRowMessage($key);
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode(
|
||||
array(
|
||||
'ok' => true,
|
||||
'messages' => $messages,
|
||||
'count_messages' => $this->module->getCountUnreadMessage(),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
} elseif ($bulk_action_message == 'mark_as_unread') {
|
||||
$messages = array();
|
||||
foreach (Tools::getValue('etsCfuMessageReaded') as $key => $value) {
|
||||
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'ets_cfu_contact_message SET readed=0 WHERE id_contact_message ="' . (int)$key . '"');
|
||||
unset($value);
|
||||
$messages[$key] = $this->displayRowMessage($key);
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode(
|
||||
array(
|
||||
'ok' => true,
|
||||
'messages' => $messages,
|
||||
'count_messages' => $this->module->getCountUnreadMessage(),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
} elseif ($bulk_action_message == 'delete_selected') {
|
||||
foreach (Tools::getValue('etsCfuMessageReaded') as $key => $value) {
|
||||
$attachments = Db::getInstance()->getValue('SELECT attachments FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_contact_message="' . (int)$key . '"');
|
||||
if ($attachments) {
|
||||
foreach (explode(',', $attachments) as $attachment) {
|
||||
@unlink(dirname(__FILE__) . '/../../views/img/etscfu_upload/' . $attachment);
|
||||
}
|
||||
}
|
||||
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_contact_message ="' . (int)$key . '"');
|
||||
unset($value);
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode(
|
||||
array(
|
||||
'ok' => true,
|
||||
'url_reload' => $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true) . '&conf=1'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
//reply message.
|
||||
if (Tools::isSubmit('etsCfuSubmitReplyMessage') && $id_message = Tools::getValue('id_message')) {
|
||||
$reply = new ETS_CFU_Contact_Reply();
|
||||
$errors = array();
|
||||
$context = Context::getContext();
|
||||
$template = Configuration::get('ETS_CFU_ENABLE_TEMPLATE') ? 'contact_reply_form_ultimate' : 'contact_reply_form_ultimate_plain';
|
||||
$configuration = Configuration::getMultiple(
|
||||
array(
|
||||
'PS_SHOP_EMAIL',
|
||||
'PS_SHOP_NAME',
|
||||
'PS_MAIL_TYPE',
|
||||
),
|
||||
null,
|
||||
null, $context->shop->id
|
||||
);
|
||||
if( !Tools::getValue('reply_to')){
|
||||
$errors[] = $this->module->l('Reply to is required');
|
||||
}
|
||||
if( !Tools::getValue('reply_subject')){
|
||||
$errors[] = $this->module->l('Subject is required');
|
||||
}
|
||||
if (!Tools::getValue('message_reply')) {
|
||||
$errors[] = $this->module->l('Message is required');
|
||||
}
|
||||
if (!Ets_CfUltimate::getEmailToString(Tools::getValue('reply_to'))) {
|
||||
$errors[] = $this->module->l('Email is not validate');
|
||||
}
|
||||
if (!$errors){
|
||||
$mail_temp = $this->module->getLocalPath() . 'mails/'.$context->language->iso_code.'/'.$template;
|
||||
$msg = $this->module->l('Error - The following e-mail template is missing: %s');
|
||||
if (!file_exists(($file = $mail_temp.'.txt')) && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT)) {
|
||||
$errors[] = sprintf($msg, $file);
|
||||
} else if (!file_exists(($file = $mail_temp.'.html')) && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML)) {
|
||||
$errors[] = sprintf($msg, $file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'error' => $this->module->displayError($errors),
|
||||
)));
|
||||
} else {
|
||||
$template_email = Configuration::get('ETS_CFU_EMAIL_REPLY_TEMPLATE', Context::getContext()->language->id);
|
||||
$template_vars = array(
|
||||
'{message_content}' => Configuration::get('ETS_CFU_ENABLE_TEMPLATE') ? str_replace(
|
||||
array('{message_content}', '%7Bshop_url%7D', '%7Bshop_logo%7D'),
|
||||
array(Tools::getValue('message_reply'), '{shop_url}', '{shop_logo}'),
|
||||
$template_email
|
||||
) : Tools::getValue('message_reply'),
|
||||
);
|
||||
$toEmail = Ets_CfUltimate::getEmailToString(Tools::getValue('reply_to'));
|
||||
$toName = str_replace(array('<', '>', $toEmail), '', Tools::getValue('reply_to'));
|
||||
$fromEmail = Ets_CfUltimate::getEmailToString(Tools::getValue('from_reply'));
|
||||
$fromName = str_replace(array('<', '>', $fromEmail), '', Tools::getValue('from_reply'));
|
||||
$replyTo = Ets_CfUltimate::getEmailToString(Tools::getValue('reply_to_reply'));
|
||||
$replyToName = trim(str_replace(array('<', '>', $replyTo), '', Tools::getValue('reply_to_reply')));
|
||||
if (Mail::Send(
|
||||
Context::getContext()->language->id,
|
||||
$template,
|
||||
Tools::getValue('reply_subject'),
|
||||
$template_vars,
|
||||
$toEmail,
|
||||
$toName ? $toName : null,
|
||||
$fromEmail ? $fromEmail : null,
|
||||
$fromName ? $fromName : null,
|
||||
null,
|
||||
null,
|
||||
$this->module->getLocalPath() . 'mails/',
|
||||
null,
|
||||
Context::getContext()->shop->id,
|
||||
$replyTo ? $replyTo : null,
|
||||
$replyToName ? $replyToName : null
|
||||
)) {
|
||||
$reply->id_contact_message = $id_message;
|
||||
$reply->content = Tools::getValue('message_reply');
|
||||
$reply->id_employee = $this->context->employee->id;
|
||||
$reply->reply_to = Tools::getValue('reply_to');
|
||||
$reply->subject = Tools::getValue('reply_subject');
|
||||
$reply->add();
|
||||
die(Tools::jsonEncode(array(
|
||||
'success' => $this->module->l('Your message has been successfully sent'),
|
||||
'message_reply' => Tools::getValue('message_reply'),
|
||||
'id_message' => $id_message,
|
||||
'reply' => $this->module->displayReplyMessage($reply),
|
||||
)));
|
||||
} else {
|
||||
$errors[] = $this->module->l('An error occurred while sending the message');
|
||||
die(Tools::jsonEncode(array(
|
||||
'error' => $this->module->displayError($errors),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*end reply msg*/
|
||||
|
||||
if (Tools::isSubmit('etsCfuDeleteMessage') && $id_message = Tools::getValue('id_message')) {
|
||||
$attachments = Db::getInstance()->getValue('SELECT attachments FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_contact_message="' . (int)$id_message . '"');
|
||||
if ($attachments) {
|
||||
foreach (explode(',', $attachments) as $attachment) {
|
||||
@unlink(dirname(__FILE__) . '/../../views/img/etscfu_upload/' . $attachment);
|
||||
}
|
||||
}
|
||||
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message WHERE id_contact_message="' . (int)$id_message . '"');
|
||||
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message_shop where id_contact_message=' . (int)$id_message);
|
||||
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'ets_cfu_message_reply WHERE id_contact_message=' . (int)$id_message);
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateMessage', true) . '&conf=1');
|
||||
}
|
||||
if (Tools::isSubmit('etsCfuAjax') && Tools::isSubmit('etsCfuViewMessage') && $id_message = Tools::getValue('id_message'))
|
||||
{
|
||||
$message = $this->getMessageById($id_message);
|
||||
if ($message['reply_to'] && Ets_CfUltimate::getEmailToString($message['reply_to'])) {
|
||||
$message['reply_to_check'] = true;
|
||||
} else
|
||||
$message['reply_to_check'] = false;
|
||||
if ($message)
|
||||
{
|
||||
$replies = $this->getRepliesByIdMessage($id_message);
|
||||
$this->context->smarty->assign(array(
|
||||
'message' => $message,
|
||||
'replies' => $replies,
|
||||
'is170' => $this->is170
|
||||
));
|
||||
$message_html = $this->module->display(_PS_MODULE_DIR_ . $this->module->name . DIRECTORY_SEPARATOR . $this->module->name . '.php', 'message.tpl');
|
||||
|
||||
if (!Validate::isCleanHtml($message_html, true)) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'errors' => $this->module->l('Message invalid.'),
|
||||
)));
|
||||
}
|
||||
$messages = array();
|
||||
if (!Tools::getValue('etsCfuMessageReaded'))
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'ets_cfu_contact_message SET readed="1" WHERE id_contact_message ="' . (int)$id_message . '"');
|
||||
$messages[$id_message] = $this->displayRowMessage($id_message);
|
||||
}
|
||||
die(Tools::jsonEncode(array(
|
||||
'message_html' => $message_html,
|
||||
'messages' => $messages,
|
||||
'count_messages' => $this->module->getCountUnreadMessage(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function displayRowMessage($message)
|
||||
{
|
||||
if (!is_array($message))
|
||||
$message = $this->getMessageById($message);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'message' => $message,
|
||||
)
|
||||
);
|
||||
return $this->module->display($this->module->getLocalPath(), 'row-message.tpl');
|
||||
}
|
||||
|
||||
public function getMessageById($id_message)
|
||||
{
|
||||
$message = Db::getInstance()->getRow('
|
||||
SELECT m.*,cl.title,c.save_attachments ,c.email_to, CONCAT(cu.firstname," ",cu.lastname) as customer_name ,log.ip
|
||||
FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_message m
|
||||
INNER JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact_message_shop ms ON (m.id_contact_message=ms.id_contact_message)
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact c ON (c.id_contact=m.id_contact)
|
||||
lEFT JOIN ' . _DB_PREFIX_ . 'ets_cfu_contact_lang cl on (c.id_contact=cl.id_contact AND cl.id_lang="' . (int)$this->context->language->id . '")
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'customer cu ON (m.id_customer=cu.id_customer)
|
||||
LEFT JOIN '._DB_PREFIX_.'ets_cfu_log log ON (log.id_contact = m.id_contact)
|
||||
WHERE ms.id_shop="' . (int)Context::getContext()->shop->id . '" AND m.id_contact_message=' . (int)$id_message);
|
||||
if (trim($message['attachments']))
|
||||
$message['attachments'] = explode(',', trim($message['attachments']));
|
||||
else
|
||||
$message['attachments'] = '';
|
||||
$message['replies'] = $this->getRepliesByIdMessage($message['id_contact_message']);
|
||||
$message['from_reply'] = Configuration::get('PS_SHOP_NAME') . ' <' . (Configuration::get('PS_MAIL_METHOD') == 2 ? Configuration::get('PS_MAIL_USER') : Configuration::get('PS_SHOP_EMAIL')) . '>';
|
||||
$message['reply'] = Configuration::get('PS_SHOP_NAME') . ' <' . Configuration::get('PS_SHOP_EMAIL') . '>';
|
||||
$message['email_to'] = explode(',',trim($message['email_to']))[0];
|
||||
return $message;
|
||||
}
|
||||
|
||||
public function getRepliesByIdMessage($id_message)
|
||||
{
|
||||
$replies = Db::getInstance()->executeS('
|
||||
SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_message_reply
|
||||
WHERE id_contact_message="' . (int)$id_message . '"'
|
||||
);
|
||||
return $replies;
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
if (Tools::isSubmit('etsCfuViewMessage') && $id_message = Tools::getValue('id_message')) {
|
||||
$message = $this->getMessageById($id_message);
|
||||
if ($message['reply_to'] && Ets_CfUltimate::getEmailToString($message['reply_to'])) {
|
||||
$message['reply_to_check'] = True;
|
||||
} else
|
||||
$message['reply_to_check'] = false;
|
||||
if ($message) {
|
||||
$replies = $this->getRepliesByIdMessage($id_message);
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'message' => $message,
|
||||
'replies' => $replies,
|
||||
'base_url' => $this->module->getBaseLink(),
|
||||
'is170' => $this->is170
|
||||
)
|
||||
);
|
||||
return $this->module->display(_PS_MODULE_DIR_ . $this->module->name . DIRECTORY_SEPARATOR . $this->module->name . '.php', 'message.tpl');
|
||||
}
|
||||
} else {
|
||||
$filter = '';
|
||||
$url_extra = '';
|
||||
$values_submit = array();
|
||||
if (Tools::getValue('id_contact')) {
|
||||
$filter .= ' AND m.id_contact="' . (int)Tools::getValue('id_contact') . '"';
|
||||
$url_extra .= '&id_contact=' . (int)Tools::getValue('id_contact');
|
||||
$values_submit['id_contact'] = Tools::getValue('id_contact');
|
||||
}
|
||||
if (Tools::getValue('id_contact_message')) {
|
||||
$filter .= ' AND m.id_contact_message="' . (int)Tools::getValue('id_contact_message') . '"';
|
||||
$url_extra .= '&id_contact_message=' . (int)Tools::getValue('id_contact_message');
|
||||
$values_submit['id_contact_message'] = (int)Tools::getValue('id_contact_message');
|
||||
}
|
||||
if (Tools::getValue('subject')) {
|
||||
$filter .= ' AND m.subject like "%' . Tools::getValue('subject') . '%"';
|
||||
$url_extra .= '&subject=' . Tools::getValue('subject');
|
||||
$values_submit['subject'] = Tools::getValue('subject');
|
||||
}
|
||||
if (Tools::getValue('sender')) {
|
||||
$filter .= ' AND m.sender like "%' . Tools::getValue('sender') . '%"';
|
||||
$url_extra .= '&sender=' . Tools::getValue('sender');
|
||||
$values_submit['sender'] = Tools::getValue('sender');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_dateadd_from')) {
|
||||
$filter .= ' AND m.date_add >="' . Tools::getValue('messageFilter_dateadd_from') . '"';
|
||||
$url_extra .= '&messageFilter_dateadd_from=' . Tools::getValue('messageFilter_dateadd_from');
|
||||
$values_submit['messageFilter_dateadd_from'] = Tools::getValue('messageFilter_dateadd_from');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_dateadd_to')) {
|
||||
$filter .= ' AND m.date_add <= "' . Tools::getValue('messageFilter_dateadd_to') . '"';
|
||||
$url_extra .= '&messageFilter_dateadd_to=' . Tools::getValue('messageFilter_dateadd_to');
|
||||
$values_submit['messageFilter_dateadd_to'] = Tools::getValue('messageFilter_dateadd_to');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_replied') != '') {
|
||||
if (Tools::getValue('messageFilter_replied') == 0)
|
||||
$filter .= ' AND m.id_contact_message NOT IN (SELECT id_contact_message FROM ' . _DB_PREFIX_ . 'ets_cfu_message_reply)';
|
||||
else
|
||||
$filter .= ' AND m.id_contact_message IN (SELECT id_contact_message FROM ' . _DB_PREFIX_ . 'ets_cfu_message_reply)';
|
||||
$url_extra .= '&messageFilter_replied=' . Tools::getValue('messageFilter_replied');
|
||||
$values_submit['messageFilter_replied'] = Tools::getValue('messageFilter_replied');
|
||||
}
|
||||
if (Tools::getValue('messageFilter_message') != '') {
|
||||
$filter .= ' AND m.body like "%' . pSQL(Tools::getValue('messageFilter_message')) . '%"';
|
||||
$url_extra .= '&messageFilter_message=' . Tools::getValue('messageFilter_message');
|
||||
$values_submit['messageFilter_message'] = Tools::getValue('messageFilter_message');
|
||||
}
|
||||
$url_extra_no_order = $url_extra;
|
||||
if (Tools::getValue('OrderBy') != '' && Tools::getValue('OrderBy') != 'm.id_contact_message') {
|
||||
$orderBy = Tools::getValue('OrderBy') . ' ' . Tools::getValue('OrderWay', 'DESC') . ',m.id_contact_message DESC';
|
||||
$url_extra .= '&OrderBy=' . Tools::getValue('OrderBy') . '&OrderWay=' . Tools::getValue('OrderWay', 'DESC');
|
||||
} else {
|
||||
$orderBy = Tools::getValue('OrderBy', 'm.id_contact_message') . ' ' . Tools::getValue('OrderWay', 'DESC');
|
||||
}
|
||||
$totalMessage = $this->module->getMessages($filter, 0, 0, true, $orderBy);
|
||||
$limit = Configuration::get('ETS_CFU_NUMBER_MESSAGE') ? Configuration::get('ETS_CFU_NUMBER_MESSAGE') : 20;
|
||||
$page = Tools::getValue('page', 1);
|
||||
$start = ($page - 1) * $limit;
|
||||
$pagination = new ETS_CFU_Pagination();
|
||||
$pagination->url = $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true) . $url_extra . '&page=_page_';
|
||||
$pagination->limit = $limit;
|
||||
$pagination->page = $page;
|
||||
$pagination->total = $totalMessage;
|
||||
if (Tools::isSubmit('etsCfuSubmitExportButtonMessage')) {
|
||||
ob_get_clean();
|
||||
ob_start();
|
||||
$messages = $this->module->getMessages($filter);
|
||||
$csv = "Subject\tFrom\tContact Form\tMessage\tDate" . "\r\n";
|
||||
foreach ($messages as $row) {
|
||||
$message = array();
|
||||
$message[] = $row['subject'];
|
||||
$message[] = $row['sender'];
|
||||
$message[] = $row['title'];
|
||||
$message[] = str_replace("\n", '', strip_tags($row['body']));
|
||||
$message[] = $row['date_add'];
|
||||
$csv .= join("\t", $message) . "\r\n";
|
||||
}
|
||||
$csv = chr(255) . chr(254) . mb_convert_encoding($csv, "UTF-16LE", "UTF-8");
|
||||
header("Content-type: application/x-msdownload");
|
||||
header("Content-disposition: csv; filename=" . date("Y-m-d") .
|
||||
"_message_list.csv; size=" . Tools::strlen($csv));
|
||||
echo $csv;
|
||||
exit();
|
||||
}
|
||||
$messages = $this->module->getMessages($filter, $start, $limit, false, $orderBy);
|
||||
if ($messages) {
|
||||
foreach ($messages as &$message) {
|
||||
$message['replies'] = $this->getRepliesByIdMessage($message['id_contact_message']);
|
||||
$message['row_message'] = $this->displayRowMessage($message);
|
||||
}
|
||||
|
||||
}
|
||||
$contacts = $this->module->getContacts();
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'messages' => $messages,
|
||||
'ets_cfu_contacts' => $contacts,
|
||||
'url_module' => $this->context->link->getAdminLink('AdminModules', true) . '&configure=' . $this->module->name . '&tab_module=' . $this->module->tab . '&module_name=' . $this->module->name,
|
||||
'link' => $this->context->link,
|
||||
'base_url' => $this->module->getBaseLink(),
|
||||
'filter' => $filter,
|
||||
'is_ps15' => version_compare(_PS_VERSION_, '1.6', '<') ? true : false,
|
||||
'ets_cfu_pagination_text' => $pagination->render(),
|
||||
'values_submit' => $values_submit,
|
||||
'url_full' => $this->context->link->getAdminLink('AdminContactFormUltimateMessage', true) . $url_extra_no_order . '&page=' . Tools::getValue('page', 1),
|
||||
'orderBy' => Tools::getValue('OrderBy', 'm.id_contact_message'),
|
||||
'orderWay' => Tools::getValue('OrderWay', 'DESC'),
|
||||
)
|
||||
);
|
||||
return $this->module->display($this->module->getLocalPath(), 'list-message.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateSettingController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateEmail', true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
require_once(_PS_MODULE_DIR_ . 'ets_cfultimate/classes/ETS_CFU_Pagination.php');
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class AdminContactFormUltimateStatisticsController extends AdminModuleAdapterController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->charts = array(
|
||||
'mes' => array(
|
||||
'label' => $this->l('Messages'),
|
||||
),
|
||||
'vie' => array(
|
||||
'label' => $this->l('Views'),
|
||||
),
|
||||
'rep' => array(
|
||||
'label' => $this->l('Replies'),
|
||||
),
|
||||
'use' => array(
|
||||
'label' => $this->l('Users'),
|
||||
),
|
||||
);
|
||||
if ($ip = Tools::getValue('etsCfuAddToBlackList'))
|
||||
{
|
||||
$black_list = explode("\n", Configuration::get('ETS_CFU_IP_BLACK_LIST'));
|
||||
$black_list[] = $ip;
|
||||
Configuration::updateValue('ETS_CFU_IP_BLACK_LIST', implode("\n", $black_list));
|
||||
if (Tools::isSubmit('etsCfuAjax')) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'ok' => true,
|
||||
)));
|
||||
}
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateStatistics') . '&cfu_tab_ets=view-log');
|
||||
}
|
||||
if (Tools::isSubmit('etsCfuClearLogSubmit'))
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE id_contact IN (SELECT id_contact FROM ' . _DB_PREFIX_ . 'ets_cfu_contact_shop WHERE id_shop=' . (int)$this->context->shop->id . ')');
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminContactFormUltimateStatistics') . '&cfu_tab_ets=view-log&conf=1');
|
||||
}
|
||||
}
|
||||
public function renderList()
|
||||
{
|
||||
$assigns = $this->getCharts();
|
||||
$contacts = Db::getInstance()->executeS('
|
||||
SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_contact c, ' . _DB_PREFIX_ . 'ets_cfu_contact_lang cl
|
||||
WHERE c.id_contact=cl.id_contact AND cl.id_lang=' . (int)$this->context->language->id
|
||||
);
|
||||
$sql = "
|
||||
SELECT * FROM " . _DB_PREFIX_ . "ets_cfu_log l
|
||||
INNER JOIN " . _DB_PREFIX_ . "ets_cfu_contact c ON (l.id_contact=c.id_contact)
|
||||
LEFT JOIN " . _DB_PREFIX_ . "ets_cfu_contact_lang cl ON (c.id_contact=cl.id_contact AND cl.id_lang='" . (int)$this->context->language->id . "')
|
||||
GROUP BY l.ip,l.id_contact,l.datetime_added
|
||||
";
|
||||
$total = count(Db::getInstance()->executeS($sql));
|
||||
$limit = 20;
|
||||
$page = Tools::getValue('page', 1);
|
||||
if ($page <= 0)
|
||||
$page = 1;
|
||||
$start = ($page - 1) * $limit;
|
||||
$pagination = new ETS_CFU_Pagination();
|
||||
$pagination->url = $this->context->link->getAdminLink('AdminContactFormUltimateStatistics') . '&cfu_tab_ets=view-log&page=_page_';
|
||||
$pagination->limit = $limit;
|
||||
$pagination->page = $page;
|
||||
$pagination->total = $total;
|
||||
$sql = "
|
||||
SELECT * FROM " . _DB_PREFIX_ . "ets_cfu_log l
|
||||
INNER JOIN " . _DB_PREFIX_ . "ets_cfu_contact c ON (l.id_contact=c.id_contact)
|
||||
LEFT JOIN " . _DB_PREFIX_ . "ets_cfu_contact_lang cl ON (c.id_contact=cl.id_contact AND cl.id_lang='" . (int)$this->context->language->id . "')
|
||||
LEFT JOIN " . _DB_PREFIX_ . "customer cu ON (l.id_customer=cu.id_customer)
|
||||
GROUP BY l.ip,l.id_contact,l.datetime_added ORDER BY l.datetime_added DESC LIMIT " . (int)$start . ", " . (int)$limit;
|
||||
if (($logs = Db::getInstance()->executeS($sql)))
|
||||
{
|
||||
$black_list = explode("\n", Configuration::get('ETS_CFU_IP_BLACK_LIST'));
|
||||
foreach ($logs as &$log) {
|
||||
if (in_array($log['ip'], $black_list))
|
||||
$log['black_list'] = true;
|
||||
else
|
||||
$log['black_list'] = false;
|
||||
$browser = explode(' ', $log['browser']);
|
||||
if (isset($browser[0]))
|
||||
$log['class'] = Tools::strtolower($browser[0]);
|
||||
else
|
||||
$log['class'] = 'default';
|
||||
}
|
||||
}
|
||||
$assigns = array_merge($assigns, array(
|
||||
'action' => $this->context->link->getAdminLink('AdminContactFormUltimateStatistics'),
|
||||
'ets_cfu_js_dir_path' => $this->module->getPathUri() . 'views/js/',
|
||||
'ets_cfu_logs' => $logs,
|
||||
'cfu_tab_ets' => Tools::getValue('cfu_tab_ets', 'chart'),
|
||||
'ets_cfu_pagination_text' => $pagination->render(),
|
||||
'ets_cfu_show_reset' => Tools::isSubmit('etsCfuSubmitFilterChart'),
|
||||
'ets_cfu_contacts' => $contacts,
|
||||
));
|
||||
$this->context->smarty->assign($assigns);
|
||||
return $this->module->display($this->module->getLocalPath(), 'statistics.tpl');
|
||||
}
|
||||
}
|
||||
31
modules/ets_cfultimate/controllers/admin/index.php
Normal file
31
modules/ets_cfultimate/controllers/admin/index.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
123
modules/ets_cfultimate/controllers/front/captcha.php
Normal file
123
modules/ets_cfultimate/controllers/front/captcha.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class Ets_CfUltimateCaptchaModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->create_image();
|
||||
die;
|
||||
}
|
||||
|
||||
public function create_image()
|
||||
{
|
||||
$security_code = Tools::substr(sha1(mt_rand()), 17, 6);
|
||||
$context = Context::getContext();
|
||||
$captcha_name = Tools::getValue('captcha_name');
|
||||
if (Tools::getValue('page') == 'contact')
|
||||
$context->cookie->$captcha_name = $security_code;
|
||||
else
|
||||
$context->cookie->$captcha_name = $security_code;
|
||||
$context->cookie->write();
|
||||
if (Tools::getValue('theme') == 'colorful') {
|
||||
|
||||
$image = imagecreatetruecolor(150, 35);
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$white = imagecolorallocate($image, 255, 255, 255);
|
||||
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
|
||||
$green = imagecolorallocatealpha($image, 0, 255, 0, 75);
|
||||
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
|
||||
|
||||
imagefilledrectangle($image, 0, 0, $width, $height, $white);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
|
||||
imagefilledrectangle($image, 0, 0, $width, 0, $black);
|
||||
imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
|
||||
imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
|
||||
imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
|
||||
|
||||
imagestring($image, 10, (int)(($width - (Tools::strlen($security_code) * 9)) / 2), (int)(($height - 15) / 2), $security_code, $black);
|
||||
} else {
|
||||
$width = 100;
|
||||
$height = 30;
|
||||
$image = ImageCreate($width, $height);
|
||||
$white = ImageColorAllocate($image, 255, 255, 255);
|
||||
$black = ImageColorAllocate($image, 27, 79, 166);
|
||||
$noise_color = imagecolorallocate($image, 172, 211, 255);
|
||||
$background_color = imagecolorallocate($image, 255, 255, 255);
|
||||
//$text_color = imagecolorallocate($image, 20, 40, 100);
|
||||
ImageFill($image, 0, 0, $background_color);
|
||||
for ($i = 0; $i < ($width * $height) / 3; $i++) {
|
||||
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
|
||||
}
|
||||
for ($i = 0; $i < ($width * $height) / 150; $i++) {
|
||||
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
|
||||
}
|
||||
imagestring($image, 10, 30, 6, $security_code, $black);
|
||||
}
|
||||
header("Content-Type: image/jpeg");
|
||||
ImageJpeg($image);
|
||||
ImageDestroy($image);
|
||||
exit();
|
||||
}
|
||||
|
||||
/*function to convert hex value to rgb array*/
|
||||
protected function hexToRGB($colour)
|
||||
{
|
||||
if ($colour[0] == '#') {
|
||||
$colour = Tools::substr($colour, 1);
|
||||
}
|
||||
if (Tools::strlen($colour) == 6) {
|
||||
list($r, $g, $b) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
|
||||
} elseif (Tools::strlen($colour) == 3) {
|
||||
list($r, $g, $b) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$r = hexdec($r);
|
||||
$g = hexdec($g);
|
||||
$b = hexdec($b);
|
||||
return array('r' => $r, 'g' => $g, 'b' => $b);
|
||||
}
|
||||
|
||||
|
||||
/*function to get center position on image*/
|
||||
protected function ImageTTFCenter($image, $text, $font, $size, $angle = 8)
|
||||
{
|
||||
$xi = imagesx($image);
|
||||
$yi = imagesy($image);
|
||||
$box = imagettfbbox($size, $angle, $font, $text);
|
||||
$xr = abs(max($box[2], $box[4])) + 5;
|
||||
$yr = abs(max($box[5], $box[7]));
|
||||
$x = (int)(($xi - $xr) / 2);
|
||||
$y = (int)(($yi + $yr) / 2);
|
||||
return array($x, $y);
|
||||
}
|
||||
}
|
||||
91
modules/ets_cfultimate/controllers/front/contact.php
Normal file
91
modules/ets_cfultimate/controllers/front/contact.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateContactModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias);
|
||||
}
|
||||
|
||||
if ( Configuration::get('PS_REWRITING_SETTINGS') && $id_contact && (Tools::strpos($_SERVER['REQUEST_URI'],'url_alias')!==false || Tools::strpos($_SERVER['REQUEST_URI'],'id_contact')!==false)){
|
||||
$url = $this->module->getLinkContactForm($id_contact,$this->context->language->id);
|
||||
Tools::redirect($url);
|
||||
}
|
||||
|
||||
$this->module->setMetas($id_contact);
|
||||
|
||||
$ip = Tools::getRemoteAddr();
|
||||
$browser = $this->module->getDevice();
|
||||
if (!Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE ip="' . pSQL($ip) . '" AND DAY(datetime_added) ="' . pSQL(date('d')) . '" AND MONTH(datetime_added) ="' . pSQL(date('m')) . '" AND YEAR(datetime_added) ="' . pSQL(date('Y')) . '" AND id_contact=' . (int)$id_contact)) {
|
||||
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'ets_cfu_log(ip,id_contact,browser,id_customer,datetime_added) VALUES ("' . pSQL($ip) . '","' . (int)$id_contact . '","' . pSQL($browser) . '","' . (int)Context::getContext()->customer->id . '","' . pSQL(date('Y-m-d h:i:s')) . '")');
|
||||
}
|
||||
if (Tools::getValue('action') == 'etsCfuAddLogger') {
|
||||
die(Tools::jsonEncode(array(
|
||||
'sus' => true
|
||||
)));
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
if ($contact->id && $contact->active && $contact->enable_form_page && $this->module->existContact($id_contact) && ($this->context->customer->logged || !$contact->only_customer )) {
|
||||
$contact_form = $this->module->ets_cfu_contact_form($contact->id);
|
||||
$this->context->smarty->assign(array(
|
||||
'form_html' => $this->module->form_html($contact_form),
|
||||
'contact' => $contact,
|
||||
'link_contact' => $this->module->getLinkContactForm($id_contact),
|
||||
));
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('contactform16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/contactform.tpl');
|
||||
}
|
||||
} elseif (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('not-found16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/not-found.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<'))
|
||||
return;
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias);
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
$breadcrumb['links'][] = array(
|
||||
'title' => $contact->title,
|
||||
'url' => $this->module->getLinkContactForm($id_contact),
|
||||
);
|
||||
return $breadcrumb;
|
||||
}
|
||||
}
|
||||
31
modules/ets_cfultimate/controllers/front/index.php
Normal file
31
modules/ets_cfultimate/controllers/front/index.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
56
modules/ets_cfultimate/controllers/front/submit.php
Normal file
56
modules/ets_cfultimate/controllers/front/submit.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateSubmitModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
if ($id = (int)Tools::getValue('_ets_cfu_container_post')) {
|
||||
$item = ets_cfu_contact_form($id);
|
||||
$result = $item->submit();
|
||||
$unit_tag = Tools::getValue('_ets_cfu_unit_tag');
|
||||
$response = array(
|
||||
'into' => '#' . ets_cfu_sanitize_unit_tag($unit_tag),
|
||||
'status' => $result['status'],
|
||||
'message' => $result['message'],
|
||||
);
|
||||
if ('validation_failed' == $result['status']) {
|
||||
$invalid_fields = array();
|
||||
foreach ((array)$result['invalid_fields'] as $name => $field) {
|
||||
$invalid_fields[] = array(
|
||||
'into' => 'span.ets_cfu_form-control-wrap.' . ets_cfu_sanitize_html_class($name),
|
||||
'message' => $field['reason'],
|
||||
'idref' => $field['idref'],
|
||||
);
|
||||
}
|
||||
|
||||
$response['invalidFields'] = $invalid_fields;
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode($response)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
modules/ets_cfultimate/controllers/front/thank.php
Normal file
95
modules/ets_cfultimate/controllers/front/thank.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateThankModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias,null,true);
|
||||
}
|
||||
|
||||
if ( Configuration::get('PS_REWRITING_SETTINGS') && $id_contact && (Tools::strpos($_SERVER['REQUEST_URI'],'url_alias')!==false || Tools::strpos($_SERVER['REQUEST_URI'],'id_contact')!==false)){
|
||||
$url = $this->module->getLinkContactForm($id_contact,$this->context->language->id);
|
||||
Tools::redirect($url);
|
||||
}
|
||||
|
||||
$this->module->setMetas($id_contact,true);
|
||||
$ip = Tools::getRemoteAddr();
|
||||
$browser = $this->module->getDevice();
|
||||
if (!Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE ip="' . pSQL($ip) . '" AND DAY(datetime_added) ="' . pSQL(date('d')) . '" AND MONTH(datetime_added) ="' . pSQL(date('m')) . '" AND YEAR(datetime_added) ="' . pSQL(date('Y')) . '" AND id_contact=' . (int)$id_contact)) {
|
||||
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'ets_cfu_log(ip,id_contact,browser,id_customer,datetime_added) VALUES ("' . pSQL($ip) . '","' . (int)$id_contact . '","' . pSQL($browser) . '","' . (int)Context::getContext()->customer->id . '","' . pSQL(date('Y-m-d h:i:s')) . '")');
|
||||
}
|
||||
if (Tools::getValue('action') == 'etsCfuAddLogger') {
|
||||
die(Tools::jsonEncode(array(
|
||||
'sus' => true
|
||||
)));
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
if ($contact->id && $contact->active && $this->module->existContact($id_contact)) {
|
||||
$contact_form = $this->module->ets_cfu_contact_form($contact->id);
|
||||
$base_url = Ets_CfUltimate::getLinkContactForm($id_contact,(int)Context::getContext()->language->id,'thank');
|
||||
$base_url .=$contact->thank_you_alias;
|
||||
$this->context->smarty->assign(array(
|
||||
'contact' => $contact,
|
||||
'link_contact' => $base_url,
|
||||
'thank_you_page_title' => $contact_form->thank_you_page_title,
|
||||
'thank_you_message' => $contact_form->thank_you_message
|
||||
));
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('thank-page16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/thank-page.tpl');
|
||||
}
|
||||
} elseif (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('not-found16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/not-found.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<'))
|
||||
return;
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias,null, true);
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
$base_url = Ets_CfUltimate::getLinkContactForm($id_contact,(int)Context::getContext()->language->id,'thank');
|
||||
$breadcrumb['links'][] = array(
|
||||
'title' => $contact->thank_you_page_title,
|
||||
'url' => $base_url,
|
||||
);
|
||||
return $breadcrumb;
|
||||
}
|
||||
}
|
||||
31
modules/ets_cfultimate/controllers/index.php
Normal file
31
modules/ets_cfultimate/controllers/index.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user