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

(-)a/Koha/Template/Plugin/JSConsents.pm (-2 / +2 lines)
Lines 26-32 use C4::Context; Link Here
26
26
27
sub all {
27
sub all {
28
    my ( $self ) = @_;
28
    my ( $self ) = @_;
29
    my $consents = C4::Context->preference( 'ConsentJS' );
29
    my $consents = C4::Context->preference( 'CookieConsentedJS' );
30
    if (length $consents > 0) {
30
    if (length $consents > 0) {
31
        my $decoded = decode_base64($consents);
31
        my $decoded = decode_base64($consents);
32
        return decode_json $decoded;
32
        return decode_json $decoded;
Lines 40-46 sub all { Link Here
40
=head1 NAME
40
=head1 NAME
41
41
42
Koha::Template::Plugin::JSConsents - TT Plugin for Javascript consents
42
Koha::Template::Plugin::JSConsents - TT Plugin for Javascript consents
43
Provided by ConsentJS syspref
43
Provided by CookieConsentedJS syspref
44
44
45
=head1 SYNOPSIS
45
=head1 SYNOPSIS
46
46
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 157-163 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
157
('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
157
('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
158
('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'),
158
('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'),
159
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
159
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
160
('ConsentJS', '', NULL, 'Specify Javascript that requires user consent to run (e.g. tracking code)', 'Free'),
160
('CookieConsentedJS', '', NULL, 'Add Javascript code that will run if cookie consent is provided (e.g. tracking code).', 'Free'),
161
('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo'),
161
('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo'),
162
('ContentWarningField', '', NULL, 'MARC field to use for content warnings', 'Free'),
162
('ContentWarningField', '', NULL, 'MARC field to use for content warnings', 'Free'),
163
('CookieConsent', '0', NULL, 'Require cookie consent to be displayed', 'YesNo'),
163
('CookieConsent', '0', NULL, 'Require cookie consent to be displayed', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (-3 / +3 lines)
Lines 4330-4343 div .suggestion_note { Link Here
4330
    }
4330
    }
4331
}
4331
}
4332
4332
4333
#consentJSItems {
4333
#cookieConsentedJSItems {
4334
    #consentJSWarning {
4334
    #cookieConsentedJSWarning {
4335
        margin: 20px 0;
4335
        margin: 20px 0;
4336
        text-align: center;
4336
        text-align: center;
4337
        font-weight: 800;
4337
        font-weight: 800;
4338
        font-size: 120%;
4338
        font-size: 120%;
4339
    }
4339
    }
4340
    .consentJSItem {
4340
    .cookieConsentedJSItem {
4341
        margin-bottom: 30px;
4341
        margin-bottom: 30px;
4342
        padding: 10px;
4342
        padding: 10px;
4343
        border: 1px solid #ccc;
4343
        border: 1px solid #ccc;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc (-4 / +4 lines)
Lines 85-91 Link Here
85
            [% Koha.Preference( 'CookieConsentBar' ) | $raw %]
85
            [% Koha.Preference( 'CookieConsentBar' ) | $raw %]
86
            <div id="consentButtons">
86
            <div id="consentButtons">
87
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
87
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
88
                [% IF ( Koha.Preference( 'ConsentJS' ).length > 0 ) %]
88
                [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
89
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
89
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
90
                    <button type="button" class="btn btn-info" id="consentMoreInfo">More information</button>
90
                    <button type="button" class="btn btn-info" id="consentMoreInfo">More information</button>
91
                [% END %]
91
                [% END %]
Lines 122-128 Link Here
122
                    <div class="modal-footer">
122
                    <div class="modal-footer">
123
                        <div id="consentButtons">
123
                        <div id="consentButtons">
124
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
124
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
125
                            [% IF ( Koha.Preference( 'ConsentJS' ).length > 0 ) %]
125
                            [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
126
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
126
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
127
                                <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button>
127
                                <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button>
128
                            [% END %]
128
                            [% END %]
Lines 132-139 Link Here
132
            </div> <!-- /.modal-dialog -->
132
            </div> <!-- /.modal-dialog -->
133
        </div>  <!-- /#cookieConsentModal  -->
133
        </div>  <!-- /#cookieConsentModal  -->
134
    [% END %]
134
    [% END %]
135
    <!-- ConsentJS code that may run -->
135
    <!-- CookieConsentedJS code that may run -->
136
    [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %]
136
    [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %]
137
        [% consents = JSConsents.all() %]
137
        [% consents = JSConsents.all() %]
138
        [% FOREACH consent IN consents %]
138
        [% FOREACH consent IN consents %]
139
            <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>
139
            <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>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-4 / +4 lines)
Lines 389-399 Patrons: Link Here
389
               no: "Don't require"
389
               no: "Don't require"
390
         - cookie consent to be displayed
390
         - cookie consent to be displayed
391
     -
391
     -
392
         - Specify Javascript that requires user consent to run (e.g. tracking code)
392
         - Add Javascript code that will run if cookie consent is provided (e.g. tracking code).
393
         - pref: ConsentJS
393
         - pref: CookieConsentedJS
394
           type: modaljs
394
           type: modaljs
395
           initiator: populateConsentJS
395
           initiator: populateCookieConsentedJS
396
           processor: prepareConsentJS
396
           processor: prepareCookieConsentedJS
397
     -
397
     -
398
         - Show the following HTML in the cookie consent bar that is displayed at the bottom of the screen
398
         - Show the following HTML in the cookie consent bar that is displayed at the bottom of the screen
399
         - pref: CookieConsentBar
399
         - pref: CookieConsentBar
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (-2 / +2 lines)
Lines 451-457 Link Here
451
            [% Koha.Preference( 'CookieConsentBar' ) | $raw %]
451
            [% Koha.Preference( 'CookieConsentBar' ) | $raw %]
452
            <div id="consentButtons">
452
            <div id="consentButtons">
453
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
453
                <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
454
                [% IF ( Koha.Preference( 'ConsentJS' ).length > 0 ) %]
454
                [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
455
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
455
                    <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
456
                    <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
456
                    <button type="button" class="btn btn-info" id="consentMoreInfo" aria-label="Click to view more information about your cookie consents">More information</button>
457
                [% END %]
457
                [% END %]
Lines 488-494 Link Here
488
                    <div class="modal-footer">
488
                    <div class="modal-footer">
489
                        <div id="consentButtons">
489
                        <div id="consentButtons">
490
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
490
                            <button type="button" class="btn btn-primary consentAcceptAll">Accept all cookies</button>
491
                            [% IF ( Koha.Preference( 'ConsentJS' ).length > 0 ) %]
491
                            [% IF ( Koha.Preference( 'CookieConsentedJS' ).length > 0 ) %]
492
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
492
                                <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
493
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
493
                                <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
494
                            [% END %]
494
                            [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-2 / +2 lines)
Lines 120-127 Link Here
120
    [% END # /IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %]
120
    [% END # /IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %]
121
[% END # / UNLESS is_popup %]
121
[% END # / UNLESS is_popup %]
122
122
123
<!-- ConsentJS code that may run -->
123
<!-- CookieConsentedJS code that may run -->
124
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %]
124
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'CookieConsentedJS' ).length > 0 %]
125
    [% consents = JSConsents.all() %]
125
    [% consents = JSConsents.all() %]
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>
(-)a/t/db_dependent/Koha/Template/Plugin/JSConsents.t (-2 / +1 lines)
Lines 17-23 ok( my $consents = Koha::Template::Plugin::JSConsents->new(), 'Able to instantia Link Here
17
subtest "all" => sub {
17
subtest "all" => sub {
18
    plan tests => 1;
18
    plan tests => 1;
19
19
20
    t::lib::Mocks::mock_preference( 'ConsentJS', 'eyAidGVzdCI6ICJvbmUiIH0=' );
20
    t::lib::Mocks::mock_preference( 'CookieConsentedJS', 'eyAidGVzdCI6ICJvbmUiIH0=' );
21
21
22
    is_deeply( $consents->all(), { test => 'one' }, 'Returns a Base64 decoded JSON object converted into a data structure');
22
    is_deeply( $consents->all(), { test => 'one' }, 'Returns a Base64 decoded JSON object converted into a data structure');
23
};
23
};
24
- 

Return to bug 27378