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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc (-1 / +1 lines)
Lines 136-142 Link Here
136
    [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %]
136
    [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).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-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>
140
        [% END %]
140
        [% END %]
141
    [% END %]
141
    [% END %]
142
    [% IF Koha.Preference( 'CookieConsent' ) %]
142
    [% IF Koha.Preference( 'CookieConsent' ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js (-1 / +3 lines)
Lines 106-118 Link Here
106
                // This code doesn't have consent to run, we may need to remove
106
                // This code doesn't have consent to run, we may need to remove
107
                // any cookies it has previously set
107
                // any cookies it has previously set
108
                const matchPattern = $(this).data('consent-match-pattern');
108
                const matchPattern = $(this).data('consent-match-pattern');
109
                const cookieDomain = $(this).data('consent-cookie-domain');
110
                const cookiePath = $(this).data('consent-cookie-path');
109
                if (matchPattern.length > 0) {
111
                if (matchPattern.length > 0) {
110
                    const regex = new RegExp(matchPattern);
112
                    const regex = new RegExp(matchPattern);
111
                    const allCookies = document.cookie.split('; ');
113
                    const allCookies = document.cookie.split('; ');
112
                    allCookies.forEach(function (cookie) {
114
                    allCookies.forEach(function (cookie) {
113
                        const name = cookie.split('=')[0];
115
                        const name = cookie.split('=')[0];
114
                        if (regex.test(name)) {
116
                        if (regex.test(name)) {
115
                            document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT';
117
                            document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT; domain=' + cookieDomain + '; path=' + cookiePath;
116
                        }
118
                        }
117
                    });
119
                    });
118
120
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js (+17 lines)
Lines 362-367 $( document ).ready( function () { Link Here
362
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
362
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
363
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
363
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
364
               '        </div >' +
364
               '        </div >' +
365
               '        <div class="consentItem">' +
366
               '            <label for="cookieDomain' + id + '">' + __('Cookie domain') + ':</label>' +
367
               '            <input id="cookieDomain' + id + '" class="metaCookieDomain" type="text" value="' + item.cookieDomain + '"><span class="required">' + __('Required') + '</span>' +
368
               '        </div >' +
369
               '        <div class="consentItem">' +
370
               '            <label for="cookiePath' + id + '">' + __('Cookie path') + ':</label>' +
371
               '            <input id="cookiePath' + id + '" class="metaCookiePath" type="text" value="' + item.cookiePath + '"><span class="required">' + __('Required') + '</span>' +
372
               '        </div >' +
365
               '    </div >' +
373
               '    </div >' +
366
               '    <div class="consentRow codeRow">' +
374
               '    <div class="consentRow codeRow">' +
367
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
375
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
Lines 392-397 $( document ).ready( function () { Link Here
392
            name: '',
400
            name: '',
393
            description: '',
401
            description: '',
394
            matchPattern: '',
402
            matchPattern: '',
403
            cookieDomain: '',
404
            cookiePath: '',
395
            code: '',
405
            code: '',
396
            consentInOpac: false,
406
            consentInOpac: false,
397
            consentInStaff: false
407
            consentInStaff: false
Lines 470-475 $( document ).ready( function () { Link Here
470
            const name = $(this).find('.metaName').val();
480
            const name = $(this).find('.metaName').val();
471
            const desc = $(this).find('.metaDescription').val();
481
            const desc = $(this).find('.metaDescription').val();
472
            const matchPattern = $(this).find('.metaMatchPattern').val();
482
            const matchPattern = $(this).find('.metaMatchPattern').val();
483
            const cookieDomain = $(this).find('.metaCookieDomain').val();
484
            const cookiePath = $(this).find('.metaCookiePath').val();
473
            const opacConsent = $(this).find('.opacConsent').is(':checked')
485
            const opacConsent = $(this).find('.opacConsent').is(':checked')
474
            const staffConsent = $(this).find('.staffConsent').is(':checked');
486
            const staffConsent = $(this).find('.staffConsent').is(':checked');
475
            const code = $(this).find('.preference-code').val();
487
            const code = $(this).find('.preference-code').val();
Lines 479-484 $( document ).ready( function () { Link Here
479
                name.length === 0 &&
491
                name.length === 0 &&
480
                desc.length === 0 &&
492
                desc.length === 0 &&
481
                matchPattern.length === 0 &&
493
                matchPattern.length === 0 &&
494
                cookieDomain.length === 0 &&
495
                cookiePath.length === 0 &&
482
                code.length === 0
496
                code.length === 0
483
            ) {
497
            ) {
484
                return;
498
                return;
Lines 488-493 $( document ).ready( function () { Link Here
488
                (name.length === 0) ||
502
                (name.length === 0) ||
489
                (desc.length === 0) ||
503
                (desc.length === 0) ||
490
                (matchPattern.length === 0) ||
504
                (matchPattern.length === 0) ||
505
                (cookiePath.length === 0) ||
491
                (code.length === 0)
506
                (code.length === 0)
492
            ) {
507
            ) {
493
                invalid.push(this);
508
                invalid.push(this);
Lines 497-502 $( document ).ready( function () { Link Here
497
                    name: name,
512
                    name: name,
498
                    description: desc,
513
                    description: desc,
499
                    matchPattern: matchPattern,
514
                    matchPattern: matchPattern,
515
                    cookieDomain: cookieDomain,
516
                    cookiePath: cookiePath,
500
                    opacConsent: opacConsent,
517
                    opacConsent: opacConsent,
501
                    staffConsent: staffConsent,
518
                    staffConsent: staffConsent,
502
                    code: btoa(code)
519
                    code: btoa(code)
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-1 / +1 lines)
Lines 124-130 Link Here
124
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %]
124
[% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).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-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
[% END %]
129
[% END %]
130
130
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js (-2 / +3 lines)
Lines 120-132 Link Here
120
                // This code doesn't have consent to run, we may need to remove
120
                // This code doesn't have consent to run, we may need to remove
121
                // any cookies it has previously set
121
                // any cookies it has previously set
122
                const matchPattern = $(this).data('consent-match-pattern');
122
                const matchPattern = $(this).data('consent-match-pattern');
123
                const cookieDomain = $(this).data('consent-cookie-domain');
124
                const cookiePath = $(this).data('consent-cookie-path');
123
                if (matchPattern.length > 0) {
125
                if (matchPattern.length > 0) {
124
                    const regex = new RegExp(matchPattern);
126
                    const regex = new RegExp(matchPattern);
125
                    const allCookies = document.cookie.split('; ');
127
                    const allCookies = document.cookie.split('; ');
126
                    allCookies.forEach(function (cookie) {
128
                    allCookies.forEach(function (cookie) {
127
                        const name = cookie.split('=')[0];
129
                        const name = cookie.split('=')[0];
128
                        if (regex.test(name)) {
130
                        if (regex.test(name)) {
129
                            document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT';
131
                            document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=' + cookieDomain +'; path=' + cookiePath;
130
                        }
132
                        }
131
                    });
133
                    });
132
                }
134
                }
133
- 

Return to bug 27378