Bugzilla – Attachment 154025 Details for
Bug 27378
Enable compliance with EU Cookie Legislation via cookie consent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27378: (QA follow-up) Add filtering for OPAC only and staff only cookies
Bug-27378-QA-follow-up-Add-filtering-for-OPAC-only.patch (text/plain), 7.94 KB, created by
Matt Blenkinsop
on 2023-07-28 09:35:30 UTC
(
hide
)
Description:
Bug 27378: (QA follow-up) Add filtering for OPAC only and staff only cookies
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2023-07-28 09:35:30 UTC
Size:
7.94 KB
patch
obsolete
>From ad3ec11e73845a05bf6733b44243093d2ce7eae6 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Tue, 11 Jul 2023 16:43:59 +0000 >Subject: [PATCH] Bug 27378: (QA follow-up) Add filtering for OPAC only and > staff only cookies > >This patch fixes an issue where cookies selected as OPAC only would still show in the staff client and vise versa. The cookies are now filtered and only the correct cookies will be used in the OPAC and staff client >--- > Koha/Template/Plugin/JSConsents.pm | 13 ++++++++----- > .../prog/en/includes/intranet-bottom.inc | 10 +++++----- > .../opac-tmpl/bootstrap/en/includes/masthead.inc | 6 +++--- > .../opac-tmpl/bootstrap/en/includes/opac-bottom.inc | 4 ++-- > 4 files changed, 18 insertions(+), 15 deletions(-) > >diff --git a/Koha/Template/Plugin/JSConsents.pm b/Koha/Template/Plugin/JSConsents.pm >index 8a559904ad..2148cc12c3 100644 >--- a/Koha/Template/Plugin/JSConsents.pm >+++ b/Koha/Template/Plugin/JSConsents.pm >@@ -25,11 +25,14 @@ use JSON qw{ decode_json }; > use C4::Context; > > sub all { >- my ( $self ) = @_; >- my $consents = C4::Context->preference( 'CookieConsentedJS' ); >- if (length $consents > 0) { >- my $decoded = decode_base64($consents); >- return decode_json $decoded; >+ my ( $self, $filter ) = @_; >+ >+ my $consents = C4::Context->preference('CookieConsentedJS'); >+ if ( length $consents > 0 ) { >+ my $decoded_consents = decode_base64($consents); >+ my $consents_array = decode_json $decoded_consents; >+ my @filtered_consents = grep { $_->{$filter} } @{$consents_array}; >+ return \@filtered_consents; > } else { > return []; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >index 7627476516..cd3abdfb5a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc >@@ -94,7 +94,7 @@ > [% END %] > <div id="consentButtons"> > <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button> >- [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %] >+ [% IF ( JSConsents.all('staffConsent').size ) %] > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-info" id="consentMoreInfo">More information</button> > [% END %] >@@ -116,7 +116,7 @@ > </div> > [% END %] > <div id="consentCookieList"> >- [% consents = JSConsents.all() %] >+ [% consents = JSConsents.all('staffConsent') %] > [% FOREACH consent IN consents %] > <div class="consentModalItem"> > <div class="consentItemCheckbox"> >@@ -133,7 +133,7 @@ > <div class="modal-footer"> > <div id="consentButtons"> > <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button> >- [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %] >+ [% IF ( JSConsents.all('staffConsent').size ) %] > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button> > [% END %] >@@ -145,8 +145,8 @@ > </div> <!-- /#cookieConsentModal --> > [% END %] > <!-- CookieConsentedJS code that may run --> >- [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %] >- [% consents = JSConsents.all() %] >+ [% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('staffConsent').size %] >+ [% consents = JSConsents.all('staffConsent') %] > [% FOREACH consent IN consents %] > <div class="consentCode" style="display:none" aria-hidden="true" data-consent-id="[% consent.id | html %]" data-consent-code="[% consent.code | html %]" data-consent-match-pattern="[% consent.matchPattern | html %]" data-consent-cookie-domain="[% consent.cookieDomain | html %]" data-consent-cookie-path="[% consent.cookiePath | html %]" data-requires-consent="[% consent.staffConsent ? 'true' : 'false' | html %]"></div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index 8098b87078..8788bf9520 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -462,7 +462,7 @@ > [% END %] > <div id="consentButtons"> > <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button> >- [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %] >+ [% IF ( JSConsents.all('opacConsent').size ) %] > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button> > [% END %] >@@ -482,7 +482,7 @@ > </div> > [% END %] > <div id="consentCookieList"> >- [% consents = JSConsents.all() %] >+ [% consents = JSConsents.all('opacConsent') %] > [% FOREACH consent IN consents %] > <div class="consentModalItem"> > <div class="consentItemCheckbox"> >@@ -499,7 +499,7 @@ > <div class="modal-footer"> > <div id="consentButtons"> > <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button> >- [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %] >+ [% IF ( JSConsents.all('opacConsent').size ) %] > <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button> > <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index da9a88d7be..dbd9bb3e8c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -125,8 +125,8 @@ > [% END %] > > <!-- CookieConsentedJS code that may run --> >-[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %] >- [% consents = JSConsents.all() %] >+[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %] >+ [% consents = JSConsents.all('opacConsent') %] > [% FOREACH consent IN consents %] > <div class="consentCode" style="display:none" aria-hidden="true" data-consent-id="[% consent.id | html %]" data-consent-code="[% consent.code | html %]" data-consent-match-pattern="[% consent.matchPattern | html %]" data-consent-cookie-domain="[% consent.cookieDomain | html %]" data-consent-cookie-path="[% consent.cookiePath | html %]" data-requires-consent="[% consent.opacConsent ? 'true' : 'false' | html %]"></div> > [% END %] >-- >2.37.1 (Apple Git-137.1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27378
:
115544
|
115545
|
115546
|
115547
|
115548
|
115756
|
116397
|
116398
|
116399
|
116400
|
116401
|
116402
|
116403
|
116416
|
116417
|
116418
|
116419
|
116420
|
116421
|
116422
|
116423
|
116978
|
116979
|
116980
|
116981
|
116982
|
116983
|
116984
|
116985
|
116986
|
121728
|
121729
|
121730
|
121731
|
121732
|
121733
|
121734
|
121735
|
121995
|
121996
|
121997
|
121998
|
121999
|
122000
|
122001
|
122002
|
122635
|
122636
|
122637
|
122638
|
122639
|
122640
|
122641
|
122642
|
124957
|
124958
|
124959
|
124960
|
124961
|
124962
|
124963
|
124964
|
124965
|
130072
|
130073
|
130074
|
130075
|
130076
|
130077
|
130078
|
130079
|
130080
|
135309
|
135310
|
135311
|
135312
|
135313
|
135314
|
135315
|
135316
|
135317
|
135318
|
151735
|
151736
|
151737
|
151738
|
151739
|
151740
|
151741
|
151742
|
151743
|
151744
|
151745
|
151746
|
151747
|
151748
|
151749
|
151750
|
151751
|
151752
|
151753
|
151826
|
151827
|
151828
|
151829
|
151830
|
151831
|
151832
|
151833
|
151834
|
151835
|
151836
|
151837
|
151838
|
151839
|
151840
|
151841
|
151842
|
151843
|
151844
|
153326
|
153327
|
153328
|
153329
|
153330
|
153331
|
153332
|
153333
|
153334
|
153335
|
153336
|
154015
|
154016
|
154017
|
154018
|
154019
|
154020
|
154021
|
154022
|
154023
|
154024
|
154025
|
154093
|
154264
|
154265
|
154266
|
154267
|
154268
|
154269
|
154270
|
154271
|
154272
|
154273
|
154274
|
154275
|
154276