Bugzilla – Attachment 148816 Details for
Bug 18398
CHECKIN/CHECKOUT/RENEWAL don't use AutoEmailPrimaryAddress but first valid e-mail
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address
Bug-18398-Update-C4Message-enqueue-to-use-patron-n.patch (text/plain), 4.56 KB, created by
Martin Renvoize (ashimema)
on 2023-03-28 12:36:42 UTC
(
hide
)
Description:
Bug 18398: Update C4::Message enqueue to use $patron->notice_email_address
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-03-28 12:36:42 UTC
Size:
4.56 KB
patch
obsolete
>From 16ce159cc7d962e8a2cad3f4e946d28d23ba64db Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 10 Mar 2023 10:02:19 +0000 >Subject: [PATCH] Bug 18398: Update C4::Message enqueue to use > $patron->notice_email_address > >This patch updates the enque method in C4::Message to expect a >Koha::Patron object in the parameters and then uses that patron object >to select the correct email address for notices as defined by >AutoEmailPrimaryAddress. > >Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> >--- > C4/Circulation.pm | 3 ++- > C4/Message.pm | 45 ++++++++++++++++++++++++--------------------- > Koha/Recall.pm | 2 +- > Koha/Recalls.pm | 2 +- > 4 files changed, 28 insertions(+), 24 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index a8c5ba9dbb..b16b615bf9 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3650,7 +3650,8 @@ sub SendCirculationAlert { > my $message = C4::Message->find_last_message($borrower, $type, $mtt); > unless ( $message ) { > C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; >- C4::Message->enqueue($letter, $borrower, $mtt); >+ my $patron = Koha::Patrons->find($borrower->{borrowernumber}); >+ C4::Message->enqueue($letter, $patron, $mtt); > } else { > $message->append($letter); > $message->update; >diff --git a/C4/Message.pm b/C4/Message.pm >index 7a55152e05..8bf1a05b0a 100644 >--- a/C4/Message.pm >+++ b/C4/Message.pm >@@ -157,41 +157,44 @@ the message. > > # C4::Message->enqueue($letter, $borrower, $transport) > sub enqueue { >- my ($class, $letter, $borrower, $transport) = @_; >+ my ( $class, $letter, $patron, $transport ) = @_; > my $metadata = _metadata($letter); >- my $to_address = _to_address($borrower, $transport); >+ my $to_address = _to_address( $patron, $transport ); > > # Same as render_metadata > my $format ||= sub { $_[0] || "" }; >- my $body = join('', map { $format->($_) } @{$metadata->{body}}); >+ my $body = join( '', map { $format->($_) } @{ $metadata->{body} } ); > $letter->{content} = $metadata->{header} . $body . $metadata->{footer}; > >- $letter->{metadata} = Encode::decode_utf8(Dump($metadata)); >- C4::Letters::EnqueueLetter({ >- letter => $letter, >- borrowernumber => $borrower->{borrowernumber}, >- message_transport_type => $transport, >- to_address => $to_address, >- }); >+ $letter->{metadata} = Encode::decode_utf8( Dump($metadata) ); >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->id, >+ message_transport_type => $transport, >+ to_address => $to_address, >+ } >+ ); > } > > # based on message $transport, pick an appropriate address to send to > sub _to_address { >- my ($borrower, $transport) = @_; >+ my ( $patron, $transport ) = @_; > my $address; >- if ($transport eq 'email') { >- $address = $borrower->{email} >- || $borrower->{emailpro} >- || $borrower->{B_email}; >- } elsif ($transport eq 'sms') { >- $address = $borrower->{smsalertnumber}; >- } else { >+ if ( $transport eq 'email' ) { >+ $address = $patron->notice_email_address; >+ } >+ elsif ( $transport eq 'sms' ) { >+ $address = $patron->smsalertnumber; >+ } >+ else { > warn "'$transport' is an unknown message transport."; > } >- if (not defined $address) { >+ if ( not defined $address ) { > warn "An appropriate $transport address " >- . "for borrower $borrower->{userid} " >- . "could not be found."; >+ . "for borrower " >+ . $patron->userid >+ . "could not be found."; > } > return $address; > } >diff --git a/Koha/Recall.pm b/Koha/Recall.pm >index c993bb7fda..ab390962b2 100644 >--- a/Koha/Recall.pm >+++ b/Koha/Recall.pm >@@ -358,7 +358,7 @@ sub set_waiting { > }, > ); > >- C4::Message->enqueue($letter, $self->patron->unblessed, 'email'); >+ C4::Message->enqueue($letter, $self->patron, 'email'); > > return $self; > } >diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm >index 36d891d195..e81802b191 100644 >--- a/Koha/Recalls.pm >+++ b/Koha/Recalls.pm >@@ -161,7 +161,7 @@ sub add_recall { > }, > ); > >- C4::Message->enqueue( $letter, $checkout->patron->unblessed, 'email' ); >+ C4::Message->enqueue( $letter, $checkout->patron, 'email' ); > > $item = Koha::Items->find( $itemnumber ); > # add to statistics table >-- >2.40.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 18398
:
148053
|
148130
|
148816
|
148817
|
148838
|
148839