From 3266b9d5bc80d4aabf47488fff4221d9af516a5e Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 1 Feb 2024 07:55:55 +0000 Subject: [PATCH] Bug 35969: Add error code in opac-sendbasket.pl No need to carp about empty basket or no reply address. Just add a simple explanation on the form. Note that it makes no sense to show the form if the patron has no email address. We need it as reply-to. Test plan: Try opac-sendbasket.pl?bib_list=null Remove email address from your account, try again. Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Emily Lamancusa Signed-off-by: Katrin Fischer (cherry picked from commit 35293612a8d0efa932bf376b7855b17cc29d6d5c) Signed-off-by: Fridolin Somers --- .../en/modules/opac-sendbasketform.tt | 8 +++++- opac/opac-sendbasket.pl | 28 ++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt index 577f149503..87ed2fef43 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt @@ -22,7 +22,13 @@ [% IF ( error ) %]
-

There was an error sending the cart.

+ [% IF error == 'NO_BODY' %] +

There was an error sending the cart: No valid biblio records found.

+ [% ELSIF error == 'NO_REPLY_ADDRESS' %] +

Since we do not have your email address, we cannot send a mail. We need your email address as reply-to address.

+ [% ELSE %] +

There was an error sending the cart.

+ [% END %]
[% END %] diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index d0ff9fc53a..5708d67cc0 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -21,13 +21,9 @@ use Modern::Perl; use CGI qw ( -utf8 ); use Encode; -use Carp qw( carp ); -use Try::Tiny qw( catch try ); -use C4::Biblio qw( - GetMarcSubjects -); -use C4::Auth qw( get_template_and_user ); +use C4::Auth qw( get_template_and_user ); +use C4::Biblio qw(GetMarcSubjects); use C4::Output qw( output_html_with_http_headers ); use C4::Templates; use Koha::Biblios; @@ -44,6 +40,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( type => "opac", } ); +my $patron = Koha::Patrons->find($borrowernumber); +my $user_email = $patron ? $patron->notice_email_address : undef; my $bib_list = $query->param('bib_list') || ''; my $email_add = $query->param('email_add'); @@ -57,9 +55,6 @@ if ( $email_add ) { } ); - my $patron = Koha::Patrons->find($borrowernumber); - my $user_email = $patron->notice_email_address; - my $comment = $query->param('comment'); my @bibs = split( /\//, $bib_list ); @@ -70,12 +65,7 @@ if ( $email_add ) { } if ( !defined $iso2709 ) { - carp "Error sending mail: empty basket"; - $template->param( error => 1 ); - } - elsif ( !defined $user_email or $user_email eq '' ) { - carp "Error sending mail: sender's email address is invalid"; - $template->param( error => 1 ); + $template->param( error => 'NO_BODY' ); } else { my %loops = ( biblio => \@bibs, ); @@ -118,8 +108,12 @@ if ( $email_add ) { $template->param( email_add => $email_add ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -} -else { + +} elsif( !$user_email ) { + $template->param( email_add => 1, error => 'NO_REPLY_ADDRESS' ); + output_html_with_http_headers $query, $cookie, $template->output; + +} else { my $new_session_id = $query->cookie('CGISESSID'); $template->param( bib_list => $bib_list, -- 2.39.5