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 455-461 Link Here
455
                [% END %]
455
                [% END %]
456
                <div id="consentButtons">
456
                <div id="consentButtons">
457
                    <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
457
                    <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
458
                    [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
458
                    [% IF ( JSConsents.all('opacConsent').size ) %]
459
                        <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
459
                        <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
460
                        <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
460
                        <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
461
                    [% END %]
461
                    [% END %]
Lines 475-481 Link Here
475
                            </div>
475
                            </div>
476
                        [% END %]
476
                        [% END %]
477
                        <div id="consentCookieList">
477
                        <div id="consentCookieList">
478
                            [% consents = JSConsents.all() %]
478
                            [% consents = JSConsents.all('opacConsent') %]
479
                            [% FOREACH consent IN consents %]
479
                            [% FOREACH consent IN consents %]
480
                                <div class="consentModalItem">
480
                                <div class="consentModalItem">
481
                                    <div class="consentItemCheckbox">
481
                                    <div class="consentItemCheckbox">
Lines 492-498 Link Here
492
                    <div class="modal-footer">
492
                    <div class="modal-footer">
493
                        <div id="consentButtons">
493
                        <div id="consentButtons">
494
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
494
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
495
                            [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
495
                            [% IF ( JSConsents.all('opacConsent').size ) %]
496
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
496
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
497
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
497
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
498
                            [% END %]
498
                            [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-3 / +2 lines)
Lines 121-128 Link Here
121
[% END # / UNLESS is_popup %]
121
[% END # / UNLESS is_popup %]
122
122
123
<!-- CookieConsentedJS code that may run -->
123
<!-- CookieConsentedJS code that may run -->
124
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %]
124
[% IF Koha.Preference( 'CookieConsent' ) && JSConsents.all('opacConsent').size %]
125
    [% consents = JSConsents.all() %]
125
    [% consents = JSConsents.all('opacConsent') %]
126
    [% FOREACH consent IN consents %]
126
    [% FOREACH consent IN consents %]
127
        <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>
127
        <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>
128
    [% END %]
128
    [% END %]
129
- 

Return to bug 27378