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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc (+7 lines)
Lines 24-29 Link Here
24
                <li>
24
                <li>
25
            [% END %]
25
            [% END %]
26
                <a href="/cgi-bin/koha/opac-memberentry.pl">your personal details</a></li>
26
                <a href="/cgi-bin/koha/opac-memberentry.pl">your personal details</a></li>
27
28
            [% IF Koha.Preference('GDPR_Policy') # remove when extending %]
29
                [% IF consentview %]<li class="active">[% ELSE %]<li>[% END %]
30
                    <a href="/cgi-bin/koha/opac-patron-consent.pl">your consents</a>
31
                </li>
32
            [% END %]
33
27
            [% IF Koha.Preference( 'TagsEnabled' ) == 1 %]
34
            [% IF Koha.Preference( 'TagsEnabled' ) == 1 %]
28
                [% IF ( tagsview ) %]
35
                [% IF ( tagsview ) %]
29
                    <li class="active">
36
                    <li class="active">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt (+89 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% SET consentview = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your consents</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% BLOCK cssinclude %][% END %]
7
</head>
8
[% INCLUDE 'bodytag.inc' bodyid='opac-patron-consent' %]
9
[% INCLUDE 'masthead.inc' %]
10
11
<div class="main">
12
    <ul class="breadcrumb">
13
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
14
        <li><a href="/cgi-bin/koha/opac-user.pl">[% patron.firstname %] [% patron.surname %]</a> <span class="divider">&rsaquo;</span></li>
15
        <li><a href="#">Your consents</a></li>
16
    </ul>
17
18
    <div class="container-fluid">
19
        <div class="row-fluid">
20
            <div class="span2">
21
                <div id="navigation">
22
                    [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
23
                </div>
24
            </div>
25
            <div class="span10">
26
                <div id="patronconsents">
27
28
                    [% IF Koha.Preference('GDPR_Policy') %]
29
                    <div class="alert">
30
                            <p>In order to keep you logged in, we need your consent to process personal data as specified in the EU General Data Protection Regulation of May 25, 2018.</p>
31
                            <p>Please save your consent below or log out. Thank you!</p>
32
                    </div>
33
                    [% END %]
34
35
                    <h3>Your consents</h3>
36
37
                    <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
38
                        [% IF Koha.Preference('GDPR_Policy') %]
39
                            <h5>GDPR consents</h5>
40
                            <input type="hidden" name="op" value="gdpr_proc_save"/>
41
                            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]"/>
42
                            <fieldset>
43
                                <ul><li>
44
                                    <p>I have read the <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') %]">privacy policy</a> and agree with your processing of my personal data as outlined therein.</p>
45
                                    <p><input type="radio" name="gdpr_processing" value="agreed"> Yes, I agree.<br>
46
                                    <input type="radio" name="gdpr_processing" value="disagreed"> No, I do not agree. Please remove my account within a reasonable time.</p>
47
                                    [% IF gdpr_proc_consent %]
48
                                        <p>Your consent was registered on [% gdpr_proc_consent %].</p>
49
                                    [% END %]
50
                                </li></ul>
51
                            </fieldset>
52
                            <fieldset class="action"><input id="saveconsent" type="submit" value="Save" class="btn" /></fieldset>
53
                        [% END %]
54
55
                    </form>
56
57
                </div> <!-- / #userpasswd -->
58
            </div> <!-- / .span10 -->
59
        </div> <!-- / .row-fluid -->
60
    </div> <!-- / .container-fluid -->
61
</div> <!-- / .main -->
62
63
[% INCLUDE 'opac-bottom.inc' %]
64
[% BLOCK jsinclude %]
65
<script type="text/javascript">
66
    var consent = null;
67
    $(document).ready(function() {
68
        [% IF gdpr_proc_consent %]
69
            consent=1;
70
            $("input[type='radio'][value='agreed']").prop('checked',true);
71
            $(".alert").hide();
72
        [% ELSIF gdpr_proc_refusal %]
73
            consent=0;
74
            $("input[type='radio'][value='disagreed']").prop('checked',true);
75
        [% ELSE %]
76
        [% END %]
77
        $("#saveconsent").prop('disabled', true);
78
79
        $("input[type='radio']").click(function() {
80
            var radio = $(this).val();
81
            if(radio=='agreed' && (consent==null || consent==0)) $("#saveconsent").prop('disabled', false);
82
            if(radio=='disagreed' && (consent==null || consent==1)) $("#saveconsent").prop('disabled', false);
83
            if(radio=='agreed') $(".alert").hide();
84
            if(radio=='disagreed') $(".alert").show();
85
        });
86
87
    });
88
</script>
89
[% END %]
(-)a/opac/opac-patron-consent.pl (-1 / +82 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2018 Rijksmuseum
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI qw/-utf8/;
22
23
use C4::Auth qw/get_template_and_user/;
24
use C4::Output qw/output_html_with_http_headers/;
25
use Koha::DateUtils qw/dt_from_string/;
26
use Koha::Patron::Consents;
27
use Koha::Patrons;
28
29
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
30
31
my $query = new CGI;
32
my $op = $query->param('op') // q{};
33
my $gdpr_check = $query->param('gdpr_processing') // q{};
34
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
36
    template_name   => "opac-patron-consent.tt",
37
    query           => $query,
38
    type            => "opac",
39
    authnotrequired => 0,
40
});
41
42
my $patron = Koha::Patrons->find($borrowernumber);
43
my $gdpr_proc_consent;
44
if( C4::Context->preference('GDPR_Policy') ) {
45
    $gdpr_proc_consent = Koha::Patron::Consents->search({
46
        borrowernumber => $borrowernumber,
47
        type => GDPR_PROCESSING,
48
    })->next;
49
    $gdpr_proc_consent //= Koha::Patron::Consent->new({
50
        borrowernumber => $borrowernumber,
51
        type => GDPR_PROCESSING,
52
    });
53
}
54
55
# Handle saves here
56
if( $op eq 'gdpr_proc_save' && $gdpr_proc_consent ) {
57
    if( $gdpr_check eq 'agreed' ) {
58
        $gdpr_proc_consent->given_on( dt_from_string() );
59
        $gdpr_proc_consent->refused_on( undef );
60
    } elsif( $gdpr_check eq 'disagreed' ) {
61
        $gdpr_proc_consent->given_on( undef );
62
        $gdpr_proc_consent->refused_on( dt_from_string() );
63
    }
64
    $gdpr_proc_consent->store;
65
}
66
67
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
68
if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gdpr_proc_consent->refused_on )
69
{
70
    print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
71
    exit;
72
}
73
74
$template->param( patron => $patron );
75
if( $gdpr_proc_consent ) {
76
    $template->param(
77
        gdpr_proc_consent => $gdpr_proc_consent->given_on // q{},
78
        gdpr_proc_refusal => $gdpr_proc_consent->refused_on // q{},
79
    );
80
}
81
82
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };

Return to bug 20819