Skip to content
Snippets Groups Projects
Commit 43c1ca63 authored by Sven Berg Ryen's avatar Sven Berg Ryen
Browse files

Issue #3261155 by svenryen, John_B: We sometimes hit the cache before getting geographic location

parent 09631c7f
No related branches found
No related tags found
1 merge request!57Issue #3261155: We sometimes hit the cache before getting geographic location
......@@ -732,17 +732,29 @@ function eu_cookie_compliance_admin_form(array $form, array $form_state) {
);
if (module_exists('geoip') || module_exists('smart_ip') || extension_loaded('geoip')) {
$form['eu_only']['eu_cookie_compliance']['eu_only'] = array(
'#type' => 'checkbox',
'#title' => t('Only display banner in EU countries.'),
'#default_value' => isset($popup_settings['eu_only']) ? $popup_settings['eu_only'] : 0,
'#description' => t('You can limit the number of countries for which the banner is displayed by checking this option. If you want to provide a list of countries other than current EU states, you may place an array in <code>$conf[\'eu_cookie_compliance_eu_countries\']</code> in your <code>settings.php</code> file. Using the <a href="http://drupal.org/project/geoip">geoip</a> module or the <a href="http://drupal.org/project/smart_ip">smart_ip</a> module or the <a href="http://www.php.net/manual/en/function.geoip-country-code-by-name.php">geoip_country_code_by_name()</a> PHP function.'),
$form['eu_only']['eu_cookie_compliance']['eu_info'] = array(
'#type' => 'markup',
'#markup' => t('You can limit the number of countries for which the banner is displayed. If you want to provide a list of countries other than current EU states, you may place an array in <code>$conf[\'eu_cookie_compliance_eu_countries\']</code> in your <code>settings.php</code> file. Using the <a href="http://drupal.org/project/geoip">geoip</a> module or the <a href="http://drupal.org/project/smart_ip">smart_ip</a> module or the <a href="http://www.php.net/manual/en/function.geoip-country-code-by-name.php">geoip_country_code_by_name()</a> PHP function.'),
);
$form['eu_only']['eu_cookie_compliance']['eu_only_js'] = array(
'#type' => 'checkbox',
'#title' => t('JavaScript-based (for Varnish): Only display banner in EU countries.'),
'#default_value' => isset($popup_settings['eu_only_js']) ? $popup_settings['eu_only_js'] : 0,
'#description' => t('This option also works for visitors that bypass Varnish. You can limit the number of countries for which the banner is displayed by checking this option. If you want to provide a list of countries other than current EU states, you may place an array in <code>$conf[\'eu_cookie_compliance_eu_countries\']</code> in your <code>settings.php</code> file. Using the <a href="http://drupal.org/project/geoip">geoip</a> module or the <a href="http://drupal.org/project/smart_ip">smart_ip</a> module or the <a href="http://www.php.net/manual/en/function.geoip-country-code-by-name.php">geoip_country_code_by_name()</a> PHP function.'),
if (isset($popup_settings['eu_only']) && $popup_settings['eu_only'] == 1) {
$eu_option_default_value = 'eu_only';
}
elseif (isset($popup_settings['eu_only_js']) && $popup_settings['eu_only_js'] == 1) {
$eu_option_default_value = 'eu_only_js';
}
else {
$eu_option_default_value = 'disabled';
}
$form['eu_only']['eu_cookie_compliance']['eu_option'] = array(
'#type' => 'radios',
'#options' => array(
'eu_only_js' => t('Use JavaScript to determine if the visitor is in a country where GDPR applies. Required if caching is enabled or a caching strategy such as varnish is utilized.'),
'eu_only' => t('I have no caching enabled or set up. Use non-JavaScript method.'),
'disabled' => t('Disabled. Show the banner to all visitors, also those in non-GDPR countries.'),
),
'#default_value' => $eu_option_default_value,
);
}
else {
......@@ -944,6 +956,18 @@ function eu_cookie_compliance_admin_form(array $form, array $form_state) {
* Form state array.
*/
function eu_cookie_compliance_admin_form_validate(array $form, array &$form_state) {
$form_state['values']['eu_cookie_compliance']['eu_only_js'] = '0';
$form_state['values']['eu_cookie_compliance']['eu_only'] = '0';
if (!empty($form_state['values']['eu_cookie_compliance']['eu_option'])) {
if ($form_state['values']['eu_cookie_compliance']['eu_option'] === 'eu_only') {
$form_state['values']['eu_cookie_compliance']['eu_only'] = '1';
}
elseif ($form_state['values']['eu_cookie_compliance']['eu_option'] === 'eu_only_js') {
$form_state['values']['eu_cookie_compliance']['eu_only_js'] = '1';
}
}
if ($form_state['values']['eu_cookie_compliance']['popup_agreed_enabled']) {
if (empty($form_state['values']['eu_cookie_compliance']['popup_agreed']['value'])) {
form_set_error('eu_cookie_compliance][popup_agreed', t('@name field is required', array('@name' => '"Thank you" banner message')));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment