From 7f113a6d82ab57cfd3441475d547c80802670483 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 22 Nov 2021 09:53:33 +0100 Subject: [PATCH] cookie consent path + lax --- core/core.js.php | 65 +++++++++++++++++++++++++++++------------------- core/core.php | 2 +- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/core/core.js.php b/core/core.js.php index de79f572..831967bf 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -219,31 +219,46 @@ core.start = function() { } }); - /** - * Traitement du formulaire cookies - */ - $("#cookieForm").submit(function(event){ - var samesite = "samesite=lax"; - var getUrl = window.location; - var domain = "domain=" + getUrl.host; - var path = "path=" + getUrl.pathname.split('/')[1]; - var samesite = "samesite=lax"; - var e = new Date(); - e.setFullYear(e.getFullYear() + 1); - var expires = "expires=" + e.toUTCString(); - - // Crée le cookie d'acceptation Google Analytics si nécessaire - var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; - if( analytics.length > 0){ - document.cookie = "ZWII_COOKIE_GA_CONSENT=" + $("#googleAnalytics").prop("checked") + "" +";" + domain + ";" + path + ";" + samesite + ";" + expires; - } - document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; - }); - - $("#cookieConsent .cookieClose").on("click", function() { - $(this).parents("#cookieConsent").fadeOut(); - }); - + /** + * Message sur l'utilisation des cookies + */ + var analytics = ""; + if (getData(['config', 'seo', 'analyticsId'])); ?>) { + analytics = ' grâce au cookie Google Analytics' + } + if(getData(['config', 'cookieConsent'])); ?>) { + if(document.cookie.indexOf("ZWII_COOKIE_CONSENT") === -1) { + $("body").append( + $("
").attr("id", "cookieConsent").append( + $("").html("

Ce site utilise des cookies pour assurer l'authentification, améliorer l'expérience utilisateur"+analytics+".
En cliquant sur ”J’accepte”, vous acceptez l’utilisation de ces cookies.

"), + $("") + .attr("id", "cookieConsentConfirm") + .text("Accepter") + .on("click", function() { + // Créé le cookie d'acceptation + var expires = new Date(); + expires.setFullYear(expires.getFullYear() + 1); + expires = "expires=" + expires.toUTCString(); + document.cookie = "ZWII_COOKIE_CONSENT=true;path:/;samesite=lax;" + expires; + // Ferme le message + $(this).parents("#cookieConsent").fadeOut(); + }), + $("") + .attr("id", "cookieConsentRefuse") + .text("Refuser") + .on("click", function() { + // Créé le cookie d'acceptation + var expires = new Date(); + expires.setFullYear(expires.getFullYear() + 1); + expires = "expires=" + expires.toUTCString(); + document.cookie = "ZWII_COOKIE_CONSENT=false;path:/;samesite=lax;" + expires; + // Ferme le message + $(this).parents("#cookieConsent").fadeOut(); + }), + ) + ); + } + } /** * Choix de page dans la barre de membre */ diff --git a/core/core.php b/core/core.php index cf083385..01d5b49e 100644 --- a/core/core.php +++ b/core/core.php @@ -45,7 +45,7 @@ class common { // Numéro de version const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_VERSION = '11.2.00.7'; + const ZWII_VERSION = '11.2.00.8'; const ZWII_UPDATE_CHANNEL = "test"; public static $actions = [];