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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 35293612a8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 3266b9d5bc)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2024-02-01 07:55:55 +00:00 committed by Lucas Gass
parent 2644f581fd
commit 2d11da8436
2 changed files with 18 additions and 18 deletions

View file

@ -22,7 +22,13 @@
[% IF ( error ) %]
<div class="alert alert-warning">
<p>There was an error sending the cart.</p>
[% IF error == 'NO_BODY' %]
<p>There was an error sending the cart: No valid biblio records found.</p>
[% ELSIF error == 'NO_REPLY_ADDRESS' %]
<p>Since we do not have your email address, we cannot send a mail. We need your email address as reply-to address.</p>
[% ELSE %]
<p>There was an error sending the cart.</p>
[% END %]
</div>
[% END %]

View file

@ -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,