From 7c7794f1b250abf5fc8c82fa30e4f2c97df38727 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 17 Jun 2021 14:30:59 +0100 Subject: [PATCH] Bug 28581: Use 'from_email_address' where appropriate This patch replaces a few more trivial cases where we were using library->branchemail with a fallback to KohaAdminEmail to just use the new library->from_email_address method directly instead. There were also a couple of cases where we were passing borrowernumber and the patrons library from address too.. this is unneccesary as the code in _send_email_massage will already default to patron library from address if we do not pass an override. Signed-off-by: Marcel de Rooy Added a semicolon. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/Reserves.pm | 2 +- Koha/Illrequest.pm | 4 ++-- circ/pendingreserves.pl | 4 ++-- misc/cronjobs/notice_unprocessed_suggestions.pl | 6 +----- misc/cronjobs/overdue_notices.pl | 3 +-- suggestion/suggestion.pl | 6 +----- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 0bf8bf6b77..8fb05c1e37 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1849,7 +1849,7 @@ sub _koha_notify_reserve { my $library = Koha::Libraries->find( $hold->branchcode )->unblessed; - my $admin_email_address = $library->{branchemail} || C4::Context->preference('KohaAdminEmailAddress'); + my $admin_email_address = $library->from_email_address; my %letter_params = ( module => 'reserves', diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 74d9b84d10..01d421f63d 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1335,7 +1335,7 @@ sub generic_confirm { "No target email addresses found. Either select at least one partner or check your ILL partner library records.") if ( !$to ); # Create the from, replyto and sender headers - my $from = $branch->branchemail; + my $from = $branch->from_email_address; my $replyto = $branch->inbound_ill_address; Koha::Exceptions::Ill::NoLibraryEmail->throw( "Your library has no usable email address. Please set it.") @@ -1427,7 +1427,7 @@ sub send_patron_notice { # Notice should come from the library where the request was placed, # not the patrons home library my $branch = Koha::Libraries->find($self->branchcode); - my $from_address = $branch->branchemail; + my $from_address = $branch->from_email_address; my $reply_address = $branch->inbound_ill_address; # Send the notice to the patron via the chosen transport methods diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 9c730239e5..9310f26bbf 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -84,13 +84,13 @@ if ( $op eq 'cancel_reserve' and $reserve_id ) { }, ); if ( $letter ) { - my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); + my $from_address = $library->from_email_address; C4::Letters::EnqueueLetter( { letter => $letter, borrowernumber => $patron->borrowernumber, message_transport_type => 'email', - from_address => $admin_email_address, + from_address => $from_address, } ); unless ( $patron->notice_email_address ) { diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl index 055315c9dd..d2870b2372 100755 --- a/misc/cronjobs/notice_unprocessed_suggestions.pl +++ b/misc/cronjobs/notice_unprocessed_suggestions.pl @@ -48,9 +48,6 @@ for my $number_of_days (@days) { my $budget = C4::Budgets::GetBudget( $suggestion->{budgetid} ); my $patron = Koha::Patrons->find( $budget->{budget_owner_id} ); my $email_address = $patron->notice_email_address; - my $library = $patron->library; - my $admin_email_address = $library->branchemail - || C4::Context->preference('KohaAdminEmailAddress'); if ($email_address) { say "Patron " . $patron->borrowernumber . " is going to be notified" if $verbose; @@ -70,8 +67,7 @@ for my $number_of_days (@days) { { letter => $letter, borrowernumber => $patron->borrowernumber, - message_transport_type => 'email', - from_address => $admin_email_address, + message_transport_type => 'email' } ); } diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 74c1fc3789..c18997db35 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -469,8 +469,7 @@ foreach my $branchcode (@branches) { } my $library = Koha::Libraries->find($branchcode); - my $admin_email_address = $library->branchemail - || C4::Context->preference('KohaAdminEmailAddress'); + my $admin_email_address = $library->from_email_address; my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices') || $library->inbound_email_address; my @output_chunks; # may be sent to mail or stdout or csv file. diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 24b2099c87..370bac1e0c 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -187,9 +187,6 @@ if ( $op =~ /save/i ) { my $patron = Koha::Patrons->find( $suggestion_only->{managedby} ); my $email_address = $patron->notice_email_address; if ($patron->notice_email_address) { - my $library = $patron->library; - my $admin_email_address = $library->branchemail - || C4::Context->preference('KohaAdminEmailAddress'); my $letter = C4::Letters::GetPreparedLetter( module => 'suggestions', @@ -206,8 +203,7 @@ if ( $op =~ /save/i ) { { letter => $letter, borrowernumber => $patron->borrowernumber, - message_transport_type => 'email', - from_address => $admin_email_address, + message_transport_type => 'email' } ); } -- 2.39.5