From f7b11f38e8c779685662be9dbd43e5eb30339e4d 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 Signed-off-by: Hugo Agud Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Acquisition.pm | 1 + C4/Circulation.pm | 1 + 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 | 3 +++ 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, 34 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 2bb97a99e7..a9b26317d3 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -3026,6 +3026,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 174b3ac273..7147e2177f 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3389,6 +3389,7 @@ sub SendCirculationAlert { letter_code => $type, branchcode => $branch, message_transport_type => $mtt, + lang => $borrower->{lang}, tables => { $issues_table => $item->{itemnumber}, 'items' => $item->{itemnumber}, diff --git a/C4/Members.pm b/C4/Members.pm index cf7ea7cc22..b61f0b1252 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1173,6 +1173,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) { @@ -1233,6 +1235,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 8509bfcd93..b56708afff 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -994,6 +994,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} ); @@ -1028,6 +1030,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 5520954453..7e24ff465a 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -233,6 +233,7 @@ sub AddReserve { module => 'reserves', letter_code => 'HOLDPLACED', branchcode => $branch, + lang => $borrower->{lang}, tables => { 'branches' => $library, 'borrowers' => $borrower, @@ -1859,6 +1860,7 @@ sub _koha_notify_reserve { my %letter_params = ( module => 'reserves', branchcode => $hold->branchcode, + lang => $borrower->{lang}, tables => { 'branches' => $library, 'borrowers' => $borrower, @@ -2204,6 +2206,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, @@ -2215,6 +2218,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 4fdd378654..1ea2339625 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 6b4daf4ead..f114eed338 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -108,6 +108,7 @@ sub notify { module => 'circulation', letter_code => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED 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 d519d40940..289fdb09a8 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 7c35c5d405..a23a609b90 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 6a7087d449..7c8ec50823 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 855492e51b..7eb3809be0 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 260a9f8b10..1b6ea81d43 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. @@ -185,6 +187,7 @@ while ( my $recent = $upcoming_mem_expires->next ) { module => 'members', letter_code => $letter_type, branchcode => $recent->branchcode, + lang => $recent->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 4c370e8613..a0c42ed662 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 1299b7d91b..54c259249c 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 64f9e03756..1e4034c6c9 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -174,6 +174,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 b2f5c8b668..89d7dc9d5d 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.39.5