Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions psgdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Psgdpr extends Module
'actionAdminControllerSetMedia',
'additionalCustomerFormFields',
'actionCustomerAccountAdd',
'actionModuleRegisterHookAfter',
];

private $presetMessageAccountCreation = [
Expand Down Expand Up @@ -87,7 +88,7 @@ public function __construct()
{
$this->name = 'psgdpr';
$this->tab = 'administration';
$this->version = '2.0.3';
$this->version = '2.0.4';
$this->author = 'PrestaShop';
$this->need_instance = 0;

Expand Down Expand Up @@ -153,6 +154,7 @@ public function install(): bool
$this->registerHook($this->hooksUsedByModule);
$this->executeQuerySql(self::SQL_QUERY_TYPE_UNINSTALL);
$this->executeQuerySql(self::SQL_QUERY_TYPE_INSTALL);
$this->getRegisteredModules();
} catch (PrestaShopException $e) {
/** @var LegacyLogger $legacyLogger */
$legacyLogger = $this->get('prestashop.adapter.legacy.logger');
Expand Down Expand Up @@ -267,7 +269,6 @@ public function getContent()
$id_lang = $this->context->language->id;
$id_shop = $this->context->shop->id;

$this->getRegisteredModules();
$moduleList = $this->loadRegisteredModules();

$apiController = $router->generate('psgdpr_api_index');
Expand Down Expand Up @@ -781,6 +782,34 @@ public function hookDisplayGDPRConsent(array $params): string
return $this->fetch('module:' . $this->name . '/views/templates/hook/display_rgpd_consent.tpl');
}

public function hookActionModuleRegisterHookAfter(array $params): void
{
$hookName = $params['hookName'] ?? null;
$moduleObject = $params['object'] ?? null;

if ($hookName != 'registerGDPRConsent' || !is_a($moduleObject, Module::class)) {
return;
}

try {
$this->addModuleConsent([
'id_module' => $moduleObject->id,
]);
} catch (PrestaShopException $e) {
/** @var LegacyLogger $legacyLogger */
$legacyLogger = $this->get('prestashop.adapter.legacy.logger');
$legacyLogger->error($e->getMessage(), [
'file' => $e->getFile(),
'line' => $e->getLine(),
]);
$this->_errors[] = $this->trans(
'There was an error during to add the module %module_name% consent. Please contact us through Addons website. (for developers, consult shop logs)',
['%module_name%' => $moduleObject->name],
'Modules.Psgdpr.Shop'
);
}
}

/**
* Execute raw sql query from specific folder
* Used mainly for the install or uninstall of the psgdpr module
Expand Down
33 changes: 33 additions & 0 deletions upgrade/upgrade-2.0.4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}

/**
* @param Psgdpr $module
*
* @return bool
*/
function upgrade_module_2_0_4($module)
{
return $module->registerHook('actionModuleRegisterHookAfter');
}
Loading