Add only required cookies option
This commit is contained in:
parent
5172966eb2
commit
2cab569707
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea/
|
@ -49,11 +49,11 @@ class GdprCookieConsent extends Module
|
|||||||
Configuration::updateValue('GDPR_COOKIE_SETTINGS', 'Cookie Settings') &&
|
Configuration::updateValue('GDPR_COOKIE_SETTINGS', 'Cookie Settings') &&
|
||||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO', 'More Information') &&
|
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_DATA_CONTROLLER', 'Your Company Name') &&
|
||||||
Configuration::updateValue('GDPR_COOKIE_RETENTION_PERIOD', '365 days') &&
|
Configuration::updateValue('GDPR_COOKIE_RETENTION_PERIOD', '365 days') &&
|
||||||
Configuration::updateValue('GDPR_COOKIE_THIRD_PARTIES', 'Google Analytics, Facebook, etc.') &&
|
Configuration::updateValue('GDPR_COOKIE_THIRD_PARTIES', 'Google Analytics, Facebook, etc.') &&
|
||||||
Configuration::updateValue('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookie Preferences');
|
Configuration::updateValue('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookie Preferences') &&
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_ONLY_REQUIRED', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,11 +70,11 @@ class GdprCookieConsent extends Module
|
|||||||
Configuration::deleteByName('GDPR_COOKIE_SETTINGS') &&
|
Configuration::deleteByName('GDPR_COOKIE_SETTINGS') &&
|
||||||
Configuration::deleteByName('GDPR_COOKIE_MORE_INFO') &&
|
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_DATA_CONTROLLER') &&
|
||||||
Configuration::deleteByName('GDPR_COOKIE_RETENTION_PERIOD') &&
|
Configuration::deleteByName('GDPR_COOKIE_RETENTION_PERIOD') &&
|
||||||
Configuration::deleteByName('GDPR_COOKIE_THIRD_PARTIES') &&
|
Configuration::deleteByName('GDPR_COOKIE_THIRD_PARTIES') &&
|
||||||
Configuration::deleteByName('GDPR_COOKIE_MANAGE_TEXT');
|
Configuration::deleteByName('GDPR_COOKIE_MANAGE_TEXT') &&
|
||||||
|
Configuration::deleteByName('GDPR_COOKIE_ONLY_REQUIRED');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,6 +94,11 @@ class GdprCookieConsent extends Module
|
|||||||
$settings = Tools::getValue('GDPR_COOKIE_SETTINGS');
|
$settings = Tools::getValue('GDPR_COOKIE_SETTINGS');
|
||||||
$moreInfo = Tools::getValue('GDPR_COOKIE_MORE_INFO');
|
$moreInfo = Tools::getValue('GDPR_COOKIE_MORE_INFO');
|
||||||
$moreInfoUrl = Tools::getValue('GDPR_COOKIE_MORE_INFO_URL');
|
$moreInfoUrl = Tools::getValue('GDPR_COOKIE_MORE_INFO_URL');
|
||||||
|
$dataController = Tools::getValue('GDPR_COOKIE_DATA_CONTROLLER');
|
||||||
|
$retentionPeriod = Tools::getValue('GDPR_COOKIE_RETENTION_PERIOD');
|
||||||
|
$thirdParties = Tools::getValue('GDPR_COOKIE_THIRD_PARTIES');
|
||||||
|
$manageText = Tools::getValue('GDPR_COOKIE_MANAGE_TEXT');
|
||||||
|
$onlyRequired = Tools::getValue('GDPR_COOKIE_ONLY_REQUIRED');
|
||||||
|
|
||||||
// Update configuration values
|
// Update configuration values
|
||||||
Configuration::updateValue('GDPR_COOKIE_ENABLED', $enabled);
|
Configuration::updateValue('GDPR_COOKIE_ENABLED', $enabled);
|
||||||
@ -103,6 +108,11 @@ class GdprCookieConsent extends Module
|
|||||||
Configuration::updateValue('GDPR_COOKIE_SETTINGS', $settings);
|
Configuration::updateValue('GDPR_COOKIE_SETTINGS', $settings);
|
||||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO', $moreInfo);
|
Configuration::updateValue('GDPR_COOKIE_MORE_INFO', $moreInfo);
|
||||||
Configuration::updateValue('GDPR_COOKIE_MORE_INFO_URL', $moreInfoUrl);
|
Configuration::updateValue('GDPR_COOKIE_MORE_INFO_URL', $moreInfoUrl);
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_DATA_CONTROLLER', $dataController);
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_RETENTION_PERIOD', $retentionPeriod);
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_THIRD_PARTIES', $thirdParties);
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_MANAGE_TEXT', $manageText);
|
||||||
|
Configuration::updateValue('GDPR_COOKIE_ONLY_REQUIRED', $onlyRequired);
|
||||||
|
|
||||||
// Display confirmation
|
// Display confirmation
|
||||||
$output .= $this->displayConfirmation($this->l('Settings updated'));
|
$output .= $this->displayConfirmation($this->l('Settings updated'));
|
||||||
@ -208,6 +218,26 @@ class GdprCookieConsent extends Module
|
|||||||
'name' => 'GDPR_COOKIE_MORE_INFO_URL',
|
'name' => 'GDPR_COOKIE_MORE_INFO_URL',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'type' => 'switch',
|
||||||
|
'label' => $this->l('This cookie types are used'),
|
||||||
|
'name' => 'GDPR_COOKIE_ONLY_REQUIRED',
|
||||||
|
'desc' => $this->l('If this option is enabled, no config modal will be rendered and there will only be a single button to hide the cookie notice. (Only enable this, if you don\'t track any user data)'),
|
||||||
|
'is_bool' => true,
|
||||||
|
'required' => true,
|
||||||
|
'values' => [
|
||||||
|
[
|
||||||
|
'id' => 'active_on',
|
||||||
|
'value' => 1,
|
||||||
|
'label' => $this->l('Nessessary only')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'active_off',
|
||||||
|
'value' => 0,
|
||||||
|
'label' => $this->l('All cookies')
|
||||||
|
]
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'submit' => [
|
'submit' => [
|
||||||
'title' => $this->l('Save'),
|
'title' => $this->l('Save'),
|
||||||
@ -242,11 +272,11 @@ class GdprCookieConsent extends Module
|
|||||||
$helper->fields_value['GDPR_COOKIE_SETTINGS'] = Configuration::get('GDPR_COOKIE_SETTINGS');
|
$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'] = Configuration::get('GDPR_COOKIE_MORE_INFO');
|
||||||
$helper->fields_value['GDPR_COOKIE_MORE_INFO_URL'] = Configuration::get('GDPR_COOKIE_MORE_INFO_URL');
|
$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_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_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_THIRD_PARTIES'] = Configuration::get('GDPR_COOKIE_THIRD_PARTIES');
|
||||||
$helper->fields_value['GDPR_COOKIE_MANAGE_TEXT'] = Configuration::get('GDPR_COOKIE_MANAGE_TEXT');
|
$helper->fields_value['GDPR_COOKIE_MANAGE_TEXT'] = Configuration::get('GDPR_COOKIE_MANAGE_TEXT');
|
||||||
|
$helper->fields_value['GDPR_COOKIE_ONLY_REQUIRED'] = Configuration::get('GDPR_COOKIE_ONLY_REQUIRED');
|
||||||
|
|
||||||
return $helper->generateForm([$form]);
|
return $helper->generateForm([$form]);
|
||||||
}
|
}
|
||||||
@ -276,11 +306,11 @@ class GdprCookieConsent extends Module
|
|||||||
'gdprCookieMoreInfoUrl' => $this->context->link->getCMSLink(
|
'gdprCookieMoreInfoUrl' => $this->context->link->getCMSLink(
|
||||||
Configuration::get('GDPR_COOKIE_MORE_INFO_URL')
|
Configuration::get('GDPR_COOKIE_MORE_INFO_URL')
|
||||||
),
|
),
|
||||||
// New variables
|
|
||||||
'gdprCookieDataController' => Configuration::get('GDPR_COOKIE_DATA_CONTROLLER', ''),
|
'gdprCookieDataController' => Configuration::get('GDPR_COOKIE_DATA_CONTROLLER', ''),
|
||||||
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD', '365 days'),
|
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD', '365 days'),
|
||||||
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES', ''),
|
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES', ''),
|
||||||
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookies'),
|
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT', 'Manage Cookies'),
|
||||||
|
'gdprCookieOnlyRequired' => Configuration::get('GDPR_COOKIE_ONLY_REQUIRED'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Assign variables to Smarty for the manage button template
|
// Assign variables to Smarty for the manage button template
|
||||||
@ -317,6 +347,7 @@ class GdprCookieConsent extends Module
|
|||||||
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD'),
|
'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD'),
|
||||||
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES'),
|
'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES'),
|
||||||
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT'),
|
'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT'),
|
||||||
|
'gdprCookieOnlyRequired' => Configuration::get('GDPR_COOKIE_ONLY_REQUIRED'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->display(__FILE__, 'views/templates/hook/footer.tpl');
|
return $this->display(__FILE__, 'views/templates/hook/footer.tpl');
|
||||||
|
@ -64,13 +64,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
acceptAllCookies();
|
acceptAllCookies();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('gdpr-cookie-banner-decline').addEventListener('click', function() {
|
if(!gdprCookieOnlyRequired) {
|
||||||
declineAllCookies();
|
document.getElementById('gdpr-cookie-banner-decline').addEventListener('click', function() {
|
||||||
});
|
declineAllCookies();
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById('gdpr-cookie-banner-settings').addEventListener('click', function() {
|
document.getElementById('gdpr-cookie-banner-settings').addEventListener('click', function() {
|
||||||
showModal();
|
showModal();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Modal buttons
|
// Modal buttons
|
||||||
document.getElementById('gdpr-cookie-accept-all').addEventListener('click', function() {
|
document.getElementById('gdpr-cookie-accept-all').addEventListener('click', function() {
|
||||||
|
@ -27,21 +27,23 @@
|
|||||||
<label for="gdpr-cookie-necessary">{l s='Necessary' mod='gdprcookieconsent'}</label>
|
<label for="gdpr-cookie-necessary">{l s='Necessary' mod='gdprcookieconsent'}</label>
|
||||||
<p>{l s='Necessary cookies help make a website usable by enabling basic functions like page navigation. The website cannot function properly without these cookies.' mod='gdprcookieconsent'}</p>
|
<p>{l s='Necessary cookies help make a website usable by enabling basic functions like page navigation. The website cannot function properly without these cookies.' mod='gdprcookieconsent'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="gdpr-cookie-category">
|
{if !$gdprCookieOnlyRequired}
|
||||||
<input type="checkbox" id="gdpr-cookie-functional" class="gdpr-cookie-checkbox" data-cookie-category="functional">
|
<div class="gdpr-cookie-category">
|
||||||
<label for="gdpr-cookie-functional">{l s='Functional' mod='gdprcookieconsent'}</label>
|
<input type="checkbox" id="gdpr-cookie-functional" class="gdpr-cookie-checkbox" data-cookie-category="functional">
|
||||||
<p>{l s='Functional cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region you are in.' mod='gdprcookieconsent'}</p>
|
<label for="gdpr-cookie-functional">{l s='Functional' mod='gdprcookieconsent'}</label>
|
||||||
</div>
|
<p>{l s='Functional cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region you are in.' mod='gdprcookieconsent'}</p>
|
||||||
<div class="gdpr-cookie-category">
|
</div>
|
||||||
<input type="checkbox" id="gdpr-cookie-analytics" class="gdpr-cookie-checkbox" data-cookie-category="analytics">
|
<div class="gdpr-cookie-category">
|
||||||
<label for="gdpr-cookie-analytics">{l s='Analytics' mod='gdprcookieconsent'}</label>
|
<input type="checkbox" id="gdpr-cookie-analytics" class="gdpr-cookie-checkbox" data-cookie-category="analytics">
|
||||||
<p>{l s='Analytics cookies help website owners understand how visitors interact with websites by collecting and reporting information anonymously.' mod='gdprcookieconsent'}</p>
|
<label for="gdpr-cookie-analytics">{l s='Analytics' mod='gdprcookieconsent'}</label>
|
||||||
</div>
|
<p>{l s='Analytics cookies help website owners understand how visitors interact with websites by collecting and reporting information anonymously.' mod='gdprcookieconsent'}</p>
|
||||||
<div class="gdpr-cookie-category">
|
</div>
|
||||||
<input type="checkbox" id="gdpr-cookie-marketing" class="gdpr-cookie-checkbox" data-cookie-category="marketing">
|
<div class="gdpr-cookie-category">
|
||||||
<label for="gdpr-cookie-marketing">{l s='Marketing' mod='gdprcookieconsent'}</label>
|
<input type="checkbox" id="gdpr-cookie-marketing" class="gdpr-cookie-checkbox" data-cookie-category="marketing">
|
||||||
<p>{l s='Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user.' mod='gdprcookieconsent'}</p>
|
<label for="gdpr-cookie-marketing">{l s='Marketing' mod='gdprcookieconsent'}</label>
|
||||||
</div>
|
<p>{l s='Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user.' mod='gdprcookieconsent'}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="gdpr-cookie-modal-footer">
|
<div class="gdpr-cookie-modal-footer">
|
||||||
@ -58,13 +60,15 @@
|
|||||||
<div id="gdpr-cookie-banner" class="gdpr-cookie-banner">
|
<div id="gdpr-cookie-banner" class="gdpr-cookie-banner">
|
||||||
<div class="gdpr-cookie-banner-content">
|
<div class="gdpr-cookie-banner-content">
|
||||||
<p>{$gdprCookieMessage}</p>
|
<p>{$gdprCookieMessage}</p>
|
||||||
<div class="gdpr-cookie-banner-info">
|
{* <div class="gdpr-cookie-banner-info">*}
|
||||||
<p><small><strong>{l s='Data Controller:' mod='gdprcookieconsent'}</strong> {$gdprCookieDataController} |
|
{* <p><small><strong>{l s='Data Controller:' mod='gdprcookieconsent'}</strong> {$gdprCookieDataController} | *}
|
||||||
<strong>{l s='Retention:' mod='gdprcookieconsent'}</strong> {$gdprCookieRetentionPeriod}</small></p>
|
{* <strong>{l s='Retention:' mod='gdprcookieconsent'}</strong> {$gdprCookieRetentionPeriod}</small></p>*}
|
||||||
</div>
|
{* </div>*}
|
||||||
<div class="gdpr-cookie-banner-buttons">
|
<div class="gdpr-cookie-banner-buttons">
|
||||||
<button id="gdpr-cookie-banner-decline" class="gdpr-cookie-banner-decline">{$gdprCookieDecline}</button>
|
{if !$gdprCookieOnlyRequired}
|
||||||
<button id="gdpr-cookie-banner-settings" class="gdpr-cookie-banner-settings">{$gdprCookieSettings}</button>
|
<button id="gdpr-cookie-banner-decline" class="gdpr-cookie-banner-decline">{$gdprCookieDecline}</button>
|
||||||
|
<button id="gdpr-cookie-banner-settings" class="gdpr-cookie-banner-settings">{$gdprCookieSettings}</button>
|
||||||
|
{/if}
|
||||||
<button id="gdpr-cookie-banner-accept" class="gdpr-cookie-banner-accept">{$gdprCookieAccept}</button>
|
<button id="gdpr-cookie-banner-accept" class="gdpr-cookie-banner-accept">{$gdprCookieAccept}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user