"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/opac/opac-patron-consent.pl" (23 Feb 2021, 2747 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "opac-patron-consent.pl" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.05.06_vs_20.11.00.

    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 });
   40 
   41 my $patron = Koha::Patrons->find($borrowernumber);
   42 my $gdpr_proc_consent;
   43 if( C4::Context->preference('GDPR_Policy') ) {
   44     $gdpr_proc_consent = Koha::Patron::Consents->search({
   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 }
   53 
   54 # Handle saves here
   55 if( $op eq 'gdpr_proc_save' && $gdpr_proc_consent ) {
   56     if( $gdpr_check eq 'agreed' ) {
   57         $gdpr_proc_consent->given_on( dt_from_string() );
   58         $gdpr_proc_consent->refused_on( undef );
   59     } elsif( $gdpr_check eq 'disagreed' ) {
   60         $gdpr_proc_consent->given_on( undef );
   61         $gdpr_proc_consent->refused_on( dt_from_string() );
   62     }
   63     $gdpr_proc_consent->store;
   64 }
   65 
   66 # If user refused GDPR consent and we enforce GDPR, logout (when saving)
   67 if( $op =~ /save/ && C4::Context->preference('GDPR_Policy') eq 'Enforced' && $gdpr_proc_consent->refused_on )
   68 {
   69     print $query->redirect('/cgi-bin/koha/opac-main.pl?logout.x=1');
   70     exit;
   71 }
   72 
   73 $template->param( patron => $patron );
   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 
   81 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };