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 156-162 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
156
('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
156
('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
157
('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'),
157
('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'),
158
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
158
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
159
('ConsentJS', '', NULL, 'Specify Javascript that requires user consent to run (e.g. tracking code)', 'Free'),
159
('CookieConsentedJS', '', NULL, 'Add Javascript code that will run if cookie consent is provided (e.g. tracking code).', 'Free'),
160
('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo'),
160
('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo'),
161
('ContentWarningField', '', NULL, 'MARC field to use for content warnings', 'Free'),
161
('ContentWarningField', '', NULL, 'MARC field to use for content warnings', 'Free'),
162
('CookieConsent', '0', NULL, 'Require cookie consent to be displayed', 'YesNo'),
162
('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 4306-4319 div .suggestion_note { Link Here
4306
    }
4306
    }
4307
}
4307
}
4308
4308
4309
#consentJSItems {
4309
#cookieConsentedJSItems {
4310
    #consentJSWarning {
4310
    #cookieConsentedJSWarning {
4311
        margin: 20px 0;
4311
        margin: 20px 0;
4312
        text-align: center;
4312
        text-align: center;
4313
        font-weight: 800;
4313
        font-weight: 800;
4314
        font-size: 120%;
4314
        font-size: 120%;
4315
    }
4315
    }
4316
    .consentJSItem {
4316
    .cookieConsentedJSItem {
4317
        margin-bottom: 30px;
4317
        margin-bottom: 30px;
4318
        padding: 10px;
4318
        padding: 10px;
4319
        border: 1px solid #ccc;
4319
        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 395-405 Patrons: Link Here
395
               no: "Don't require"
395
               no: "Don't require"
396
         - cookie consent to be displayed
396
         - cookie consent to be displayed
397
     -
397
     -
398
         - Specify Javascript that requires user consent to run (e.g. tracking code)
398
         - Add Javascript code that will run if cookie consent is provided (e.g. tracking code).
399
         - pref: ConsentJS
399
         - pref: CookieConsentedJS
400
           type: modaljs
400
           type: modaljs
401
           initiator: populateConsentJS
401
           initiator: populateCookieConsentedJS
402
           processor: prepareConsentJS
402
           processor: prepareCookieConsentedJS
403
     -
403
     -
404
         - Show the following HTML in the cookie consent bar that is displayed at the bottom of the screen
404
         - Show the following HTML in the cookie consent bar that is displayed at the bottom of the screen
405
         - pref: CookieConsentBar
405
         - 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