Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #35 from Joukz/gdpr_compliance
Browse files Browse the repository at this point in the history
Add compliance to gdpr law (psgdpr module)
  • Loading branch information
eternoendless authored May 24, 2018
2 parents 41f7f4b + 8cfd02c commit 6c43f7f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>mailalerts</name>
<displayName><![CDATA[Mail alerts]]></displayName>
<version><![CDATA[3.6.1]]></version>
<version><![CDATA[3.7.0]]></version>
<description><![CDATA[Sends e-mail notifications to customers and merchants.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
29 changes: 27 additions & 2 deletions mailalerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct()
{
$this->name = 'mailalerts';
$this->tab = 'administration';
$this->version = '3.6.1';
$this->version = '3.7.0';
$this->author = 'PrestaShop';
$this->need_instance = 0;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
)
);

Expand Down Expand Up @@ -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(
Expand Down
35 changes: 35 additions & 0 deletions upgrade/install-3.7.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2016 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 [email protected] 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 <[email protected]>
* @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_7_0($object)
{
return ($object->registerHook('registerGDPRConsent') &&
$object->registerHook('actionDeleteGDPRCustomer') &&
$object->registerHook('actionExportGDPRData'));
}
11 changes: 10 additions & 1 deletion views/templates/hook/product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
Expand All @@ -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();
}
Expand Down Expand Up @@ -89,9 +92,15 @@ $(document).ready(function() {
</script>
<!-- MODULE MailAlerts -->
<form>
{if isset($email) AND $email}
<input type="text" id="oos_customer_email" name="customer_email" size="20" value="{l s='[email protected]' mod='mailalerts'}" class="mailalerts_oos_email" onclick="clearText();" /><br />
{/if}
<a href="#" title="{l s='Notify me when available' mod='mailalerts'}" onclick="return addNotification();" id="mailalert_link" rel="nofollow">{l s='Notify me when available' mod='mailalerts'}</a>
{if isset($id_module)}
{hook h='displayGDPRConsent' id_module=$id_module}
{/if}
<button type="submit" class="btn btn-default" title="{l s='Notify me when available' mod='mailalerts'}" onclick="return addNotification();" id="mailalert_link" rel="nofollow">{l s='Notify me when available' mod='mailalerts'}</button>
<span id="oos_customer_email_result" style="display:none;"></span>
</form>
<!-- END : MODULE MailAlerts -->

0 comments on commit 6c43f7f

Please sign in to comment.