From 2ffed3e207110e27d470439865ba6c3ef5313ff3 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. --- C4/Acquisition.pm | 14 ++++++++------ circ/pendingreserves.pl | 14 ++++++++------ opac/opac-shareshelf.pl | 16 +++++++++------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 3dadeab028e..68eef8ded63 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2915,12 +2915,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, @@ -2933,7 +2935,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 a80762c3120..69bc0c000a1 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..ca4301879d5 100755 --- a/opac/opac-shareshelf.pl +++ b/opac/opac-shareshelf.pl @@ -195,13 +195,15 @@ sub notify_owner { 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 @@ -210,7 +212,7 @@ sub notify_owner { letter => $letter, message_transport_type => 'email', from_address => C4::Context->preference('KohaAdminEmailAddress'), - message_transport_type => $patron->message_transport_type_for('email'), + message_transport_type => $mtt, } ); } -- 2.48.1