View | Details | Raw Unified | Return to bug 27378
Collapse All | Expand All

(-)a/Koha/Template/Plugin/JSConsents.pm (-5 / +8 lines)
Lines 25-35 use JSON qw{ decode_json }; Link Here
25
use C4::Context;
25
use C4::Context;
26
26
27
sub all {
27
sub all {
28
    my ( $self ) = @_;
28
    my ( $self, $filter ) = @_;
29
    my $consents = C4::Context->preference( 'CookieConsentedJS' );
29
30
    if (length $consents > 0) {
30
    my $consents = C4::Context->preference('CookieConsentedJS');
31
        my $decoded = decode_base64($consents);
31
    if ( length $consents > 0 ) {
32
        return decode_json $decoded;
32
        my $decoded_consents  = decode_base64($consents);
33
        my $consents_array    = decode_json $decoded_consents;
34
        my @filtered_consents = grep { $_->{$filter} } @{$consents_array};
35
        return \@filtered_consents;
33
    } else {
36
    } else {
34
        return [];
37
        return [];
35
    }
38
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc (-5 / +5 lines)
Lines 94-100 Link Here
94
            [% END %]
94
            [% END %]
95
            <div id="consentButtons">
95
            <div id="consentButtons">
96
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
96
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
97
                [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
97
                [% IF ( JSConsents.all('staffConsent').size ) %]
98
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
98
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
99
                    <button type="button" class="btn btn-info" id="consentMoreInfo">More information</button>
99
                    <button type="button" class="btn btn-info" id="consentMoreInfo">More information</button>
100
                [% END %]
100
                [% END %]
Lines 116-122 Link Here
116
                            </div>
116
                            </div>
117
                        [% END %]
117
                        [% END %]
118
                        <div id="consentCookieList">
118
                        <div id="consentCookieList">
119
                            [% consents = JSConsents.all() %]
119
                            [% consents = JSConsents.all('staffConsent') %]
120
                            [% FOREACH consent IN consents %]
120
                            [% FOREACH consent IN consents %]
121
                                <div class="consentModalItem">
121
                                <div class="consentModalItem">
122
                                    <div class="consentItemCheckbox">
122
                                    <div class="consentItemCheckbox">
Lines 133-139 Link Here
133
                    <div class="modal-footer">
133
                    <div class="modal-footer">
134
                        <div id="consentButtons">
134
                        <div id="consentButtons">
135
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
135
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
136
                            [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
136
                            [% IF ( JSConsents.all('staffConsent').size ) %]
137
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
137
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
138
                                <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button>
138
                                <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button>
139
                            [% END %]
139
                            [% END %]
Lines 145-152 Link Here
145
        </div>  <!-- /#cookieConsentModal  -->
145
        </div>  <!-- /#cookieConsentModal  -->
146
    [% END %]
146
    [% END %]
147
    <!-- CookieConsentedJS code that may run -->
147
    <!-- CookieConsentedJS code that may run -->
148
    [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %]
148
    [% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('staffConsent').size %]
149
        [% consents = JSConsents.all() %]
149
        [% consents = JSConsents.all('staffConsent') %]
150
        [% FOREACH consent IN consents %]
150
        [% FOREACH consent IN consents %]
151
            <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>
151
            <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>
152
        [% END %]
152
        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (-3 / +3 lines)
Lines 462-468 Link Here
462
                [% END %]
462
                [% END %]
463
                <div id="consentButtons">
463
                <div id="consentButtons">
464
                    <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
464
                    <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
465
                    [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
465
                    [% IF ( JSConsents.all('opacConsent').size ) %]
466
                        <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
466
                        <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
467
                        <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
467
                        <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
468
                    [% END %]
468
                    [% END %]
Lines 482-488 Link Here
482
                            </div>
482
                            </div>
483
                        [% END %]
483
                        [% END %]
484
                        <div id="consentCookieList">
484
                        <div id="consentCookieList">
485
                            [% consents = JSConsents.all() %]
485
                            [% consents = JSConsents.all('opacConsent') %]
486
                            [% FOREACH consent IN consents %]
486
                            [% FOREACH consent IN consents %]
487
                                <div class="consentModalItem">
487
                                <div class="consentModalItem">
488
                                    <div class="consentItemCheckbox">
488
                                    <div class="consentItemCheckbox">
Lines 499-505 Link Here
499
                    <div class="modal-footer">
499
                    <div class="modal-footer">
500
                        <div id="consentButtons">
500
                        <div id="consentButtons">
501
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
501
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
502
                            [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
502
                            [% IF ( JSConsents.all('opacConsent').size ) %]
503
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
503
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
504
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
504
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
505
                            [% END %]
505
                            [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-3 / +2 lines)
Lines 125-132 Link Here
125
[% END %]
125
[% END %]
126
126
127
<!-- CookieConsentedJS code that may run -->
127
<!-- CookieConsentedJS code that may run -->
128
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %]
128
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
129
    [% consents = JSConsents.all() %]
129
    [% consents = JSConsents.all('opacConsent') %]
130
    [% FOREACH consent IN consents %]
130
    [% FOREACH consent IN consents %]
131
        <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>
131
        <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>
132
    [% END %]
132
    [% END %]
133
- 

Return to bug 27378