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 356-361 $( document ).ready( function () { Link Here
356
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
356
               '            <label for="matchPattern_' + id + '">' + __('String used to identify cookie name') + ':</label>' +
357
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
357
               '            <input id="matchPattern_' + id + '" class="metaMatchPattern" type="text" value="' + item.matchPattern + '"><span class="required">' + __('Required') + '</span>' +
358
               '        </div >' +
358
               '        </div >' +
359
               '        <div class="consentItem">' +
360
               '            <label for="cookieDomain' + id + '">' + __('Cookie domain') + ':</label>' +
361
               '            <input id="cookieDomain' + id + '" class="metaCookieDomain" type="text" value="' + item.cookieDomain + '"><span class="required">' + __('Required') + '</span>' +
362
               '        </div >' +
363
               '        <div class="consentItem">' +
364
               '            <label for="cookiePath' + id + '">' + __('Cookie path') + ':</label>' +
365
               '            <input id="cookiePath' + id + '" class="metaCookiePath" type="text" value="' + item.cookiePath + '"><span class="required">' + __('Required') + '</span>' +
366
               '        </div >' +
359
               '    </div >' +
367
               '    </div >' +
360
               '    <div class="consentRow codeRow">' +
368
               '    <div class="consentRow codeRow">' +
361
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
369
               '        <textarea style="display:none;" id="pref_' + id + '" class="preference preference-code codemirror" rows="10" cols="40">' + code + '</textarea>' +
Lines 386-391 $( document ).ready( function () { Link Here
386
            name: '',
394
            name: '',
387
            description: '',
395
            description: '',
388
            matchPattern: '',
396
            matchPattern: '',
397
            cookieDomain: '',
398
            cookiePath: '',
389
            code: '',
399
            code: '',
390
            consentInOpac: false,
400
            consentInOpac: false,
391
            consentInStaff: false
401
            consentInStaff: false
Lines 464-469 $( document ).ready( function () { Link Here
464
            const name = $(this).find('.metaName').val();
474
            const name = $(this).find('.metaName').val();
465
            const desc = $(this).find('.metaDescription').val();
475
            const desc = $(this).find('.metaDescription').val();
466
            const matchPattern = $(this).find('.metaMatchPattern').val();
476
            const matchPattern = $(this).find('.metaMatchPattern').val();
477
            const cookieDomain = $(this).find('.metaCookieDomain').val();
478
            const cookiePath = $(this).find('.metaCookiePath').val();
467
            const opacConsent = $(this).find('.opacConsent').is(':checked')
479
            const opacConsent = $(this).find('.opacConsent').is(':checked')
468
            const staffConsent = $(this).find('.staffConsent').is(':checked');
480
            const staffConsent = $(this).find('.staffConsent').is(':checked');
469
            const code = $(this).find('.preference-code').val();
481
            const code = $(this).find('.preference-code').val();
Lines 473-478 $( document ).ready( function () { Link Here
473
                name.length === 0 &&
485
                name.length === 0 &&
474
                desc.length === 0 &&
486
                desc.length === 0 &&
475
                matchPattern.length === 0 &&
487
                matchPattern.length === 0 &&
488
                cookieDomain.length === 0 &&
489
                cookiePath.length === 0 &&
476
                code.length === 0
490
                code.length === 0
477
            ) {
491
            ) {
478
                return;
492
                return;
Lines 482-487 $( document ).ready( function () { Link Here
482
                (name.length === 0) ||
496
                (name.length === 0) ||
483
                (desc.length === 0) ||
497
                (desc.length === 0) ||
484
                (matchPattern.length === 0) ||
498
                (matchPattern.length === 0) ||
499
                (cookiePath.length === 0) ||
485
                (code.length === 0)
500
                (code.length === 0)
486
            ) {
501
            ) {
487
                invalid.push(this);
502
                invalid.push(this);
Lines 491-496 $( document ).ready( function () { Link Here
491
                    name: name,
506
                    name: name,
492
                    description: desc,
507
                    description: desc,
493
                    matchPattern: matchPattern,
508
                    matchPattern: matchPattern,
509
                    cookieDomain: cookieDomain,
510
                    cookiePath: cookiePath,
494
                    opacConsent: opacConsent,
511
                    opacConsent: opacConsent,
495
                    staffConsent: staffConsent,
512
                    staffConsent: staffConsent,
496
                    code: btoa(code)
513
                    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