From 78cbd46d7dd3cddeee61fc2c5bdcee69c8ced3b4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Dec 2016 16:11:21 +0100 Subject: [PATCH] Bug 17762: Send lang to GetPreparedLetter This patch set the lang parameter when C4::Letters::GetPreparedLetter is called to generate the notice. Note that we do not need to pass it if want_librarian is set. TODO: I do not know what to do with TransferSlip Sponsored-by: Orex Digital --- C4/Acquisition.pm | 1 + C4/Circulation.pm | 2 ++ C4/Members.pm | 3 +++ C4/Overdues.pm | 3 +++ C4/Reserves.pm | 4 ++++ C4/Suggestions.pm | 2 ++ Koha/ArticleRequest.pm | 1 + Koha/Patron/Discharge.pm | 2 ++ Koha/Patron/Password/Recovery.pm | 1 + circ/article-request-slip.pl | 3 +++ misc/cronjobs/advance_notices.pl | 3 +++ misc/cronjobs/membership_expiry.pl | 4 ++++ misc/cronjobs/notice_unprocessed_suggestions.pl | 1 + misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl | 1 + opac/opac-memberentry.pl | 1 + opac/opac-shareshelf.pl | 4 ++++ 16 files changed, 36 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 6ad5ff7..be831e0 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -3028,6 +3028,7 @@ sub NotifyOrderUsers { module => 'acquisition', letter_code => 'ACQ_NOTIF_ON_RECEIV', branchcode => $library->{branchcode}, + lang => $borrower->{lang}, tables => { 'branches' => $library, 'borrowers' => $borrower, diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b505031..800e133 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3474,6 +3474,7 @@ sub SendCirculationAlert { letter_code => $type, branchcode => $branch, message_transport_type => $_, + lang => $borrower->{lang}, tables => { $issues_table => $item->{itemnumber}, 'items' => $item->{itemnumber}, @@ -3491,6 +3492,7 @@ sub SendCirculationAlert { letter_code => $type, branchcode => $branch, message_transport_type => $_, + lang => $borrower->{lang}, tables => { $issues_table => $item->{itemnumber}, 'items' => $item->{itemnumber}, diff --git a/C4/Members.pm b/C4/Members.pm index 9b44b32..aa8893b 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1542,6 +1542,8 @@ sub IssueSlip { # FIXME Check callers before removing this statement #return unless $borrowernumber; + my $patron = Koha::Patrons->find( $borrowernumber ); + my @issues = @{ GetPendingIssues($borrowernumber) }; for my $issue (@issues) { @@ -1602,6 +1604,7 @@ sub IssueSlip { module => 'circulation', letter_code => $letter_code, branchcode => $branch, + lang => $patron->lang, tables => { 'branches' => $branch, 'borrowers' => $borrowernumber, diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 545f4d2..9075e20 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -995,6 +995,8 @@ sub parse_overdues_letter { return unless ( exists $params->{$required} && $params->{$required} ); } + my $patron = Koha::Patrons->find( $params->{borrowernumber} ); + my $substitute = $params->{'substitute'} || {}; $substitute->{today} ||= output_pref( { dt => dt_from_string, dateonly => 1} ); @@ -1035,6 +1037,7 @@ sub parse_overdues_letter { module => 'circulation', letter_code => $params->{'letter_code'}, branchcode => $params->{'branchcode'}, + lang => $patron->lang, tables => \%tables, substitute => $substitute, repeat => { item => \@item_tables }, diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9ef33ad..1223bbb 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -232,6 +232,7 @@ sub AddReserve { module => 'reserves', letter_code => 'HOLDPLACED', branchcode => $branch, + lang => $borrower->{lang}, tables => { 'branches' => $library, 'borrowers' => $borrower, @@ -2007,6 +2008,7 @@ sub _koha_notify_reserve { my %letter_params = ( module => 'reserves', branchcode => $reserve->{branchcode}, + lang => $borrower->{lang}, tables => { 'branches' => $library, 'borrowers' => $borrower, @@ -2352,6 +2354,7 @@ sub ReserveSlip { my ($branch, $borrowernumber, $biblionumber) = @_; # return unless ( C4::Context->boolean_preference('printreserveslips') ); + my $patron = Koha::Patrons->find( $borrowernumber ); my $reserve_id = GetReserveId({ biblionumber => $biblionumber, @@ -2363,6 +2366,7 @@ sub ReserveSlip { module => 'circulation', letter_code => 'HOLD_SLIP', branchcode => $branch, + lang => $patron->lang, tables => { 'reserves' => $reserve, 'branches' => $reserve->{branchcode}, diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 8e76cea..3839e4e 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -502,11 +502,13 @@ sub ModSuggestion { # fetch the entire updated suggestion so that we can populate the letter my $full_suggestion = GetSuggestion( $suggestion->{suggestionid} ); + my $patron = Koha::Patrons->find( $full_suggestion->{suggestedby} ); if ( my $letter = C4::Letters::GetPreparedLetter( module => 'suggestions', letter_code => $full_suggestion->{STATUS}, branchcode => $full_suggestion->{branchcode}, + lang => $patron->lang, tables => { 'branches' => $full_suggestion->{branchcode}, 'borrowers' => $full_suggestion->{suggestedby}, diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index 75318fd..7f1a594 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -108,6 +108,7 @@ sub notify { module => 'circulation', letter_code => "AR_$status", message_transport_type => 'email', + lang => $self->borrower->lang, tables => { article_requests => $self->id, borrowers => $self->borrowernumber, diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm index d519d40..289fdb0 100644 --- a/Koha/Patron/Discharge.pm +++ b/Koha/Patron/Discharge.pm @@ -107,9 +107,11 @@ sub generate_as_pdf { my ($params) = @_; return unless $params->{borrowernumber}; + my $patron = Koha::Patrons->find( $params->{borrowernumber} ); my $letter = C4::Letters::GetPreparedLetter( module => 'members', letter_code => 'DISCHARGE', + lang => $patron->lang, tables => { borrowers => $params->{borrowernumber}, branches => $params->{'branchcode'}, }, ); diff --git a/Koha/Patron/Password/Recovery.pm b/Koha/Patron/Password/Recovery.pm index cc59a6c..c85540c 100644 --- a/Koha/Patron/Password/Recovery.pm +++ b/Koha/Patron/Password/Recovery.pm @@ -143,6 +143,7 @@ sub SendPasswordRecoveryEmail { module => 'members', letter_code => 'PASSWORD_RESET', branchcode => $borrower->branchcode, + lang => $borrower->lang, substitute => { passwordreseturl => $uuidLink, user => $borrower->userid }, ); diff --git a/circ/article-request-slip.pl b/circ/article-request-slip.pl index 6a7087d..7c8ec50 100755 --- a/circ/article-request-slip.pl +++ b/circ/article-request-slip.pl @@ -25,6 +25,7 @@ use C4::Context; use C4::Output; use C4::Auth; use Koha::ArticleRequests; +use Koha::Patrons; my $cgi = new CGI; @@ -43,11 +44,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $ar = Koha::ArticleRequests->find($id); $template->param( article_request => $ar ); +my $patron = Koha::Patrons->find( $ar->borrowernumber ); my $slip = C4::Letters::GetPreparedLetter( module => 'circulation', letter_code => 'AR_SLIP', message_transport_type => 'print', + lang => $patron->lang, tables => { article_requests => $ar->id, borrowers => $ar->borrowernumber, diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index 855492e..7eb3809 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -58,6 +58,7 @@ use C4::Overdues; use Koha::DateUtils; use C4::Log; use Koha::Libraries; +use Koha::Patrons; =head1 NAME @@ -467,6 +468,7 @@ sub parse_letter { foreach my $required ( qw( letter_code borrowernumber ) ) { return unless exists $params->{$required}; } + my $patron = Koha::Patrons->find( $params->{borrowernumber} ); my %table_params = ( 'borrowers' => $params->{'borrowernumber'} ); @@ -486,6 +488,7 @@ sub parse_letter { module => 'circulation', letter_code => $params->{'letter_code'}, branchcode => $table_params{'branches'}, + lang => $patron->lang, substitute => $params->{'substitute'}, tables => \%table_params, message_transport_type => $params->{message_transport_type}, diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index 36c0329..0007a2f 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -130,6 +130,8 @@ use C4::Context; use C4::Letters; use C4::Log; +use Koha::Patrons; + # These are defaults for command line options. my $confirm; # -c: Confirm that the user has read and configured this script. my $nomail; # -n: No mail. Will not send any emails. @@ -174,11 +176,13 @@ warn 'found ' . scalar( @$upcoming_mem_expires ) . ' soon expiring members' # main loop $letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; foreach my $recent ( @$upcoming_mem_expires ) { + my $patron = Koha::Patrons->find( $recent->{borrowernumber} ); my $from_address = $recent->{'branchemail'} || $admin_adress; my $letter = C4::Letters::GetPreparedLetter( module => 'members', letter_code => $letter_type, branchcode => $recent->{'branchcode'}, + lang => $patron->lang, tables => { borrowers => $recent->{'borrowernumber'}, branches => $recent->{'branchcode'}, diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl index 4c370e8..a0c42ed 100755 --- a/misc/cronjobs/notice_unprocessed_suggestions.pl +++ b/misc/cronjobs/notice_unprocessed_suggestions.pl @@ -58,6 +58,7 @@ for my $number_of_days (@days) { module => 'suggestions', letter_code => 'TO_PROCESS', branchcode => $patron->{branchcode}, + lang => $patron->{lang}, tables => { suggestions => $suggestion->{suggestionid}, branches => $patron->{branchcode}, diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 1299b7d..54c2592 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -123,6 +123,7 @@ foreach my $type (@types) { my $letter = C4::Letters::GetPreparedLetter( module => $module, letter_code => $code, + lang => 'default', # It does not sound useful to send a lang here tables => { borrowers => $issues->{'borrowernumber'}, biblio => $issues->{'biblionumber'}, diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 59306bc..6627a8b 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -153,6 +153,7 @@ if ( $action eq 'create' ) { my $letter = C4::Letters::GetPreparedLetter( module => 'members', letter_code => 'OPAC_REG_VERIFY', + lang => 'default', # Patron does not have a preferred language defined yet tables => { borrower_modifications => $verification_token, }, diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl index b2f5c8b..89d7dc9 100755 --- a/opac/opac-shareshelf.pl +++ b/opac/opac-shareshelf.pl @@ -169,11 +169,14 @@ sub notify_owner { my $toaddr = C4::Members::GetNoticeEmailAddress( $param->{owner} ); return if !$toaddr; + my $patron = Koha::Patrons->find( $param->{owner} ); + #prepare letter my $letter = C4::Letters::GetPreparedLetter( module => 'members', letter_code => 'SHARE_ACCEPT', branchcode => C4::Context->userenv->{"branch"}, + lang => $patron->lang, tables => { borrowers => $param->{loggedinuser}, }, substitute => { listname => $param->{shelfname}, }, ); @@ -239,6 +242,7 @@ sub send_invitekey { module => 'members', letter_code => 'SHARE_INVITE', branchcode => C4::Context->userenv->{"branch"}, + lang => 'default', # Not sure how we could use something more useful else here tables => { borrowers => $param->{loggedinuser}, }, substitute => { listname => $param->{shelfname}, -- 2.9.3