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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt (-22 / +30 lines)
Lines 48-72 Link Here
48
                    <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
48
                    <form action="/cgi-bin/koha/opac-patron-consent.pl" method="post">
49
                        [% IF Koha.Preference('GDPR_Policy') %]
49
                        [% IF Koha.Preference('GDPR_Policy') %]
50
                        <legend><h2 id="GDPR_consents">GDPR consents</h2></legend>
50
                        <legend><h2 id="GDPR_consents">GDPR consents</h2></legend>
51
                            <input type="hidden" name="op" value="gdpr_proc_save"/>
51
                            <input type="hidden" name="op" value="save"/>
52
                            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"/>
52
                            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]"/>
53
                            <fieldset>
53
                            <fieldset>
54
                                <ul><li>
54
                                <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>
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>
56
                                    <p><input type="radio" name="gdpr_processing" value="agreed"> Yes, I agree.<br>
56
                                    <p><input type="radio" name="gdpr_processing" value="1"> Yes, I agree.<br>
57
                                    <input type="radio" name="gdpr_processing" value="disagreed"> No, I do not agree. Please remove my account within a reasonable time.</p>
57
                                    <input type="radio" name="gdpr_processing" value="0"> No, I do not agree. Please remove my account within a reasonable time.</p>
58
                                    [% IF gdpr_proc_consent %]
58
                                    [% IF gdpr_proc_consent.given_on %]
59
                                        <p>Your consent was registered on [% gdpr_proc_consent | html %].</p>
59
                                        <p class="consent_info">Your consent was registered on [% gdpr_proc_consent.given_on | html %].</p>
60
                                    [% ELSIF gdpr_proc_refusal %]
60
                                    [% ELSIF gdpr_proc_consent.refused_on %]
61
                                        <p>You indicated recently that you do not consent, and we will process your request soon.</p>
61
                                        <p class="consent_info">You indicated recently that you do not consent, and we will process your request soon.</p>
62
                                    [% END %]
62
                                    [% END %]
63
                                </li></ul>
63
                                </li></ul>
64
                            </fieldset>
64
                            </fieldset>
65
                            <fieldset class="action">
66
                                <input id="saveconsent" type="submit" value="Save" class="btn btn-primary" />
67
                            </fieldset>
68
                        [% END %]
65
                        [% END %]
69
66
67
                        <fieldset class="action">
68
                            <input id="saveconsent" type="submit" value="Save" class="btn btn-primary" />
69
                        </fieldset>
70
                    </form>
70
                    </form>
71
71
72
                </div> <!-- / #userpasswd -->
72
                </div> <!-- / #userpasswd -->
Lines 80-102 Link Here
80
    <script>
80
    <script>
81
        var consent = null;
81
        var consent = null;
82
        $(document).ready(function() {
82
        $(document).ready(function() {
83
            [% IF gdpr_proc_consent %]
83
            [% IF Koha.Preference('GDPR_Policy') %]
84
                consent=1;
84
                [% IF gdpr_proc_consent.given_on %]
85
                $("input[type='radio'][value='agreed']").prop('checked',true);
85
                    consent=1;
86
                $(".alert").hide();
86
                    $("input[type='radio'][value='1']").prop('checked',true);
87
            [% ELSIF gdpr_proc_refusal %]
87
                    $(".alert").hide();
88
                consent=0;
88
                [% ELSIF gdpr_proc_consent.refused_on %]
89
                $("input[type='radio'][value='disagreed']").prop('checked',true);
89
                    consent=0;
90
            [% ELSE %]
90
                    $("input[type='radio'][value='0']").prop('checked',true);
91
                [% ELSE %]
92
                [% END %]
91
            [% END %]
93
            [% END %]
94
            // Initially no choice is made or no change, so disable button
92
            $("#saveconsent").prop('disabled', true);
95
            $("#saveconsent").prop('disabled', true);
93
96
94
            $("input[type='radio']").click(function() {
97
            $("input[type='radio']").click(function() {
95
                var radio = $(this).val();
98
                var radio = $(this).val();
96
                if(radio=='agreed' && (consent==null || consent==0)) $("#saveconsent").prop('disabled', false);
99
                if( radio=='1' && (consent==null || consent==0) ) {
97
                if(radio=='disagreed' && (consent==null || consent==1)) $("#saveconsent").prop('disabled', false);
100
                    $("#saveconsent").prop('disabled', false);
98
                if(radio=='agreed') $(".alert").hide();
101
                    $(".consent_info").hide();
99
                if(radio=='disagreed') $(".alert").show();
102
                } else if( radio=='0' && (consent==null || consent==1) ) {
103
                    $("#saveconsent").prop('disabled', false);
104
                    $(".consent_info").hide();
105
                }
106
                if( radio=='1' ) $(".alert").hide();
107
                if( radio=='0' ) $(".alert").show();
100
            });
108
            });
101
109
102
        });
110
        });
(-)a/opac/opac-patron-consent.pl (-25 / +8 lines)
Lines 23-29 use CGI qw/-utf8/; Link Here
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::DateUtils qw( dt_from_string );
25
use Koha::DateUtils qw( dt_from_string );
26
use Koha::Patron::Consents;
27
use Koha::Patrons;
26
use Koha::Patrons;
28
27
29
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
28
use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
Lines 41-66 my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ Link Here
41
my $patron = Koha::Patrons->find($borrowernumber);
40
my $patron = Koha::Patrons->find($borrowernumber);
42
my $gdpr_proc_consent;
41
my $gdpr_proc_consent;
43
if( C4::Context->preference('GDPR_Policy') ) {
42
if( C4::Context->preference('GDPR_Policy') ) {
44
    $gdpr_proc_consent = Koha::Patron::Consents->search({
43
    $gdpr_proc_consent = $patron->consent(GDPR_PROCESSING);
45
        borrowernumber => $borrowernumber,
46
        type => GDPR_PROCESSING,
47
    })->next;
48
    $gdpr_proc_consent //= Koha::Patron::Consent->new({
49
        borrowernumber => $borrowernumber,
50
        type => GDPR_PROCESSING,
51
    });
52
}
44
}
53
45
54
# Handle saves here
46
# Handle saves here
55
if( $op eq 'gdpr_proc_save' && $gdpr_proc_consent ) {
47
if( $op eq 'save' ) {
56
    if( $gdpr_check eq 'agreed' ) {
48
    if( $gdpr_proc_consent ) {
57
        $gdpr_proc_consent->given_on( dt_from_string() );
49
        $gdpr_proc_consent->set({
58
        $gdpr_proc_consent->refused_on( undef );
50
            given_on => $gdpr_check ? dt_from_string() : undef,
59
    } elsif( $gdpr_check eq 'disagreed' ) {
51
            refused_on => $gdpr_check ? undef : dt_from_string(),
60
        $gdpr_proc_consent->given_on( undef );
52
        })->store;
61
        $gdpr_proc_consent->refused_on( dt_from_string() );
62
    }
53
    }
63
    $gdpr_proc_consent->store;
64
}
54
}
65
55
66
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
56
# If user refused GDPR consent and we enforce GDPR, logout (when saving)
Lines 70-81 if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gd Link Here
70
    exit;
60
    exit;
71
}
61
}
72
62
73
$template->param( patron => $patron );
63
$template->param( patron => $patron, gdpr_proc_consent => $gdpr_proc_consent );
74
if( $gdpr_proc_consent ) {
75
    $template->param(
76
        gdpr_proc_consent => $gdpr_proc_consent->given_on // q{},
77
        gdpr_proc_refusal => $gdpr_proc_consent->refused_on // q{},
78
    );
79
}
80
64
81
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
65
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
82
- 

Return to bug 31503