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 364-369 $( document ).ready( function () { Link Here
364
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
364
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
365
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
365
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
366
               '        </div >' +
366
               '        </div >' +
367
               '        <div class="consentItem">' +
368
               '            <label for="cookieDomain' + id + '">' + __('Cookie domain') + ':</label>' +
369
               '            <input id="cookieDomain' + id + '" class="metaCookieDomain" type="text" value="' + item.cookieDomain + '"><span class="required">' + __('Required') + '</span>' +
370
               '        </div >' +
371
               '        <div class="consentItem">' +
372
               '            <label for="cookiePath' + id + '">' + __('Cookie path') + ':</label>' +
373
               '            <input id="cookiePath' + id + '" class="metaCookiePath" type="text" value="' + item.cookiePath + '"><span class="required">' + __('Required') + '</span>' +
374
               '        </div >' +
367
               '    </div >' +
375
               '    </div >' +
368
               '    <div class="consentRow codeRow">' +
376
               '    <div class="consentRow codeRow">' +
369
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
377
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
Lines 394-399 $( document ).ready( function () { Link Here
394
            name: '',
402
            name: '',
395
            description: '',
403
            description: '',
396
            matchPattern: '',
404
            matchPattern: '',
405
            cookieDomain: '',
406
            cookiePath: '',
397
            code: '',
407
            code: '',
398
            consentInOpac: false,
408
            consentInOpac: false,
399
            consentInStaff: false
409
            consentInStaff: false
Lines 472-477 $( document ).ready( function () { Link Here
472
            const name = $(this).find('.metaName').val();
482
            const name = $(this).find('.metaName').val();
473
            const desc = $(this).find('.metaDescription').val();
483
            const desc = $(this).find('.metaDescription').val();
474
            const matchPattern = $(this).find('.metaMatchPattern').val();
484
            const matchPattern = $(this).find('.metaMatchPattern').val();
485
            const cookieDomain = $(this).find('.metaCookieDomain').val();
486
            const cookiePath = $(this).find('.metaCookiePath').val();
475
            const opacConsent = $(this).find('.opacConsent').is(':checked')
487
            const opacConsent = $(this).find('.opacConsent').is(':checked')
476
            const staffConsent = $(this).find('.staffConsent').is(':checked');
488
            const staffConsent = $(this).find('.staffConsent').is(':checked');
477
            const code = $(this).find('.preference-code').val();
489
            const code = $(this).find('.preference-code').val();
Lines 481-486 $( document ).ready( function () { Link Here
481
                name.length === 0 &&
493
                name.length === 0 &&
482
                desc.length === 0 &&
494
                desc.length === 0 &&
483
                matchPattern.length === 0 &&
495
                matchPattern.length === 0 &&
496
                cookieDomain.length === 0 &&
497
                cookiePath.length === 0 &&
484
                code.length === 0
498
                code.length === 0
485
            ) {
499
            ) {
486
                return;
500
                return;
Lines 490-495 $( document ).ready( function () { Link Here
490
                (name.length === 0) ||
504
                (name.length === 0) ||
491
                (desc.length === 0) ||
505
                (desc.length === 0) ||
492
                (matchPattern.length === 0) ||
506
                (matchPattern.length === 0) ||
507
                (cookiePath.length === 0) ||
493
                (code.length === 0)
508
                (code.length === 0)
494
            ) {
509
            ) {
495
                invalid.push(this);
510
                invalid.push(this);
Lines 499-504 $( document ).ready( function () { Link Here
499
                    name: name,
514
                    name: name,
500
                    description: desc,
515
                    description: desc,
501
                    matchPattern: matchPattern,
516
                    matchPattern: matchPattern,
517
                    cookieDomain: cookieDomain,
518
                    cookiePath: cookiePath,
502
                    opacConsent: opacConsent,
519
                    opacConsent: opacConsent,
503
                    staffConsent: staffConsent,
520
                    staffConsent: staffConsent,
504
                    code: btoa(code)
521
                    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