@@ -, +, @@
you are not logged out when saving a refusal.
Log in again and verify that the consents tab shows a No.
Note: a follow-up patch will add further enforcements.
---
.../opac-tmpl/bootstrap/en/includes/usermenu.inc | 7 ++
.../bootstrap/en/modules/opac-patron-consent.tt | 89 ++++++++++++++++++++++
opac/opac-patron-consent.pl | 82 ++++++++++++++++++++
3 files changed, 178 insertions(+)
create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt
create mode 100755 opac/opac-patron-consent.pl
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc
@@ -24,6 +24,13 @@
[% END %]
your personal details
+
+ [% IF Koha.Preference('GDPR_Policy') # remove when extending %]
+ [% IF consentview %][% ELSE %][% END %]
+ your consents
+
+ [% END %]
+
[% IF Koha.Preference( 'TagsEnabled' ) == 1 %]
[% IF ( tagsview ) %]
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-patron-consent.tt
@@ -0,0 +1,89 @@
+[% USE Koha %]
+[% SET consentview = 1 %]
+[% INCLUDE 'doc-head-open.inc' %]
+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your consents
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %][% END %]
+
+[% INCLUDE 'bodytag.inc' bodyid='opac-patron-consent' %]
+[% INCLUDE 'masthead.inc' %]
+
+
+
+
+
+
+
+
+ [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
+
+
+
+
+
+ [% IF Koha.Preference('GDPR_Policy') %]
+
+
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.
+
Please save your consent below or log out. Thank you!
+
+ [% END %]
+
+
Your consents
+
+
+
+
+
+
+
+
+
+[% INCLUDE 'opac-bottom.inc' %]
+[% BLOCK jsinclude %]
+
+[% END %]
--- a/opac/opac-patron-consent.pl
+++ a/opac/opac-patron-consent.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+
+# Copyright 2018 Rijksmuseum
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+use CGI qw/-utf8/;
+
+use C4::Auth qw/get_template_and_user/;
+use C4::Output qw/output_html_with_http_headers/;
+use Koha::DateUtils qw/dt_from_string/;
+use Koha::Patron::Consents;
+use Koha::Patrons;
+
+use constant GDPR_PROCESSING => 'GDPR_PROCESSING';
+
+my $query = new CGI;
+my $op = $query->param('op') // q{};
+my $gdpr_check = $query->param('gdpr_processing') // q{};
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
+ template_name => "opac-patron-consent.tt",
+ query => $query,
+ type => "opac",
+ authnotrequired => 0,
+});
+
+my $patron = Koha::Patrons->find($borrowernumber);
+my $gdpr_proc_consent;
+if( C4::Context->preference('GDPR_Policy') ) {
+ $gdpr_proc_consent = Koha::Patron::Consents->search({
+ borrowernumber => $borrowernumber,
+ type => GDPR_PROCESSING,
+ })->next;
+ $gdpr_proc_consent //= Koha::Patron::Consent->new({
+ borrowernumber => $borrowernumber,
+ type => GDPR_PROCESSING,
+ });
+}
+
+# Handle saves here
+if( $op eq 'gdpr_proc_save' && $gdpr_proc_consent ) {
+ if( $gdpr_check eq 'agreed' ) {
+ $gdpr_proc_consent->given_on( dt_from_string() );
+ $gdpr_proc_consent->refused_on( undef );
+ } elsif( $gdpr_check eq 'disagreed' ) {
+ $gdpr_proc_consent->given_on( undef );
+ $gdpr_proc_consent->refused_on( dt_from_string() );
+ }
+ $gdpr_proc_consent->store;
+}
+
+# If user refused GDPR consent and we enforce GDPR, logout (when saving)
+if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gdpr_proc_consent->refused_on )
+{
+ print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
+ exit;
+}
+
+$template->param( patron => $patron );
+if( $gdpr_proc_consent ) {
+ $template->param(
+ gdpr_proc_consent => $gdpr_proc_consent->given_on // q{},
+ gdpr_proc_refusal => $gdpr_proc_consent->refused_on // q{},
+ );
+}
+
+output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
--