Bugzilla – Attachment 186665 Details for
Bug 21781
message_transport_type should allow fallbacks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21781: Apply message_transport_type fallbacks to more locations
Bug-21781-Apply-messagetransporttype-fallbacks-to-.patch (text/plain), 5.44 KB, created by
Martin Renvoize (ashimema)
on 2025-09-22 09:55:54 UTC
(
hide
)
Description:
Bug 21781: Apply message_transport_type fallbacks to more locations
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-09-22 09:55:54 UTC
Size:
5.44 KB
patch
obsolete
>From a3040c052e31910fd8a4d4d186f0d441aa0e476c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 14 Sep 2021 13:31:09 -0400 >Subject: [PATCH] Bug 21781: Apply message_transport_type fallbacks to more > locations > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Acquisition.pm | 2 +- > C4/Suggestions.pm | 6 +--- > Koha/Patron.pm | 32 ++++++++++++++++++- > circ/pendingreserves.pl | 2 +- > .../en/modules/admin/preferences/patrons.pref | 4 +-- > opac/opac-shareshelf.pl | 2 +- > 6 files changed, 37 insertions(+), 11 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 3b5d444d458..e69c5a97893 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -2951,7 +2951,7 @@ sub NotifyOrderUsers { > letter => $letter, > borrowernumber => $borrowernumber, > LibraryName => C4::Context->preference("LibraryName"), >- message_transport_type => 'email', >+ message_transport_type => $patron->message_transport_type_for('email'), > } > ) or warn "can't enqueue letter $letter"; > } >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index a07c30131a2..d1b1452e668 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -269,10 +269,7 @@ sub ModSuggestion { > > my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} ); > >- my $transport = >- ( C4::Context->preference("FallbackToSMSIfNoEmail") ) >- && ( $patron->smsalertnumber ) >- && ( !$patron->email ) ? 'sms' : 'email'; >+ my $transport = $patron->message_transport_type_for('email'); > > if ( > my $letter = C4::Letters::GetPreparedLetter( >@@ -458,4 +455,3 @@ __END__ > Koha Development Team <http://koha-community.org/> > > =cut >- >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 479eb3c209b..5446beaf8af 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1949,6 +1949,28 @@ sub first_valid_email_address { > return $email; > } > >+=head3 message_transport_type_for >+ >+Given a message transport type, will return the transport type that should be used, >+including a fallback if needed. >+ >+my $mtt = $patron->message_transport_type_for('email'); >+ >+=cut >+ >+sub message_transport_type_for { >+ my ( $self, $mtt ) = @_; >+ >+ if ( $mtt eq 'email' ) { >+ return 'sms' >+ if C4::Context->preference("FallbackToSMSIfNoEmail") >+ && $self->smsalertnumber >+ && !$self->notice_email_address; >+ } >+ >+ return $mtt; >+} >+ > =head3 get_club_enrollments > > =cut >@@ -3016,7 +3038,15 @@ sub queue_notice { > or ( $mtt eq 'phone' and not $self->phone ) ) > { > push @{ $return{fallback} }, $mtt; >- $mtt = 'print'; >+ if ( C4::Context->preference("FallbackToSMSIfNoEmail") >+ && $mtt eq 'email' >+ && $self->smsalertnumber >+ && !$self->notice_email_address ) >+ { >+ $mtt = 'sms'; >+ } else { >+ $mtt = 'print'; >+ } > } > next if $mtt eq 'print' && $print_sent; > $letter_params->{message_transport_type} = $mtt; >diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl >index 746ae424e26..309367c3579 100755 >--- a/circ/pendingreserves.pl >+++ b/circ/pendingreserves.pl >@@ -90,7 +90,7 @@ if ( $op eq 'cud-cancel_reserve' and $reserve_id ) { > { > letter => $letter, > borrowernumber => $patron->borrowernumber, >- message_transport_type => 'email', >+ message_transport_type => $patron->message_transport_type_for('email'), > from_address => $from_address, > } > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 22788828bbc..2ca141b3ffb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -265,7 +265,7 @@ Patrons: > choices: > 1: Enable > 0: Disable >- - sending purchase suggestion messages by SMS if no patron email is defined. >+ - sending notices by SMS if patron has no email address. > - > - "Send automatic renewal notices: " > - pref: AutoRenewalNotices >@@ -526,4 +526,4 @@ Patrons: > homebranch: "Home library" > location: "Location" > itemcallnumber: "Item's callnumber" >- ccode: "Collection" >+ ccode: "Collection" >\ No newline at end of file >diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl >index c4dec0c18d6..faa1d0cff5c 100755 >--- a/opac/opac-shareshelf.pl >+++ b/opac/opac-shareshelf.pl >@@ -210,7 +210,7 @@ sub notify_owner { > letter => $letter, > message_transport_type => 'email', > from_address => C4::Context->preference('KohaAdminEmailAddress'), >- to_address => $toaddr, >+ message_transport_type => $patron->message_transport_type_for('email'), > } > ); > } >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21781
:
103525
|
103526
|
105328
|
109559
|
124868
|
124869
|
168199
|
168200
|
168201
|
178677
|
178678
| 186665 |
186666