From 4f7303f4d2728966440bae0a370b20afe32438ce Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 27 Jun 2024 15:50:13 +0100 Subject: [PATCH] Bug 21781: (follow-up) Use SMS templates We shouldn't only be changing the message transport type for the enqueue function but also for the call to GetPreparedLetter.. otherwise we'll just be putting what may be an innapropriately formatted for email notice into an SMS message. This patch updates all the occurences touched by the patchset to use the SMS notice template when we're falling back to SMS for transport medium. We also drop the fallback for the expiry notice, as a bug has since introduced functionality to send to both email and sms for that notice. Signed-off-by: Martin Renvoize --- C4/Acquisition.pm | 14 ++++++++------ circ/pendingreserves.pl | 14 ++++++++------ opac/opac-shareshelf.pl | 19 +++++++++---------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index e69c5a97893..e6503ef546d 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2933,12 +2933,14 @@ sub NotifyOrderUsers { my $patron = Koha::Patrons->find($borrowernumber); my $library = $patron->library->unblessed; my $biblio = Koha::Biblios->find( $order->{biblionumber} )->unblessed; + my $mtt = $patron->message_transport_type_for('email'); my $letter = C4::Letters::GetPreparedLetter( - module => 'acquisition', - letter_code => 'ACQ_NOTIF_ON_RECEIV', - branchcode => $library->{branchcode}, - lang => $patron->lang, - tables => { + module => 'acquisition', + letter_code => 'ACQ_NOTIF_ON_RECEIV', + branchcode => $library->{branchcode}, + message_transport_type => $mtt, + lang => $patron->lang, + tables => { 'branches' => $library, 'borrowers' => $patron->unblessed, 'biblio' => $biblio, @@ -2951,7 +2953,7 @@ sub NotifyOrderUsers { letter => $letter, borrowernumber => $borrowernumber, LibraryName => C4::Context->preference("LibraryName"), - message_transport_type => $patron->message_transport_type_for('email'), + message_transport_type => $mtt, } ) or warn "can't enqueue letter $letter"; } diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 309367c3579..3978401a950 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -69,12 +69,14 @@ if ( $op eq 'cud-cancel_reserve' and $reserve_id ) { and C4::Context->preference('CanMarkHoldsToPullAsLost') eq 'allow_and_notify' ) { my $library = $hold->branch; + my $mtt = $patron->message_transport_type_for('email'); my $letter = C4::Letters::GetPreparedLetter( - module => 'reserves', - letter_code => 'CANCEL_HOLD_ON_LOST', - branchcode => $patron->branchcode, - lang => $patron->lang, - tables => { + module => 'reserves', + letter_code => 'CANCEL_HOLD_ON_LOST', + branchcode => $patron->branchcode, + message_transport_type => $mtt, + lang => $patron->lang, + tables => { branches => $library->branchcode, borrowers => $patron->borrowernumber, items => $item->itemnumber, @@ -90,7 +92,7 @@ if ( $op eq 'cud-cancel_reserve' and $reserve_id ) { { letter => $letter, borrowernumber => $patron->borrowernumber, - message_transport_type => $patron->message_transport_type_for('email'), + message_transport_type => $mtt, from_address => $from_address, } ); diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl index faa1d0cff5c..ffe42a78e30 100755 --- a/opac/opac-shareshelf.pl +++ b/opac/opac-shareshelf.pl @@ -192,25 +192,24 @@ sub notify_owner { my $patron = Koha::Patrons->find( $param->{owner} ); return unless $patron; - my $toaddr = $patron->notice_email_address or return; - #prepare letter + my $mtt = $patron->message_transport_type_for('email'); my $letter = C4::Letters::GetPreparedLetter( - module => 'lists', - letter_code => 'SHARE_ACCEPT', - branchcode => C4::Context->userenv->{"branch"}, - lang => $patron->lang, - tables => { borrowers => $loggedinuser, }, - substitute => { listname => $param->{shelfname}, }, + module => 'lists', + letter_code => 'SHARE_ACCEPT', + branchcode => C4::Context->userenv->{"branch"}, + message_transport_type => $mtt, + lang => $patron->lang, + tables => { borrowers => $loggedinuser, }, + substitute => { listname => $param->{shelfname}, }, ); #send letter to queue C4::Letters::EnqueueLetter( { letter => $letter, - message_transport_type => 'email', + message_transport_type => $mtt, from_address => C4::Context->preference('KohaAdminEmailAddress'), - message_transport_type => $patron->message_transport_type_for('email'), } ); } -- 2.51.0