diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/gdprcookieconsent.php b/gdprcookieconsent.php index fdd337f..c5b546c 100644 --- a/gdprcookieconsent.php +++ b/gdprcookieconsent.php @@ -49,11 +49,11 @@ class GdprCookieConsent extends Module 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') && - // 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'); + 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_MORE_INFO') && 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'); + 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'); $moreInfo = Tools::getValue('GDPR_COOKIE_MORE_INFO'); $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 Configuration::updateValue('GDPR_COOKIE_ENABLED', $enabled); @@ -103,6 +108,11 @@ class GdprCookieConsent extends Module Configuration::updateValue('GDPR_COOKIE_SETTINGS', $settings); Configuration::updateValue('GDPR_COOKIE_MORE_INFO', $moreInfo); 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 $output .= $this->displayConfirmation($this->l('Settings updated')); @@ -208,6 +218,26 @@ class GdprCookieConsent extends Module 'name' => 'GDPR_COOKIE_MORE_INFO_URL', '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' => [ '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_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'); + $helper->fields_value['GDPR_COOKIE_ONLY_REQUIRED'] = Configuration::get('GDPR_COOKIE_ONLY_REQUIRED'); return $helper->generateForm([$form]); } @@ -276,11 +306,11 @@ 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'), + 'gdprCookieOnlyRequired' => Configuration::get('GDPR_COOKIE_ONLY_REQUIRED'), ]); // Assign variables to Smarty for the manage button template @@ -317,6 +347,7 @@ class GdprCookieConsent extends Module 'gdprCookieRetentionPeriod' => Configuration::get('GDPR_COOKIE_RETENTION_PERIOD'), 'gdprCookieThirdParties' => Configuration::get('GDPR_COOKIE_THIRD_PARTIES'), 'gdprCookieManageText' => Configuration::get('GDPR_COOKIE_MANAGE_TEXT'), + 'gdprCookieOnlyRequired' => Configuration::get('GDPR_COOKIE_ONLY_REQUIRED'), ]); return $this->display(__FILE__, 'views/templates/hook/footer.tpl'); diff --git a/views/js/gdpr_cookie.js b/views/js/gdpr_cookie.js index 3871c45..72c1317 100644 --- a/views/js/gdpr_cookie.js +++ b/views/js/gdpr_cookie.js @@ -64,13 +64,15 @@ document.addEventListener('DOMContentLoaded', function() { acceptAllCookies(); }); - document.getElementById('gdpr-cookie-banner-decline').addEventListener('click', function() { - declineAllCookies(); - }); + if(!gdprCookieOnlyRequired) { + document.getElementById('gdpr-cookie-banner-decline').addEventListener('click', function() { + declineAllCookies(); + }); - document.getElementById('gdpr-cookie-banner-settings').addEventListener('click', function() { - showModal(); - }); + document.getElementById('gdpr-cookie-banner-settings').addEventListener('click', function() { + showModal(); + }); + } // Modal buttons document.getElementById('gdpr-cookie-accept-all').addEventListener('click', function() { diff --git a/views/templates/hook/footer.tpl b/views/templates/hook/footer.tpl index f845643..c9407f8 100644 --- a/views/templates/hook/footer.tpl +++ b/views/templates/hook/footer.tpl @@ -27,21 +27,23 @@
{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'}
- - - + {if !$gdprCookieOnlyRequired} + + + + {/if}