From 7923eed3f83b4eeb1fe5470dd74a90cc20f782b5 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 27 Nov 2017 21:33:58 +0000 Subject: [PATCH] Bug 19496: [17.05.x] Fixing to_address for patron notes This patch ensures the patron note to_address is the branch email or the Koha Admin email, and the from_address is the patron's email. To test: 1) Ensure syspref 'allowcheckoutnotes' is turned on 2) Go to OPAC, leave a note on a checkout 3) Confirm that the note is received (in mysql message_queue) but the to_address is the patron's email - this is wrong 4) Apply patch and refresh OPAC 5) Leave a note on a checkout 6) Confirm that the note is received in message queue 7) Confirm that the to_address is one of: - branch email - branch reply to - syspref ReplytoDefault - syspref KohaAdminEmailAddress 8) Confirm that the from_address is one of: - patron email - patron emailpro - patron B_email Sponsored-by: Catalyst IT Signed-off-by: Fridolin Somers --- opac/opac-issue-note.pl | 20 +++++++++++++++----- opac/svc/patron_notes | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/opac/opac-issue-note.pl b/opac/opac-issue-note.pl index becd7083f7..da7e95fa8b 100755 --- a/opac/opac-issue-note.pl +++ b/opac/opac-issue-note.pl @@ -43,10 +43,10 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $member = C4::Members::GetMember( borrowernumber => $borrowernumber ); +my $patron = Koha::Patrons->find( $borrowernumber ); $template->param( - firstname => $member->{'firstname'}, - surname => $member->{'surname'}, + firstname => $patron->firstname, + surname => $patron->surname, borrowernumber => $borrowernumber, ); @@ -76,10 +76,20 @@ if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') ) { branchcode => $branch, tables => { 'biblio' => $biblio->{biblionumber}, - 'borrowers' => $member->{borrowernumber}, + 'borrowers' => $patron->borrowernumber, }, ); - C4::Message->enqueue($letter, $member, 'email'); + + my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->ReplytoDefault || C4::Context->preference('KohaAdminEmailAddress'); + my $from_address = $patron->email || $patron->emailpro || $patron->B_email; + + C4::Letters::EnqueueLetter({ + letter => $letter, + message_transport_type => 'email', + borrowernumber => $patron->borrowernumber, + to_address => $to_address, + from_address => $from_address, + }); } } print $query->redirect("/cgi-bin/koha/opac-user.pl"); diff --git a/opac/svc/patron_notes b/opac/svc/patron_notes index d241f0c970..a1a7623a3a 100755 --- a/opac/svc/patron_notes +++ b/opac/svc/patron_notes @@ -57,7 +57,7 @@ if ($is_ajax) { my $issue_id = $query->param('issue_id'); my $clean_note = $scrubber->scrub($note); my $status = "saved"; - my ($member, $issue); + my ($patron, $issue); my ( $template, $borrowernumber, $cookie ) = C4::Auth::get_template_and_user({ template_name => "opac-user.tt", @@ -68,7 +68,7 @@ if ($is_ajax) { # verify issue_id if ( $issue_id =~ /\d+/ ) { - $member = GetMember(borrowernumber => $borrowernumber); + $patron = Koha::Patrons->find( $borrowernumber ); # Double fetch is specific to 17.05 $issue = Koha::Checkouts->find($issue_id); if ( $issue->borrowernumber != $borrowernumber ) { $status = "fail"; @@ -86,10 +86,20 @@ if ($is_ajax) { branchcode => $branch, tables => { 'biblio' => $biblio->{biblionumber}, - 'borrowers' => $member->{borrowernumber}, + 'borrowers' => $patron->borrowernumber, }, ); - C4::Message->enqueue($letter, $member, 'email'); + + my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->ReplytoDefault || C4::Context->preference('KohaAdminEmailAddress'); + my $from_address = $patron->email || $patron->emailpro || $patron->B_email; + + C4::Letters::EnqueueLetter({ + letter => $letter, + message_transport_type => 'email', + borrowernumber => $patron->borrowernumber, + to_address => $to_address, + from_address => $from_address, + }); } else { # note empty, i.e removed $status = "removed"; } -- 2.39.5