91 lines
3.2 KiB
PHP
91 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* 2007-2020 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-2020 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;
|
|
function upgrade_module_1_1_6($object)
|
|
{
|
|
$object->regexTemplates();
|
|
|
|
Configuration::deleteByName('PA_CAPTCHA_TMP_CONTACT');
|
|
Configuration::deleteByName('PA_CAPTCHA_TMP_LOGIN');
|
|
Configuration::deleteByName('PA_CAPTCHA_TMP_RE_PASSWORD');
|
|
|
|
uninstallModuleInGDPR($object);
|
|
|
|
if ($object->getOverrides() != null) {
|
|
$dir = realpath(dirname(__FILE__) . '/../') . '/override/controllers/front/';
|
|
$classes = array(
|
|
'Auth',
|
|
'Contact',
|
|
'Password'
|
|
);
|
|
foreach ($classes as $class){
|
|
beforeUninstallOverride($dir, $class);
|
|
}
|
|
$object->uninstallOverrides();
|
|
try {
|
|
foreach ($classes as $class) {
|
|
beforeInstallOverride($dir, $class);
|
|
}
|
|
$object->installOverrides();
|
|
} catch (Exception $e) {
|
|
$object->_errors[] = $e->getMessage();
|
|
}
|
|
}
|
|
|
|
return count($object->_errors) > 0 ? false : true;
|
|
}
|
|
|
|
function uninstallModuleInGDPR($object)
|
|
{
|
|
if (Module::isInstalled('psgdpr') && $object->id) {
|
|
if ($gdpr = Db::getInstance()->getRow('
|
|
SELECT id_module, id_gdpr_consent
|
|
FROM `' . _DB_PREFIX_ . 'psgdpr_consent`
|
|
WHERE id_module = ' . (int)$object->id
|
|
)) {
|
|
Db::getInstance()->execute("DELETE FROM `" . _DB_PREFIX_ . "psgdpr_consent` WHERE id_module = " . (int)$gdpr['id_module']);
|
|
Db::getInstance()->execute("DELETE FROM `" . _DB_PREFIX_ . "psgdpr_consent_lang` WHERE id_gdpr_consent = " . (int)$gdpr['id_gdpr_consent']);
|
|
}
|
|
}
|
|
}
|
|
|
|
function beforeUninstallOverride($dir, $class)
|
|
{
|
|
$rebuild_class_content = preg_replace(
|
|
'#(class\s+' . $class . 'Controller\s+extends\s+' . $class . 'ControllerCore\s+\{)#ms'
|
|
, '$1/*-----start-----*/public function initContent(){parent::initContent();}/*-----end-----*/'
|
|
, Tools::file_get_contents($dir . $class . 'Controller.php')
|
|
);
|
|
@file_put_contents($dir . $class . 'Controller.php', $rebuild_class_content);
|
|
}
|
|
|
|
function beforeInstallOverride($dir, $class)
|
|
{
|
|
$rebuild_class_content = preg_replace(
|
|
'#\/\*[-]{5}start[-]{5}\*\/(.*?)\/*[-]{5}end[-]{5}\*\/#ms'
|
|
, ''
|
|
, Tools::file_get_contents($dir . $class . 'Controller.php')
|
|
);
|
|
@file_put_contents($dir . $class . 'Controller.php', $rebuild_class_content);
|
|
} |