first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProBatchesController
|
||||
*/
|
||||
class AdminMailchimpProAutomationsController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'automations';
|
||||
public $entitySingular = 'workflow';
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return '/automations';
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "automations/{$entityId}";
|
||||
}
|
||||
|
||||
protected function deleteEntity($id)
|
||||
{
|
||||
$this->mailchimp->delete($this->getSingleApiEndpointUrl($id));
|
||||
|
||||
if ($this->mailchimp->success()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProBatchesController
|
||||
*/
|
||||
class AdminMailchimpProBatchesController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'batches';
|
||||
public $entitySingular = 'batch';
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return '/batches';
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "batches/{$entityId}";
|
||||
}
|
||||
|
||||
protected function deleteEntity($id)
|
||||
{
|
||||
$this->mailchimp->delete($this->getSingleApiEndpointUrl($id));
|
||||
|
||||
if ($this->mailchimp->success()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \SmartyException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processSingle()
|
||||
{
|
||||
parent::processSingle();
|
||||
try {
|
||||
$tempFilename = tempnam(sys_get_temp_dir(), 'TMP_');
|
||||
$destinationPath = $tempFilename . '_extracted';
|
||||
$zipName = $tempFilename . '.zip';
|
||||
copy($this->entity['response_body_url'], $tempFilename . '.tar.gz');
|
||||
$p = new PharData($tempFilename . '.tar.gz');
|
||||
$p->convertToData(Phar::ZIP);
|
||||
$zip = new ZipArchive;
|
||||
$res = $zip->open($zipName);
|
||||
if ($res === true) {
|
||||
$zip->extractTo($destinationPath);
|
||||
$zip->close();
|
||||
}
|
||||
$it = new RecursiveDirectoryIterator($destinationPath);
|
||||
$responses = array();
|
||||
foreach (new RecursiveIteratorIterator($it) as $file) {
|
||||
if ($file->getExtension() === 'json') {
|
||||
$items = json_decode(Tools::file_get_contents($file), true);
|
||||
foreach ($items as $item) {
|
||||
$responses[] = \PrestaChamps\MailchimpPro\Models\BatchResponse::fromArray($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'responses' => $responses,
|
||||
));
|
||||
$this->content .= $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/entity_single/batch-responses.tpl'
|
||||
);
|
||||
@Tools::deleteDirectory($destinationPath, true);
|
||||
@Tools::deleteFile($zipName);
|
||||
@Tools::deleteFile($tempFilename . '.tar.gz');
|
||||
@Tools::deleteFile($tempFilename . '.tar');
|
||||
@Tools::deleteFile($tempFilename);
|
||||
} catch (Exception $exception) {
|
||||
$this->errors[] = $this->l("Can't decode response");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProCartsController
|
||||
*/
|
||||
class AdminMailchimpProCartsController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'carts';
|
||||
public $entitySingular = 'cart';
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProConfigController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProConfigController extends ModuleAdminController
|
||||
{
|
||||
public $bootstrap = 'true';
|
||||
|
||||
private static $formName = 'MailchimpPro_config_form';
|
||||
|
||||
|
||||
/**
|
||||
* Save a configuration value
|
||||
*
|
||||
* @param string $configKey
|
||||
*/
|
||||
public function saveConfigValue($configKey)
|
||||
{
|
||||
$value = Tools::getValue($configKey);
|
||||
if (!is_scalar($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
Configuration::updateValue($configKey, $value);
|
||||
|
||||
$languages = Language::getLanguages(false, false, false);
|
||||
foreach ($languages as $language) {
|
||||
if (Tools::getValue($configKey . "_{$language['id_lang']}", false)) {
|
||||
Configuration::updateValue(
|
||||
$configKey,
|
||||
array($language['id_lang'] => (string)Tools::getValue($configKey . '_' . $language['id_lang'], '')),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process, normalise and save configuration values
|
||||
*/
|
||||
public function processConfiguration()
|
||||
{
|
||||
foreach ($_REQUEST as $key => $value) {
|
||||
$normalizedKey = preg_replace('/_\d{1,}$/', '', $key);
|
||||
unset($value);
|
||||
$this->saveConfigValue($normalizedKey);
|
||||
}
|
||||
Configuration::updateValue(MailchimpProConfig::MAILCHIMP_SCRIPT_VERIFIED, '0');
|
||||
Configuration::loadConfiguration();
|
||||
|
||||
$this->confirmations[] = $this->l('Configuration updated');
|
||||
}
|
||||
|
||||
public function processDeleteEcommerceData()
|
||||
{
|
||||
try {
|
||||
$shops = array_column(Shop::getShops(true), 'id_shop');
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\StoreSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
$shops
|
||||
);
|
||||
$command->setMethod($command::SYNC_METHOD_DELETE);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->execute();
|
||||
$this->confirmations[] = $this->l('E-commerce data has been deleted');
|
||||
} catch (Exception $exception) {
|
||||
$this->errors[] = "Error during deleting e-commerce data";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws PrestaShopDatabaseException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function renderStateMappingForm()
|
||||
{
|
||||
$orderStates = OrderState::getOrderStates($this->context->language->id);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array('title' => $this->l('Order state mapping'), 'icon' => 'icon-envelope'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'label' => $this->l('Status for pending'),
|
||||
'name' => MailchimpProConfig::STATUSES_FOR_PENDING,
|
||||
'size' => count($orderStates),
|
||||
'options' => array(
|
||||
'query' => $orderStates,
|
||||
'id' => 'id_order_state',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'label' => $this->l('Status for refunded'),
|
||||
'name' => MailchimpProConfig::STATUSES_FOR_REFUNDED,
|
||||
'size' => count($orderStates),
|
||||
'options' => array(
|
||||
'query' => $orderStates,
|
||||
'id' => 'id_order_state',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'label' => $this->l('Status for cancelled'),
|
||||
'name' => MailchimpProConfig::STATUSES_FOR_CANCELLED,
|
||||
'size' => count($orderStates),
|
||||
'options' => array(
|
||||
'query' => $orderStates,
|
||||
'id' => 'id_order_state',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'label' => $this->l('Status for shipped'),
|
||||
'name' => MailchimpProConfig::STATUSES_FOR_SHIPPED,
|
||||
'size' => count($orderStates),
|
||||
'options' => array(
|
||||
'query' => $orderStates,
|
||||
'id' => 'id_order_state',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'label' => $this->l('Status for paid'),
|
||||
'name' => MailchimpProConfig::STATUSES_FOR_PAID,
|
||||
'size' => count($orderStates),
|
||||
'options' => array(
|
||||
'query' => $orderStates,
|
||||
'id' => 'id_order_state',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'btn btn-primary btn-mc pull-right',
|
||||
'id' => 'state-save-btn'
|
||||
),
|
||||
),
|
||||
);
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'states';
|
||||
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$helper->default_form_language = $lang->id;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ?: 0;
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->submit_action = self::$formName;
|
||||
$helper->currentIndex = $this->context->link->getAdminLink($this->controller_name, false);
|
||||
$helper->token = Tools::getAdminTokenLite($this->controller_name);
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => MailchimpProConfig::getConfigurationValues(),
|
||||
'languages' => $this->context->controller->getLanguages(),
|
||||
'id_language' => $this->context->language->id,
|
||||
);
|
||||
|
||||
return $helper->generateForm(array($fields_form));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws PrestaShopDatabaseException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function renderForm()
|
||||
{
|
||||
try {
|
||||
$lists = $this->module->getApiClient()->get('lists', array('fields' => 'lists.name,lists.id'));
|
||||
} catch (Exception $exception) {
|
||||
$this->errors[] = $exception->getMessage();
|
||||
$lists = array(
|
||||
'lists' => array(),
|
||||
);
|
||||
}
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array('title' => $this->l('General settings'), 'icon' => 'icon-envelope'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'multiple' => false,
|
||||
'label' => $this->l('Product image size'),
|
||||
'name' => MailchimpProConfig::PRODUCT_IMAGE_SIZE,
|
||||
'desc' => $this->module->l('Remember to resync products if you change this'),
|
||||
'options' => array(
|
||||
'query' => $this->getImageSizes(),
|
||||
'id' => 'name',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
// [
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('API Key'),
|
||||
// 'name' => MailchimpProConfig::MAILCHIMP_API_KEY,
|
||||
// 'lang' => false,
|
||||
// 'required' => true,
|
||||
// 'hint' => $this->l('API Key'),
|
||||
// ],
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'btn btn-primary btn-mc pull-right',
|
||||
),
|
||||
),
|
||||
);
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'misc';
|
||||
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$helper->default_form_language = $lang->id;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ?: 0;
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->submit_action = self::$formName;
|
||||
$helper->currentIndex = $this->context->link->getAdminLink($this->controller_name, false);
|
||||
$helper->token = Tools::getAdminTokenLite($this->controller_name);
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => MailchimpProConfig::getConfigurationValues(),
|
||||
'languages' => $this->context->controller->getLanguages(),
|
||||
'id_language' => $this->context->language->id,
|
||||
);
|
||||
|
||||
return $helper->generateForm(array($fields_form));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws PrestaShopDatabaseException
|
||||
* @throws PrestaShopException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (Tools::isSubmit(self::$formName)) {
|
||||
$this->processConfiguration();
|
||||
}
|
||||
$this->content .= $this->renderNavBar();
|
||||
$this->content .= $this->renderAccountInfo();
|
||||
$this->content .= $this->renderForm();
|
||||
$this->content .= $this->renderStateMappingForm();
|
||||
$this->content .= $this->renderDeleteEcommerceData();
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderAccountInfo()
|
||||
{
|
||||
try {
|
||||
$info = $this->module->getApiClient()->get('');
|
||||
if (!$this->module->getApiClient()->success()) {
|
||||
return '';
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'info' => $info,
|
||||
));
|
||||
return $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/config/account-info.tpl'
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderDeleteEcommerceData()
|
||||
{
|
||||
try {
|
||||
$info = $this->module->getApiClient()->get('');
|
||||
if (!$this->module->getApiClient()->success()) {
|
||||
return '';
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
'info' => $info,
|
||||
));
|
||||
return $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/config/delete-ecommerce-data.tpl'
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function renderNavBar()
|
||||
{
|
||||
return $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/config/navbar.tpl'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available image sizes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getImageSizes()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->select('name, width, height');
|
||||
$query->from('image_type');
|
||||
$query->where('products = 1');
|
||||
try {
|
||||
return Db::getInstance()->executeS($query);
|
||||
} catch (Exception $exception) {
|
||||
$this->errors[] = $exception->getMessage();
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProCustomersController
|
||||
*/
|
||||
class AdminMailchimpProCustomersController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'customers';
|
||||
public $entitySingular = 'customer';
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author PrestaChamps <leo@prestachamps.com>
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProListMembersController
|
||||
*/
|
||||
class AdminMailchimpProListMembersController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'members';
|
||||
public $entitySingular = 'member';
|
||||
public $list_id;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->list_id = Tools::getValue('list_id');
|
||||
}
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return "/lists/{$this->list_id}/members";
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "/lists/{$this->list_id}/members/{$entityId}";
|
||||
}
|
||||
|
||||
protected function renderPaginationQ()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'controller_name' => $this->controller_name,
|
||||
'totalEntities' => $this->totalEntities,
|
||||
'offset' => $this->offset,
|
||||
'totalPageNumber' => $this->totalPageNumber,
|
||||
'currentPage' => $this->currentPage,
|
||||
'count' => $this->entitiesPerPage,
|
||||
'list_id' => Tools::getValue('list_id')
|
||||
));
|
||||
$this->content .= $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/entity_list/_pagination_list-members.tpl'
|
||||
);
|
||||
}
|
||||
|
||||
protected function getPaginationPageLinkTemplate()
|
||||
{
|
||||
/**
|
||||
* PrestaShop Module validator note
|
||||
*
|
||||
* The method exits in modules/mailchimppro/src/LinkHelper.php
|
||||
*/
|
||||
return urldecode(
|
||||
LinkHelper::getAdminLink(
|
||||
$this->controller_name,
|
||||
true,
|
||||
array(),
|
||||
array(
|
||||
'action' => 'page',
|
||||
'page' => '(:num)',
|
||||
'list_id' => $this->list_id,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProListsController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProListsController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'lists';
|
||||
public $entitySingular = 'list';
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processNew()
|
||||
{
|
||||
$list_name = \Tools::getValue('list_name');
|
||||
if ($list_name) {
|
||||
$this->action = null;
|
||||
if ($this->createMailchimpList($list_name)) {
|
||||
$this->confirmations[] = $this->l('List created successfully');
|
||||
} else {
|
||||
$this->errors[] = $this->l("Oups! Failed to create list: {$this->mailchimp->getLastError()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $list_name
|
||||
*
|
||||
* @return array|false
|
||||
* @throws Exception
|
||||
*/
|
||||
private function createMailchimpList($list_name)
|
||||
{
|
||||
return \PrestaChamps\MailchimpPro\Factories\ListFactory::make(
|
||||
$list_name,
|
||||
$this->module->getApiClient(),
|
||||
$this->context
|
||||
);
|
||||
}
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return '/lists';
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "lists/{$entityId}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProOrdersController
|
||||
*/
|
||||
class AdminMailchimpProOrdersController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'orders';
|
||||
public $entitySingular = 'order';
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProStoresController
|
||||
*/
|
||||
class AdminMailchimpProProductsController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'products';
|
||||
public $entitySingular = 'product';
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author PrestaChamps <leo@prestachamps.com>
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProPromoRulesController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProPromoCodesController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'promo_codes';
|
||||
public $entitySingular = 'promo_code';
|
||||
public $rule_id;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->rule_id = Tools::getValue('rule_id');
|
||||
}
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return "/ecommerce/stores/{$this->context->shop->id}/promo-rules/{$this->rule_id}/promo-codes/";
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "/ecommerce/stores/{$this->context->shop->id}/promo-rules/{$this->rule_id}/promo-codes/$entityId";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author PrestaChamps <leo@prestachamps.com>
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProPromoRulesController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProPromoRulesController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'promo_rules';
|
||||
public $entitySingular = 'promo_rule';
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return "/ecommerce/stores/{$this->context->shop->id}/promo-rules";
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "/ecommerce/stores/{$this->context->shop->id}/promo-rules/{$entityId}/promo-codes";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProListsController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProSitesController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'sites';
|
||||
public $entitySingular = 'connected-sites';
|
||||
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return '/connected-sites';
|
||||
}
|
||||
|
||||
protected function getSingleApiEndpointUrl($entityId)
|
||||
{
|
||||
return "connected-sites/{$entityId}";
|
||||
}
|
||||
|
||||
protected function deleteEntity($id)
|
||||
{
|
||||
$this->mailchimp->delete("/connected-sites/{$id}");
|
||||
|
||||
if ($this->mailchimp->success()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProCartsController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProStoresController extends \PrestaChamps\MailchimpPro\Controllers\BaseMCObjectController
|
||||
{
|
||||
public $entityPlural = 'stores';
|
||||
public $entitySingular = 'store';
|
||||
|
||||
protected function getListApiEndpointUrl()
|
||||
{
|
||||
return '/ecommerce/stores';
|
||||
}
|
||||
|
||||
protected function deleteEntity($id)
|
||||
{
|
||||
$this->mailchimp->delete("/ecommerce/stores/{$id}");
|
||||
|
||||
if ($this->mailchimp->success()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/**
|
||||
* MailChimp
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright Mailchimp
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProSyncController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProSyncController extends ModuleAdminController
|
||||
{
|
||||
public $bootstrap = true;
|
||||
|
||||
/**
|
||||
* @throws SmartyException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
$this->content .= $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/config/navbar.tpl'
|
||||
);
|
||||
$this->content .= $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/sync/index.tpl'
|
||||
);
|
||||
Media::addJsDef(array(
|
||||
'productIds' => array_column(
|
||||
Product::getSimpleProducts(\Context::getContext()->language->id),
|
||||
'id_product'
|
||||
),
|
||||
'syncUrl' => $this->context->link->getAdminLink($this->controller_name),
|
||||
'itemsPerRequest' => 50,
|
||||
));
|
||||
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/sync.css');
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/spinner.css');
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/toastr.css');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/toastr.min.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/array.chunk.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/ajaxq.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/sync/product.js');
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processProductSync()
|
||||
{
|
||||
try {
|
||||
$method = Tools::getValue('method', 'post');
|
||||
$service = new \PrestaChamps\MailchimpPro\Commands\ProductSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
Tools::getValue('items')
|
||||
);
|
||||
if (Tools::getValue('syncMode', false) === 'batch') {
|
||||
$service->setSyncMode($service::SYNC_MODE_BATCH);
|
||||
}
|
||||
if ($method === 'post') {
|
||||
$service->setMethod($service::SYNC_METHOD_POST);
|
||||
}
|
||||
if ($method === 'patch') {
|
||||
$service->setMethod($service::SYNC_METHOD_PATCH);
|
||||
}
|
||||
if ($method === 'delete') {
|
||||
$service->setMethod($service::SYNC_METHOD_DELETE);
|
||||
}
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $service->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processStoreSync()
|
||||
{
|
||||
try {
|
||||
$method = Tools::getValue('method', 'post');
|
||||
$service = new \PrestaChamps\MailchimpPro\Commands\StoreSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
array($this->context->shop->id)
|
||||
);
|
||||
if ($method === 'post') {
|
||||
$service->setMethod($service::SYNC_METHOD_POST);
|
||||
}
|
||||
if ($method === 'patch') {
|
||||
$service->setMethod($service::SYNC_METHOD_PATCH);
|
||||
}
|
||||
if ($method === 'delete') {
|
||||
$service->setMethod($service::SYNC_METHOD_DELETE);
|
||||
}
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $service->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processPromoCodeSync()
|
||||
{
|
||||
try {
|
||||
$method = Tools::getValue('method', 'post');
|
||||
$items = $this->getCartRules();
|
||||
|
||||
$service = new \PrestaChamps\MailchimpPro\Commands\CartRuleSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
$items
|
||||
);
|
||||
if (Tools::getValue('syncMode', false) === 'batch') {
|
||||
$service->setSyncMode($service::SYNC_MODE_BATCH);
|
||||
}
|
||||
if ($method === 'post') {
|
||||
$service->setMethod($service::SYNC_METHOD_POST);
|
||||
}
|
||||
if ($method === 'patch') {
|
||||
$service->setMethod($service::SYNC_METHOD_PATCH);
|
||||
}
|
||||
if ($method === 'delete') {
|
||||
$service->setMethod($service::SYNC_METHOD_DELETE);
|
||||
}
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $service->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processBatchSync()
|
||||
{
|
||||
$responses = array();
|
||||
try {
|
||||
$batches = $this->module->getApiClient()->get(
|
||||
'/batches',
|
||||
array(
|
||||
'count' => 200,
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($batches['batches'] as $batch) {
|
||||
$responses[] = $this->module->getApiClient()->delete("/batches/{$batch['id']}");
|
||||
}
|
||||
$this->ajaxDie(array('success' => true, 'responses' => $responses));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processOrderSync()
|
||||
{
|
||||
try {
|
||||
$method = Tools::getValue('method', 'post');
|
||||
$service = new \PrestaChamps\MailchimpPro\Commands\OrderSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient()
|
||||
);
|
||||
if ($method === 'post') {
|
||||
$service->setMethod($service::SYNC_METHOD_POST);
|
||||
}
|
||||
if ($method === 'patch') {
|
||||
$service->setMethod($service::SYNC_METHOD_PATCH);
|
||||
}
|
||||
if ($method === 'delete') {
|
||||
$service->setMethod($service::SYNC_METHOD_DELETE);
|
||||
}
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $service->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processCustomerSync()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->from('customer');
|
||||
$query->select('id_customer');
|
||||
$query->where('id_shop = ' . pSQL($this->context->shop->id));
|
||||
$customerIds = array_column(Db::getInstance()->executeS($query), 'id_customer');
|
||||
try {
|
||||
$method = Tools::getValue('method', 'post');
|
||||
|
||||
$service = new \PrestaChamps\MailchimpPro\Commands\CustomerSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
$customerIds
|
||||
);
|
||||
$service->triggerDoubleOptIn(false);
|
||||
$service->setSyncMode($service::SYNC_MODE_BATCH);
|
||||
if ($method === 'post') {
|
||||
$service->setMethod($service::SYNC_METHOD_PUT);
|
||||
}
|
||||
if ($method === 'patch') {
|
||||
$service->setMethod($service::SYNC_METHOD_PUT);
|
||||
}
|
||||
if ($method === 'delete') {
|
||||
$service->setMethod($service::SYNC_METHOD_DELETE);
|
||||
}
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $service->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->getApiClient()->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $value
|
||||
* @param null $controller
|
||||
* @param null $method
|
||||
* @param int $statusCode
|
||||
*/
|
||||
public function ajaxDie($value = null, $controller = null, $method = null, $statusCode = 200)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!is_scalar($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
http_response_code($statusCode);
|
||||
parent::ajaxDie($value, $controller, $method);
|
||||
}
|
||||
|
||||
public function processBatchInfo()
|
||||
{
|
||||
try {
|
||||
$batchId = Tools::getValue('id', false);
|
||||
if (!$batchId) {
|
||||
throw new Exception('Invalid BatchId');
|
||||
}
|
||||
$mc = $this->module->getApiClient();
|
||||
|
||||
$this->ajaxDie(array('hasErrors' => false, 'batch' => $mc->new_batch($batchId)->check_status($batchId)));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCartRules()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->from('cart_rule');
|
||||
$query->select('id_cart_rule');
|
||||
$query->where('shop_restriction = 0');
|
||||
$ids = array_column(Db::getInstance()->executeS($query), 'id_cart_rule');
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->from('cart_rule_shop');
|
||||
$query->select('id_cart_rule');
|
||||
$query->where('id_shop = ' . pSQL($this->context->shop->id));
|
||||
$result = array_column(Db::getInstance()->executeS($query), 'id_cart_rule');
|
||||
$result = array_unique(array_merge($ids, $result));
|
||||
sort($result, SORT_NUMERIC);
|
||||
$objects = array();
|
||||
foreach ($result as $itemId) {
|
||||
$object = new \CartRule($itemId, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$objects[] = $object;
|
||||
}
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class AdminMailchimpProWizardController
|
||||
*
|
||||
* @property Mailchimppro $module
|
||||
*/
|
||||
class AdminMailchimpProWizardController extends ModuleAdminController
|
||||
{
|
||||
public $bootstrap = true;
|
||||
|
||||
/**
|
||||
* @throws PrestaShopException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/main.css');
|
||||
if (\Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->warnings[] = $this->module->l('Please select a shop');
|
||||
} else {
|
||||
Media::addJsDef(array('wizardUrl' => $this->context->link->getAdminLink($this->controller_name)));
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/smart_wizard.css');
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/smart_wizard_theme_dots.css');
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/toastr.css');
|
||||
$this->addCSS($this->module->getLocalPath() . 'views/css/spinner.css');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/jquery.smartWizard.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/setup-wizard.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/toastr.min.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/ajaxq.js');
|
||||
$this->addJS($this->module->getLocalPath() . 'views/js/array.chunk.js');
|
||||
|
||||
|
||||
Media::addJsDef(array(
|
||||
'statePending' => MailchimpProConfig::STATUSES_FOR_PENDING,
|
||||
'stateRefunded' => MailchimpProConfig::STATUSES_FOR_REFUNDED,
|
||||
'stateCancelled' => MailchimpProConfig::STATUSES_FOR_CANCELLED,
|
||||
'stateShipped' => MailchimpProConfig::STATUSES_FOR_SHIPPED,
|
||||
'statePaid' => MailchimpProConfig::STATUSES_FOR_PAID,
|
||||
'productIds' => array_column(
|
||||
Product::getSimpleProducts(\Context::getContext()->language->id),
|
||||
'id_product'
|
||||
),
|
||||
'promoCodeIds' => $this->getCartRules(),
|
||||
'orderIds' => $this->getOrderIds(),
|
||||
'customerIds' => array_column(Customer::getCustomers(true), 'id_customer'),
|
||||
'syncUrl' => $this->context->link->getAdminLink($this->controller_name),
|
||||
'middlewareUrl' => Mailchimppro::MC_MIDDLEWARE,
|
||||
'itemsPerRequest' => 50,
|
||||
));
|
||||
$this->context->smarty->assign(array(
|
||||
'apiKey' => Configuration::get(MailchimpProConfig::MAILCHIMP_API_KEY),
|
||||
'mcEmail' => $this->getMailchimpUserEmail(Configuration::get(MailchimpProConfig::MAILCHIMP_API_KEY)),
|
||||
));
|
||||
$this->content .= $this->context->smarty->fetch(
|
||||
$this->module->getLocalPath() . 'views/templates/admin/wizard.tpl'
|
||||
);
|
||||
if (Shop::getContext() !== Shop::CONTEXT_SHOP) {
|
||||
$this->content = '';
|
||||
$this->context->controller->warnings[] = $this->module->l('Please select a shop');
|
||||
}
|
||||
|
||||
if (!Tools::usingSecureMode()) {
|
||||
$this->content = '';
|
||||
$this->context->controller->warnings[] = $this->module->l('Please use HTTPS for authenticating to Mailchimp');
|
||||
}
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getMailchimpUserEmail($apiKey)
|
||||
{
|
||||
try {
|
||||
$mc = new \DrewM\MailChimp\MailChimp($apiKey);
|
||||
$response = $mc->get('/');
|
||||
} catch (Exception $exception) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (isset($response['email'])) ? $response['email'] : null;
|
||||
}
|
||||
|
||||
protected function getCartRules()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
$query->from('cart_rule');
|
||||
$query->select('id_cart_rule');
|
||||
$query->where('shop_restriction = 0');
|
||||
$ids = array_column(Db::getInstance()->executeS($query), 'id_cart_rule');
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->from('cart_rule_shop');
|
||||
$query->select('id_cart_rule');
|
||||
$query->where('id_shop = ' . pSQL($this->context->shop->id));
|
||||
$result = array_column(Db::getInstance()->executeS($query), 'id_cart_rule');
|
||||
$result = array_unique(array_merge($ids, $result));
|
||||
sort($result, SORT_NUMERIC);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getOrderIds()
|
||||
{
|
||||
$shopId = Shop::getContextShopID();
|
||||
$query = new DbQuery();
|
||||
$query->from('orders');
|
||||
$query->select('id_order');
|
||||
if ($shopId) {
|
||||
$query->where("id_shop = {$shopId}");
|
||||
}
|
||||
|
||||
return array_column(Db::getInstance()->executeS($query), 'id_order');
|
||||
}
|
||||
|
||||
public function processApiKey()
|
||||
{
|
||||
try {
|
||||
$apiKey = Tools::getValue('apiKey');
|
||||
$mc = new \DrewM\MailChimp\MailChimp($apiKey);
|
||||
$mc->get('ping');
|
||||
if ($mc->success()) {
|
||||
Configuration::updateValue(MailchimpProConfig::MAILCHIMP_API_KEY, $apiKey);
|
||||
$this->ajaxDie(array('hasError' => false, 'error' => null));
|
||||
} else {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $this->module->l('Invlid api key'),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $mc->getLastResponse(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateMapping()
|
||||
{
|
||||
try {
|
||||
$configValues = MailchimpProConfig::getConfigurationValues();
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => false,
|
||||
'mapping' => array(
|
||||
MailchimpProConfig::STATUSES_FOR_PENDING =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_PENDING],
|
||||
MailchimpProConfig::STATUSES_FOR_PENDING =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_REFUNDED],
|
||||
MailchimpProConfig::STATUSES_FOR_CANCELLED =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_CANCELLED],
|
||||
MailchimpProConfig::STATUSES_FOR_SHIPPED =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_SHIPPED],
|
||||
MailchimpProConfig::STATUSES_FOR_PAID =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_PAID],
|
||||
),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processStateMapping()
|
||||
{
|
||||
try {
|
||||
$statuses = Tools::getValue('states');
|
||||
if (isset($statuses[MailchimpProConfig::STATUSES_FOR_PENDING]) &&
|
||||
isset($statuses[MailchimpProConfig::STATUSES_FOR_REFUNDED]) &&
|
||||
isset($statuses[MailchimpProConfig::STATUSES_FOR_CANCELLED]) &&
|
||||
isset($statuses[MailchimpProConfig::STATUSES_FOR_SHIPPED]) &&
|
||||
isset($statuses[MailchimpProConfig::STATUSES_FOR_PAID]) &&
|
||||
is_array($statuses[MailchimpProConfig::STATUSES_FOR_PENDING]) &&
|
||||
is_array($statuses[MailchimpProConfig::STATUSES_FOR_REFUNDED]) &&
|
||||
is_array($statuses[MailchimpProConfig::STATUSES_FOR_CANCELLED]) &&
|
||||
is_array($statuses[MailchimpProConfig::STATUSES_FOR_SHIPPED]) &&
|
||||
is_array($statuses[MailchimpProConfig::STATUSES_FOR_PAID])
|
||||
) {
|
||||
MailchimpProConfig::saveValue(
|
||||
MailchimpProConfig::STATUSES_FOR_PENDING,
|
||||
json_encode($statuses[MailchimpProConfig::STATUSES_FOR_PENDING])
|
||||
);
|
||||
MailchimpProConfig::saveValue(
|
||||
MailchimpProConfig::STATUSES_FOR_REFUNDED,
|
||||
json_encode($statuses[MailchimpProConfig::STATUSES_FOR_REFUNDED])
|
||||
);
|
||||
MailchimpProConfig::saveValue(
|
||||
MailchimpProConfig::STATUSES_FOR_CANCELLED,
|
||||
json_encode($statuses[MailchimpProConfig::STATUSES_FOR_CANCELLED])
|
||||
);
|
||||
MailchimpProConfig::saveValue(
|
||||
MailchimpProConfig::STATUSES_FOR_SHIPPED,
|
||||
json_encode($statuses[MailchimpProConfig::STATUSES_FOR_SHIPPED])
|
||||
);
|
||||
MailchimpProConfig::saveValue(
|
||||
MailchimpProConfig::STATUSES_FOR_PAID,
|
||||
json_encode($statuses[MailchimpProConfig::STATUSES_FOR_PAID])
|
||||
);
|
||||
$this->ajaxDie(array('hasError' => false, 'error' => null));
|
||||
}
|
||||
throw new Exception('Invalid data');
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processGetStates()
|
||||
{
|
||||
try {
|
||||
$configValues = MailchimpProConfig::getConfigurationValues();
|
||||
|
||||
$orderStates = OrderState::getOrderStates($this->context->language->id);
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'states' => $orderStates,
|
||||
'mapping' => array(
|
||||
MailchimpProConfig::STATUSES_FOR_PENDING =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_PENDING],
|
||||
MailchimpProConfig::STATUSES_FOR_REFUNDED =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_REFUNDED],
|
||||
MailchimpProConfig::STATUSES_FOR_CANCELLED =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_CANCELLED],
|
||||
MailchimpProConfig::STATUSES_FOR_SHIPPED =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_SHIPPED],
|
||||
MailchimpProConfig::STATUSES_FOR_PAID =>
|
||||
$configValues[MailchimpProConfig::STATUSES_FOR_PAID],
|
||||
),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSyncStores()
|
||||
{
|
||||
try {
|
||||
// $shops = array_column(Shop::getShops(true), 'id_shop');
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\StoreSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
array($this->context->shop->id)
|
||||
);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->setMethod($command::SYNC_METHOD_POST);
|
||||
$command->execute();
|
||||
$command->setMethod($command::SYNC_METHOD_PATCH);
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $command->execute(),
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSyncCustomers()
|
||||
{
|
||||
try {
|
||||
$results = array();
|
||||
$customerIds = Tools::getValue('items');
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\CustomerSyncCommand(
|
||||
Context::getContext(),
|
||||
$this->module->getApiClient(),
|
||||
$customerIds
|
||||
);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->setMethod($command::SYNC_METHOD_PUT);
|
||||
$results[] = $command->execute();
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $results,
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSyncPromoCodes()
|
||||
{
|
||||
try {
|
||||
$results = array();
|
||||
$objectIds = Tools::getValue('items');
|
||||
$objects = array();
|
||||
|
||||
foreach ($objectIds as $objectId) {
|
||||
$object = new CartRule($objectId, $this->context->language->id, $this->context->shop->id);
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$objects[] = $object;
|
||||
}
|
||||
}
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\CartRuleSyncCommand(
|
||||
Context::getContext(),
|
||||
$this->module->getApiClient(),
|
||||
$objects
|
||||
);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->setMethod($command::SYNC_METHOD_POST);
|
||||
$results[] = $command->execute();
|
||||
$command->setMethod($command::SYNC_METHOD_PATCH);
|
||||
$results[] = $command->execute();
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $results,
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSyncProducts()
|
||||
{
|
||||
try {
|
||||
$results = array();
|
||||
/*
|
||||
$productIds = array_column(
|
||||
Product::getSimpleProducts(\Context::getContext()->language->id),
|
||||
'id_product'
|
||||
);*/
|
||||
$productIds = Tools::getValue('items');
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\ProductSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
$productIds
|
||||
);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->setMethod($command::SYNC_METHOD_POST);
|
||||
$results[] = $command->execute();
|
||||
$command->setMethod($command::SYNC_METHOD_PATCH);
|
||||
$results[] = $command->execute();
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $results,
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSyncOrders()
|
||||
{
|
||||
try {
|
||||
$results = array();
|
||||
$orderIds = Tools::getValue('items');
|
||||
$command = new \PrestaChamps\MailchimpPro\Commands\OrderSyncCommand(
|
||||
$this->context,
|
||||
$this->module->getApiClient(),
|
||||
$orderIds
|
||||
);
|
||||
$command->setSyncMode($command::SYNC_MODE_REGULAR);
|
||||
$command->setMethod($command::SYNC_METHOD_POST);
|
||||
$results[] = $command->execute();
|
||||
$command->setMethod($command::SYNC_METHOD_PATCH);
|
||||
$results[] = $command->execute();
|
||||
$this->ajaxDie(array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'result' => $results,
|
||||
));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processListSelect()
|
||||
{
|
||||
try {
|
||||
$listId = Tools::getValue('listId');
|
||||
Configuration::updateValue(MailchimpProConfig::MAILCHIMP_LIST_ID, $listId);
|
||||
$this->ajaxDie(array('hasError' => false, 'error' => null));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processGetLists()
|
||||
{
|
||||
try {
|
||||
$lists = $this->module->getApiClient()->get(
|
||||
'lists',
|
||||
array('fields' => 'lists.name,lists.id', 'count' => 999)
|
||||
);
|
||||
if (!$lists || empty($lists)) {
|
||||
\PrestaChamps\MailchimpPro\Factories\ListFactory::make(
|
||||
$this->context->shop->name,
|
||||
$this->module->getApiClient(),
|
||||
$this->context
|
||||
);
|
||||
$lists = $this->module->getApiClient()->get(
|
||||
'lists',
|
||||
array('fields' => 'lists.name,lists.id', 'count' => 999)
|
||||
);
|
||||
}
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => false,
|
||||
'error' => null,
|
||||
'lists' => $lists['lists'],
|
||||
'selectedList' => Configuration::get(MailchimpProConfig::MAILCHIMP_LIST_ID),
|
||||
)
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function processBatchInfo()
|
||||
{
|
||||
try {
|
||||
$batchId = Tools::getValue('id', false);
|
||||
if (!$batchId) {
|
||||
throw new Exception('Invalid BatchId');
|
||||
}
|
||||
$mc = $this->module->getApiClient();
|
||||
|
||||
$this->ajaxDie(array('hasErrors' => false, 'batch' => $mc->new_batch($batchId)->check_status($batchId)));
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxDie(
|
||||
array(
|
||||
'hasError' => true,
|
||||
'error' => $exception->getMessage(),
|
||||
),
|
||||
null,
|
||||
null,
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $value
|
||||
* @param null $controller
|
||||
* @param null $method
|
||||
* @param int $statusCode
|
||||
*/
|
||||
public function ajaxDie($value = null, $controller = null, $method = null, $statusCode = 200)
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!is_scalar($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
http_response_code($statusCode);
|
||||
parent::ajaxDie($value, $controller, $method);
|
||||
}
|
||||
}
|
||||
34
modules/mailchimppro/controllers/admin/index.php
Normal file
34
modules/mailchimppro/controllers/admin/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* 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 refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
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;
|
||||
34
modules/mailchimppro/controllers/index.php
Normal file
34
modules/mailchimppro/controllers/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* 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 refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
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