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 / +27 lines)
Lines 19-35 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use CGI qw/-utf8/;
21
use CGI qw/-utf8/;
22
use List::Util qw/none/;
22
23
23
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
24
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
use Koha::AuthorisedValueCategories;
25
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Patrons;
28
use Koha::Patrons;
27
29
28
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
30
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
31
use constant AV_CONSENT => 'PATRON_CONSENT';
29
32
30
my $query = CGI->new;
33
my $query = CGI->new;
31
my $op = $query->param('op') // q{};
34
my $op = $query->param('op') // q{};
32
my $gdpr_check = $query->param('gdpr_processing') // q{};
35
my $vars = $query->Vars;
33
36
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
37
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
35
    template_name   => "opac-patron-consent.tt",
38
    template_name   => "opac-patron-consent.tt",
Lines 37-65 my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ Link Here
37
    type            => "opac",
40
    type            => "opac",
38
});
41
});
39
42
43
my $needs_redirect = 0;
40
my $patron = Koha::Patrons->find($borrowernumber);
44
my $patron = Koha::Patrons->find($borrowernumber);
41
my $gdpr_proc_consent;
45
42
if( C4::Context->preference('GDPR_Policy') ) {
46
# Get consent types, but always add GDPR when enforced/permissive
43
    $gdpr_proc_consent = $patron->consent(GDPR_PROCESSING);
47
my ( $consents, $types );
48
$types = ( $_ = Koha::AuthorisedValueCategories->find(AV_CONSENT) ) ? [ $_->values ] : [];
49
if( C4::Context->preference('GDPR_Policy') ) { # Enforced|Permissive
50
    push @$types, GDPR_PROCESSING if none { $_ eq GDPR_PROCESSING } @$types;
51
}
52
53
# Get consent values
54
foreach my $t ( @$types ) {
55
    push @$consents, $patron->consent($t);
44
}
56
}
45
57
46
# Handle saves here
58
# Handle saves here
47
if( $op eq 'save' ) {
59
if( $op eq 'save' ) {
48
    if( $gdpr_proc_consent ) {
60
    foreach my $consent ( @$consents ) {
49
        $gdpr_proc_consent->set({
61
        my $check = $vars->{ "check_".$consent->type };
50
            given_on => $gdpr_check ? dt_from_string() : undef,
62
        next if !defined($check); # no choice made
51
            refused_on => $gdpr_check ? undef : dt_from_string(),
63
        $needs_redirect = 1 if $consent->type eq GDPR_PROCESSING && !$check && C4::Context->preference('GDPR_Policy') eq 'Enforced';
64
        next if $consent->given_on && $check || $consent->refused_on && !$check;
65
            # No update if no consent change
66
        $consent->set({
67
            given_on => $check ? dt_from_string() : undef,
68
            refused_on => $check ? undef : dt_from_string(),
52
        })->store;
69
        })->store;
53
    }
70
    }
54
}
71
}
55
72
56
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
73
# 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 )
74
if( $needs_redirect ) {
58
{
59
    print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
75
    print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
60
    exit;
76
    exit;
61
}
77
}
62
78
63
$template->param( patron => $patron, gdpr_proc_consent => $gdpr_proc_consent );
79
$template->param( patron => $patron, consents => $consents );
64
80
65
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
81
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
66
- 

Return to bug 31503