@@ -535,6 +535,18 @@ function loadDisplayOptions($fromBookCoverProcessing = false) {
535
535
$ customJavascript = '' ;
536
536
if (!isset ($ _REQUEST ['noCustomJavaScript ' ]) && !isset ($ _REQUEST ['noCustom ' ])) {
537
537
try {
538
+ if (isset ($ _COOKIE ["cookieConsent " ])) {
539
+ $ cookie = json_decode (urldecode ($ _COOKIE ["cookieConsent " ]), true );
540
+ if ($ cookie != null ) {
541
+ $ analyticsPref = $ cookie ['Analytics ' ];
542
+ }else {
543
+ $ analyticsPref = 0 ;
544
+ }
545
+ }else {
546
+ $ cookie = null ;
547
+ $ analyticsPref = 0 ;
548
+ }
549
+
538
550
if (isset ($ location )) {
539
551
require_once ROOT_DIR . '/sys/LocalEnrichment/JavaScriptSnippetLocation.php ' ;
540
552
$ javascriptSnippetLocation = new JavaScriptSnippetLocation ();
@@ -545,10 +557,15 @@ function loadDisplayOptions($fromBookCoverProcessing = false) {
545
557
$ javascriptSnippet = new JavaScriptSnippet ();
546
558
$ javascriptSnippet ->id = $ javascriptSnippetLocation ->javascriptSnippetId ;
547
559
if ($ javascriptSnippet ->find (true )) {
548
- if (strlen ($ customJavascript ) > 0 ) {
549
- $ customJavascript .= "\n" ;
560
+ if (empty ($ library ->cookieStorageConsent ) ||
561
+ (!empty ($ library ->cookieStorageConsent ) && empty ($ javascriptSnippet ->containsAnalyticsCookies )) ||
562
+ (!empty ($ library ->cookieStorageConsent ) && !empty ($ javascriptSnippet ->containsAnalyticsCookies ) && $ analyticsPref == 1 )
563
+ ) {
564
+ if (strlen ($ customJavascript ) > 0 ) {
565
+ $ customJavascript .= "\n" ;
566
+ }
567
+ $ customJavascript .= trim ($ javascriptSnippet ->snippet );
550
568
}
551
- $ customJavascript .= trim ($ javascriptSnippet ->snippet );
552
569
}
553
570
}
554
571
} else {
@@ -561,10 +578,15 @@ function loadDisplayOptions($fromBookCoverProcessing = false) {
561
578
$ javascriptSnippet = new JavaScriptSnippet ();
562
579
$ javascriptSnippet ->id = $ javascriptSnippetLibrary ->javascriptSnippetId ;
563
580
if ($ javascriptSnippet ->find (true )) {
564
- if (strlen ($ customJavascript ) > 0 ) {
565
- $ customJavascript .= "\n" ;
581
+ if (empty ($ library ->cookieStorageConsent ) ||
582
+ (!empty ($ library ->cookieStorageConsent ) && empty ($ javascriptSnippet ->containsAnalyticsCookies )) ||
583
+ (!empty ($ library ->cookieStorageConsent ) && !empty ($ javascriptSnippet ->containsAnalyticsCookies ) && $ analyticsPref == 1 )
584
+ ) {
585
+ if (strlen ($ customJavascript ) > 0 ) {
586
+ $ customJavascript .= "\n" ;
587
+ }
588
+ $ customJavascript .= trim ($ javascriptSnippet ->snippet );
566
589
}
567
- $ customJavascript .= trim ($ javascriptSnippet ->snippet );
568
590
}
569
591
}
570
592
}
0 commit comments