From 5a90d475953e194cf1f695642edc728dc9279ddb Mon Sep 17 00:00:00 2001 From: jGissinger Date: Wed, 23 May 2018 23:27:07 +0200 Subject: [PATCH 1/2] Add compliance to gdpr law (psgdpr module) --- config.xml | 2 +- mailalerts.php | 29 ++++++++++++++++++++++++-- upgrade/install-3.6.2.php | 35 ++++++++++++++++++++++++++++++++ views/templates/hook/product.tpl | 11 +++++++++- 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 upgrade/install-3.6.2.php diff --git a/config.xml b/config.xml index b96d565..d7e05f7 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ mailalerts - + diff --git a/mailalerts.php b/mailalerts.php index 3b31064..00d6a3d 100644 --- a/mailalerts.php +++ b/mailalerts.php @@ -48,7 +48,7 @@ public function __construct() { $this->name = 'mailalerts'; $this->tab = 'administration'; - $this->version = '3.6.1'; + $this->version = '3.6.2'; $this->author = 'PrestaShop'; $this->need_instance = 0; @@ -91,6 +91,9 @@ public function install($delete_params = true) !$this->registerHook('actionProductCoverage') || !$this->registerHook('actionOrderReturn') || !$this->registerHook('actionOrderEdited') || + !$this->registerHook('registerGDPRConsent') || + !$this->registerHook('actionDeleteGDPRCustomer') || + !$this->registerHook('actionExportGDPRData') || !$this->registerHook('displayHeader')) return false; @@ -478,7 +481,8 @@ public function hookActionProductOutOfStock($params) $this->context->smarty->assign( array( 'id_product' => $id_product, - 'id_product_attribute' => $id_product_attribute + 'id_product_attribute' => $id_product_attribute, + 'id_module' => $this->id ) ); @@ -866,6 +870,27 @@ public function hookActionOrderEdited($params) null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop); } + public function hookActionDeleteGDPRCustomer($customer) + { + if (!empty($customer['email']) && Validate::isEmail($customer['email'])) { + $sql = "DELETE FROM "._DB_PREFIX_."mailalert_customer_oos WHERE customer_email = '".pSQL($customer['email'])."'"; + if (Db::getInstance()->execute($sql)) { + return json_encode(true); + } + return json_encode($this->l('Mail alert: Unable to delete customer using email.')); + } + } + public function hookActionExportGDPRData($customer) + { + if (!Tools::isEmpty($customer['email']) && Validate::isEmail($customer['email'])) { + $sql = "SELECT * FROM "._DB_PREFIX_."mailalert_customer_oos WHERE customer_email = '".pSQL($customer['email'])."'"; + if ($res = Db::getInstance()->ExecuteS($sql)) { + return json_encode($res); + } + return json_encode($this->l('Mail alert: Unable to export customer using email.')); + } + } + public function renderForm() { $fields_form_1 = array( diff --git a/upgrade/install-3.6.2.php b/upgrade/install-3.6.2.php new file mode 100644 index 0000000..b9a48e5 --- /dev/null +++ b/upgrade/install-3.6.2.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2016 PrestaShop SA + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +if (!defined('_PS_VERSION_')) + exit; + +function upgrade_module_3_6_2($object) +{ + return ($object->registerHook('registerGDPRConsent') && + $object->registerHook('actionDeleteGDPRCustomer') && + $object->registerHook('actionExportGDPRData')); +} \ No newline at end of file diff --git a/views/templates/hook/product.tpl b/views/templates/hook/product.tpl index 05906d5..abfa06c 100644 --- a/views/templates/hook/product.tpl +++ b/views/templates/hook/product.tpl @@ -41,10 +41,12 @@ function oosHookJsCodeMailAlert() { if ($.trim(msg) == '0') { $('#mailalert_link').show(); $('#oos_customer_email').show(); + $('#oosHook').find('#gdpr_consent').show(); } else { $('#mailalert_link').hide(); $('#oos_customer_email').hide(); + $('#oosHook').find('#gdpr_consent').hide(); } } }); @@ -59,6 +61,7 @@ function addNotification() { if ($.trim(msg) == '1') { $('#mailalert_link').hide(); $('#oos_customer_email').hide(); + $('#oosHook').find('#gdpr_consent').hide(); $('#oos_customer_email_result').html("{/literal}{l s='Request notification registered' mod='mailalerts'}{literal}"); $('#oos_customer_email_result').css('color', 'green').show(); } @@ -89,9 +92,15 @@ $(document).ready(function() { +
{if isset($email) AND $email}
{/if} - {l s='Notify me when available' mod='mailalerts'} + + {if isset($id_module)} + {hook h='displayGDPRConsent' id_module=$id_module} + {/if} + +
From 8cfd02c8e1951605fb7d7c5232584d36031e7866 Mon Sep 17 00:00:00 2001 From: jGissinger Date: Thu, 24 May 2018 11:57:26 +0200 Subject: [PATCH 2/2] Change version to 3.7.0 --- config.xml | 2 +- mailalerts.php | 2 +- upgrade/{install-3.6.2.php => install-3.7.0.php} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename upgrade/{install-3.6.2.php => install-3.7.0.php} (96%) diff --git a/config.xml b/config.xml index d7e05f7..76320af 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ mailalerts - + diff --git a/mailalerts.php b/mailalerts.php index 00d6a3d..3271da5 100644 --- a/mailalerts.php +++ b/mailalerts.php @@ -48,7 +48,7 @@ public function __construct() { $this->name = 'mailalerts'; $this->tab = 'administration'; - $this->version = '3.6.2'; + $this->version = '3.7.0'; $this->author = 'PrestaShop'; $this->need_instance = 0; diff --git a/upgrade/install-3.6.2.php b/upgrade/install-3.7.0.php similarity index 96% rename from upgrade/install-3.6.2.php rename to upgrade/install-3.7.0.php index b9a48e5..217fe22 100644 --- a/upgrade/install-3.6.2.php +++ b/upgrade/install-3.7.0.php @@ -27,9 +27,9 @@ if (!defined('_PS_VERSION_')) exit; -function upgrade_module_3_6_2($object) +function upgrade_module_3_7_0($object) { return ($object->registerHook('registerGDPRConsent') && $object->registerHook('actionDeleteGDPRCustomer') && $object->registerHook('actionExportGDPRData')); -} \ No newline at end of file +}