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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt (-38 / +34 lines)
Lines 35-64 Link Here
35
            </div>
35
            </div>
36
            <div class="col-lg-10 order-first order-md-first order-lg-2">
36
            <div class="col-lg-10 order-first order-md-first order-lg-2">
37
                <div id="patronconsents" class="maincontent">
37
                <div id="patronconsents" class="maincontent">
38
39
                    [% IF Koha.Preference('GDPR_Policy') %]
40
                    <div class="alert alert-warning">
41
                            <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>
42
                            <p>Please save your consent below or log out. Thank you!</p>
43
                    </div>
44
                    [% END %]
45
46
                    <h1>Your consents</h1>
38
                    <h1>Your consents</h1>
47
39
48
                    <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
40
                    <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
49
                        [% IF Koha.Preference('GDPR_Policy') %]
41
                        <input type="hidden" name="op" value="save"/>
50
                        <legend><h2 id="GDPR_consents">GDPR consents</h2></legend>
42
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"/>
51
                            <input type="hidden" name="op" value="save"/>
43
                        [% FOREACH consent IN consents %]
52
                            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"/>
44
                            <legend><h2>Consent for [% consent.type | html %]</h2></legend>
53
                            <fieldset>
45
                            <fieldset>
54
                                <ul><li>
46
                                <ul><li>
55
                                    <p>I have read the <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') | url %]">privacy policy</a> and agree with your processing of my personal data as outlined therein.</p>
47
                                    [% IF consent.type == 'GDPR_PROCESSING' %]
56
                                    <p><input type="radio" name="gdpr_processing" value="1"> Yes, I agree.<br>
48
                                        <p>Please read the <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') | url %]">privacy policy</a>.</p>
57
                                    <input type="radio" name="gdpr_processing" value="0"> No, I do not agree. Please remove my account within a reasonable time.</p>
49
                                        <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. If you would not agree, we will need to <strong>remove</strong> your account within a reasonable time.</p>
58
                                    [% IF gdpr_proc_consent.given_on %]
50
                                        <p>Do you agree with our processing of your personal data as outlined in the policy?</p>
59
                                        <p class="consent_info">Your consent was registered on [% gdpr_proc_consent.given_on | html %].</p>
51
                                    [% ELSE %]
60
                                    [% ELSIF gdpr_proc_consent.refused_on %]
52
                                        <p>Description for [% consent.type | html #TODO %]. Do you agree?</p>
61
                                        <p class="consent_info">You indicated recently that you do not consent, and we will process your request soon.</p>
53
                                    [% END %]
54
                                    <p>
55
                                        <input type="radio" name="check_[% consent.type | html %]" value="1"> Yes<br>
56
                                        <input type="radio" name="check_[% consent.type | html %]" value="0"> No
57
                                    </p>
58
                                    [% IF consent.given_on %]
59
                                        <p class="consent_info">Your consent was registered on [% consent.given_on | html %].</p>
60
                                    [% ELSIF consent.refused_on %]
61
                                        <p class="dissent_info">We registered that you did not consent on [% consent.refused_on | html %].</p>
62
                                    [% END %]
62
                                    [% END %]
63
                                </li></ul>
63
                                </li></ul>
64
                            </fieldset>
64
                            </fieldset>
Lines 78-110 Link Here
78
[% INCLUDE 'opac-bottom.inc' %]
78
[% INCLUDE 'opac-bottom.inc' %]
79
[% BLOCK jsinclude %]
79
[% BLOCK jsinclude %]
80
    <script>
80
    <script>
81
        var consent = null;
82
        $(document).ready(function() {
81
        $(document).ready(function() {
83
            [% IF Koha.Preference('GDPR_Policy') %]
82
            [% FOREACH consent IN consents %]
84
                [% IF gdpr_proc_consent.given_on %]
83
                [% IF consent.given_on %]
85
                    consent=1;
84
                    $("input[type='radio'][name='check_[% consent.type | html %]'][value='1']").prop('checked',true);
86
                    $("input[type='radio'][value='1']").prop('checked',true);
85
                [% ELSIF consent.refused_on %]
87
                    $(".alert").hide();
86
                    $("input[type='radio'][name='check_[% consent.type | html %]'][value='0']").prop('checked',true);
88
                [% ELSIF gdpr_proc_consent.refused_on %]
89
                    consent=0;
90
                    $("input[type='radio'][value='0']").prop('checked',true);
91
                [% ELSE %]
92
                [% END %]
87
                [% END %]
88
93
            [% END %]
89
            [% END %]
94
            // Initially no choice is made or no change, so disable button
90
            // Initially no choice is made or no change, so disable button
95
            $("#saveconsent").prop('disabled', true);
91
            $("#saveconsent").prop('disabled', true);
96
92
97
            $("input[type='radio']").click(function() {
93
            $("input[type='radio']").click(function() {
98
                var radio = $(this).val();
94
                $("#saveconsent").prop('disabled', false);
99
                if( radio=='1' && (consent==null || consent==0) ) {
95
                var v = $(this).val();
100
                    $("#saveconsent").prop('disabled', false);
96
                // If former registration info present, toggle
101
                    $(".consent_info").hide();
97
                if( v == 1 ) {
102
                } else if( radio=='0' && (consent==null || consent==1) ) {
98
                    $(this).parent().siblings('.consent_info').show();
103
                    $("#saveconsent").prop('disabled', false);
99
                    $(this).parent().siblings('.dissent_info').hide();
104
                    $(".consent_info").hide();
100
                } else {
101
                    $(this).parent().siblings('.consent_info').hide();
102
                    $(this).parent().siblings('.dissent_info').show();
105
                }
103
                }
106
                if( radio=='1' ) $(".alert").hide();
107
                if( radio=='0' ) $(".alert").show();
108
            });
104
            });
109
105
110
        });
106
        });
(-)a/opac/opac-patron-consent.pl (-12 / +23 lines)
Lines 22-35 use CGI qw/-utf8/; Link Here
22
22
23
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user );
24
use C4::Output qw( output_html_with_http_headers );
24
use C4::Output qw( output_html_with_http_headers );
25
use Koha::AuthorisedValueCategories;
25
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Patrons;
27
use Koha::Patrons;
27
28
28
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
29
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
30
use constant AV_CONSENT => 'PATRON_CONSENT';
29
31
30
my $query = CGI->new;
32
my $query = CGI->new;
31
my $op = $query->param('op') // q{};
33
my $op = $query->param('op') // q{};
32
my $gdpr_check = $query->param('gdpr_processing') // q{};
34
my $vars = $query->Vars;
33
35
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
35
    template_name   => "opac-patron-consent.tt",
37
    template_name   => "opac-patron-consent.tt",
Lines 37-65 my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ Link Here
37
    type            => "opac",
39
    type            => "opac",
38
});
40
});
39
41
42
my $needs_redirect = 0;
40
my $patron = Koha::Patrons->find($borrowernumber);
43
my $patron = Koha::Patrons->find($borrowernumber);
41
my $gdpr_proc_consent;
44
my $types = ( $_ = Koha::AuthorisedValueCategories->find(AV_CONSENT) )
42
if( C4::Context->preference('GDPR_Policy') ) {
45
    ? [ $_->values ]
43
    $gdpr_proc_consent = $patron->consent(GDPR_PROCESSING);
46
    : [ GDPR_PROCESSING ];
47
my $consents;
48
49
# Get consent values
50
foreach my $t ( @$types ) {
51
    push @$consents, $patron->consent($t);
44
}
52
}
45
53
46
# Handle saves here
54
# Handle saves here
47
if( $op eq 'save' ) {
55
if( $op eq 'save' ) {
48
    if( $gdpr_proc_consent ) {
56
    foreach my $consent ( @$consents ) {
49
        $gdpr_proc_consent->set({
57
        my $check = $vars->{ "check_".$consent->type };
50
            given_on => $gdpr_check ? dt_from_string() : undef,
58
        next if !defined($check); # no choice made
51
            refused_on => $gdpr_check ? undef : dt_from_string(),
59
        $needs_redirect = 1 if $consent->type eq GDPR_PROCESSING && !$check;
60
        next if $consent->given_on && $check || $consent->refused_on && !$check;
61
            # No update if no consent change
62
        $consent->set({
63
            given_on => $check ? dt_from_string() : undef,
64
            refused_on => $check ? undef : dt_from_string(),
52
        })->store;
65
        })->store;
53
    }
66
    }
54
}
67
}
55
68
56
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
69
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
57
if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gdpr_proc_consent->refused_on )
70
if( C4::Context->preference('GDPR_Policy') eq 'Enforced' && $needs_redirect ) {
58
{
59
    print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
71
    print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
60
    exit;
72
    exit;
61
}
73
}
62
74
63
$template->param( patron => $patron, gdpr_proc_consent => $gdpr_proc_consent );
75
$template->param( patron => $patron, consents => $consents );
64
76
65
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
77
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
66
- 

Return to bug 31503