From ca1fdce08f1eea065ba262801f3214e646759261 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 17 Jun 2021 09:59:18 +0000 Subject: [PATCH] Bug 28581: Use from_email_address in the codebase Content-Type: text/plain; charset=utf-8 Adding only a few trivial cases now. Test plan: Run password recovery or membership expiry cron. Check sender address. Signed-off-by: Marcel de Rooy --- Koha/Patron/Password/Recovery.pm | 2 +- misc/cronjobs/automatic_renewals.pl | 6 ++---- misc/cronjobs/membership_expiry.pl | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Koha/Patron/Password/Recovery.pm b/Koha/Patron/Password/Recovery.pm index c2e2d27930..0dafdae4f3 100644 --- a/Koha/Patron/Password/Recovery.pm +++ b/Koha/Patron/Password/Recovery.pm @@ -151,7 +151,7 @@ sub SendPasswordRecoveryEmail { # define from emails my $library = $borrower->library; - my $kohaEmail = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); # send from patron's branch or Koha Admin + my $kohaEmail = $library->from_email_address; # send from patron's branch or Koha Admin my $message_id = C4::Letters::EnqueueLetter( { diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index c8958cdc9d..7b4158b969 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -212,7 +212,7 @@ if ( $send_notices && $confirm ) { ); my $library = Koha::Libraries->find( $patron->branchcode ); - my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); + my $admin_email_address = $library->from_email_address; C4::Letters::EnqueueLetter( { letter => $letter, @@ -270,8 +270,6 @@ String that denote the letter code. sub send_digests { my $params = shift; - my $admin_email_address = C4::Context->preference('KohaAdminEmailAddress'); - PATRON: while ( my ( $borrowernumber, $digest ) = each %{$params->{digests}} ) { my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( @@ -285,7 +283,7 @@ sub send_digests { my $patron = Koha::Patrons->find( $borrowernumber ); my $library = Koha::Libraries->find( $params->{branchcode} ); - my $from_address = $library->{branchemail} || $admin_email_address; + my $from_address = $library->from_email_address; foreach my $transport ( keys %{ $borrower_preferences->{'transports'} } ) { my $letter = C4::Letters::GetPreparedLetter ( diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index 5038ce1f9f..c140820ea5 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -168,7 +168,6 @@ if( !$expdays ) { exit; } -my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); warn 'getting upcoming membership expires' if $verbose; my $upcoming_mem_expires = Koha::Patrons->search_upcoming_membership_expires( { @@ -183,7 +182,7 @@ warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' # main loop $letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; while ( my $recent = $upcoming_mem_expires->next ) { - my $from_address = $recent->library->branchemail || $admin_adress; + my $from_address = $recent->library->from_email_address; my $letter = C4::Letters::GetPreparedLetter( module => 'members', letter_code => $letter_type, -- 2.20.1