Improved GDPR compliance
- Add more customization TODO: Update styling
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* GDPR Cookie Consent Module for PrestaShop
|
||||
*
|
||||
@ -42,14 +43,20 @@ class GdprCookieConsent extends Module
|
||||
$this->registerHook('displayHeader') &&
|
||||
$this->registerHook('displayFooter') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_ENABLED', 1) &&
|
||||
Configuration::updateValue('GDPR_COOKIE_MESSAGE', 'This website uses cookies to ensure you get the best experience on our website.') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_MESSAGE', 'This website uses cookies to ensure you get the best experience. We collect and process your data for website functionality, analytics, and personalized advertising.') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_ACCEPT', 'Accept All Cookies') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_DECLINE', 'Decline') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_DECLINE', 'Decline Non-Essential') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_SETTINGS', 'Cookie Settings') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO', 'More Information') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO_URL', 'content/2-privacy-policy');
|
||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO_URL', 'content/2-privacy-policy') &&
|
||||
// New configuration values
|
||||
Configuration::updateValue('GDPR_COOKIE_DATA_CONTROLLER', 'Your Company Name') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_RETENTION_PERIOD', '365 days') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_THIRD_PARTIES', 'Google Analytics, Facebook, etc.') &&
|
||||
Configuration::updateValue('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookie Preferences');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uninstall the module
|
||||
*/
|
||||
@ -62,7 +69,12 @@ class GdprCookieConsent extends Module
|
||||
Configuration::deleteByName('GDPR_COOKIE_DECLINE') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_SETTINGS') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_MORE_INFO') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_MORE_INFO_URL');
|
||||
Configuration::deleteByName('GDPR_COOKIE_MORE_INFO_URL') &&
|
||||
// New configuration values
|
||||
Configuration::deleteByName('GDPR_COOKIE_DATA_CONTROLLER') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_RETENTION_PERIOD') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_THIRD_PARTIES') &&
|
||||
Configuration::deleteByName('GDPR_COOKIE_MANAGE_TEXT');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,6 +149,27 @@ class GdprCookieConsent extends Module
|
||||
'name' => 'GDPR_COOKIE_MESSAGE',
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Data Controller'),
|
||||
'name' => 'GDPR_COOKIE_DATA_CONTROLLER',
|
||||
'desc' => $this->l('Your company/organization name'),
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Cookie Retention Period'),
|
||||
'name' => 'GDPR_COOKIE_RETENTION_PERIOD',
|
||||
'desc' => $this->l('How long cookies will be stored (e.g., 365 days)'),
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Third-Party Recipients'),
|
||||
'name' => 'GDPR_COOKIE_THIRD_PARTIES',
|
||||
'desc' => $this->l('List third parties that receive cookie data'),
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Accept Button Text'),
|
||||
@ -155,6 +188,13 @@ class GdprCookieConsent extends Module
|
||||
'name' => 'GDPR_COOKIE_SETTINGS',
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Manage Preferences Text'),
|
||||
'name' => 'GDPR_COOKIE_MANAGE_TEXT',
|
||||
'desc' => $this->l('Text for the manage preferences button (displayed after consent is given)'),
|
||||
'required' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'label' => $this->l('More Info Button Text'),
|
||||
@ -202,6 +242,11 @@ class GdprCookieConsent extends Module
|
||||
$helper->fields_value['GDPR_COOKIE_SETTINGS'] = Configuration::get('GDPR_COOKIE_SETTINGS');
|
||||
$helper->fields_value['GDPR_COOKIE_MORE_INFO'] = Configuration::get('GDPR_COOKIE_MORE_INFO');
|
||||
$helper->fields_value['GDPR_COOKIE_MORE_INFO_URL'] = Configuration::get('GDPR_COOKIE_MORE_INFO_URL');
|
||||
// New fields
|
||||
$helper->fields_value['GDPR_COOKIE_DATA_CONTROLLER'] = Configuration::get('GDPR_COOKIE_DATA_CONTROLLER');
|
||||
$helper->fields_value['GDPR_COOKIE_RETENTION_PERIOD'] = Configuration::get('GDPR_COOKIE_RETENTION_PERIOD');
|
||||
$helper->fields_value['GDPR_COOKIE_THIRD_PARTIES'] = Configuration::get('GDPR_COOKIE_THIRD_PARTIES');
|
||||
$helper->fields_value['GDPR_COOKIE_MANAGE_TEXT'] = Configuration::get('GDPR_COOKIE_MANAGE_TEXT');
|
||||
|
||||
return $helper->generateForm([$form]);
|
||||
}
|
||||
@ -231,7 +276,22 @@ class GdprCookieConsent extends Module
|
||||
'gdprCookieMoreInfoUrl' => $this->context->link->getCMSLink(
|
||||
Configuration::get('GDPR_COOKIE_MORE_INFO_URL')
|
||||
),
|
||||
// New variables
|
||||
'gdprCookieDataController' => Configuration::get('GDPR_COOKIE_DATA_CONTROLLER', ''),
|
||||
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD', '365 days'),
|
||||
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES', ''),
|
||||
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookies'),
|
||||
]);
|
||||
|
||||
// Assign variables to Smarty for the manage button template
|
||||
$this->context->smarty->assign([
|
||||
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookies'),
|
||||
]);
|
||||
|
||||
// Return the template content - but don't throw an error if it doesn't exist yet
|
||||
if (file_exists(_PS_MODULE_DIR_ . $this->name . '/views/templates/hook/manage_button.tpl')) {
|
||||
return $this->display(__FILE__, 'views/templates/hook/manage_button.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,8 +312,13 @@ class GdprCookieConsent extends Module
|
||||
'gdprCookieMoreInfoUrl' => $this->context->link->getCMSLink(
|
||||
Configuration::get('GDPR_COOKIE_MORE_INFO_URL')
|
||||
),
|
||||
// New variables
|
||||
'gdprCookieDataController' => Configuration::get('GDPR_COOKIE_DATA_CONTROLLER'),
|
||||
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD'),
|
||||
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES'),
|
||||
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT'),
|
||||
]);
|
||||
|
||||
return $this->display(__FILE__, 'views/templates/hook/footer.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user