From 5182341cd1ae542e1c0b12ab57e669d8ba3d7938 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 20 Jul 2022 11:45:23 +0000 Subject: [PATCH] Bug 25498: (follow-up) Show error message when no sharee has email Test plan: Share a list with a patron that has no email address. Try to transfer ownership. Verify that you get the error message. Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 ++ opac/opac-shelves.pl | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index fdf8036b3e..37b1b226fd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -156,6 +156,8 @@ The item has not been added to the list. Please check it's not already in the list. [% CASE 'error_on_remove_share' %] The share has not been removed. + [% CASE 'no_email_found' %] + No email found for the patrons that accepted the share [% CASE 'success_on_update' %] List updated. [% CASE 'success_on_insert' %] diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index d93ae2c52a..bc7b70d70a 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -272,10 +272,15 @@ if ( $op eq 'add_form' ) { my $patrons = []; my $shares = $shelf->get_shares->search({ borrowernumber => { '!=' => undef } }); while( my $share = $shares->next ) { - push @$patrons, { email => $share->sharee->notice_email_address, borrowernumber => $share->get_column('borrowernumber') }; + my $email = $share->sharee->notice_email_address; + push @$patrons, { email => $email, borrowernumber => $share->get_column('borrowernumber') } if $email; + } + if( @$patrons ) { + $template->param( shared_users => $patrons ); + $op = 'transfer'; + } else { + push @messages, { type => 'error', code => 'no_email_found' }; } - $template->param( shared_users => $patrons ); - $op = 'transfer'; } elsif( !Koha::Patrons->find($new_owner) ) { push @messages, { type => 'error', code => 'new_owner_not_found' }; } elsif( !$shelf->get_shares->search({ borrowernumber => $new_owner })->count ) { -- 2.39.5