Permalink
Browse files

Revert "Bug 8378 - <fine> syntax not working on overdues anymore"

This reverts commit 40f9914.

Per Colin's report (confirmed by Mathieu and Julian):
  "I've had some problems with this patch. With it applied I found
  overdues for multiple users getting the same user's overdue message
  text, eg user 1 gets their correct message but users 2, 3 and 4
  get it as well. reverting the patch corrected this. I've not tracked
  down the cause as yet."
  • Loading branch information...
1 parent fa87f18 commit 5a61a3bbfe94b3f3a2210dbd78884c8b53c5b533 @jcamins jcamins committed Dec 28, 2012
Showing with 6 additions and 108 deletions.
  1. +2 −95 C4/Letters.pm
  2. +4 −13 misc/cronjobs/overdue_notices.pl
View
97 C4/Letters.pm
@@ -31,7 +31,6 @@ use C4::SMS;
use C4::Debug;
use Date::Calc qw( Add_Delta_Days );
use Encode;
-use Unicode::Normalize;
use Carp;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -117,33 +116,6 @@ sub GetLetters {
return \%letters;
}
-=head2 GetLetter( %params )
-
- retrieves the letter template
-
- %params hash:
- module => letter module, mandatory
- letter_code => letter code, mandatory
- branchcode => for letter selection, if missing default system letter taken
- Return value:
- letter fields hashref (title & content useful)
-
-=cut
-
-sub GetLetter {
- my %params = @_;
-
- my $module = $params{module} or croak "No module";
- my $letter_code = $params{letter_code} or croak "No letter_code";
- my $branchcode = $params{branchcode} || '';
-
- my $letter = getletter( $module, $letter_code, $branchcode )
- or warn( "No $module $letter_code letter"),
- return;
-
- return $letter;
-}
-
my %letter;
sub getletter {
my ( $module, $code, $branchcode ) = @_;
@@ -440,8 +412,6 @@ sub SendAlerts {
=head2 GetPreparedLetter( %params )
- retrieves letter template and performs substituion processing
-
%params hash:
module => letter module, mandatory
letter_code => letter code, mandatory
@@ -469,65 +439,14 @@ sub GetPreparedLetter {
my $module = $params{module} or croak "No module";
my $letter_code = $params{letter_code} or croak "No letter_code";
my $branchcode = $params{branchcode} || '';
- my $tables = $params{tables};
- my $substitute = $params{substitute};
- my $repeat = $params{repeat};
my $letter = getletter( $module, $letter_code, $branchcode )
or warn( "No $module $letter_code letter"),
return;
- my $prepared_letter = GetProcessedLetter(
- module => $module,
- letter_code => $letter_code,
- letter => $letter,
- branchcode => $branchcode,
- tables => $tables,
- substitute => $substitute,
- repeat => $repeat
- );
-
- return $prepared_letter;
-}
-
-=head2 GetProcessedLetter( %params )
-
- given a letter, with possible pre-processing do standard processing
- allows one to perform letter template processing beforehand
-
- %params hash:
- module => letter module, mandatory
- letter_code => letter code, mandatory
- letter => letter, mandatory
- branchcode => for letter selection, if missing default system letter taken
- tables => a hashref with table names as keys. Values are either:
- - a scalar - primary key value
- - an arrayref - primary key values
- - a hashref - full record
- substitute => custom substitution key/value pairs
- repeat => records to be substituted on consecutive lines:
- - an arrayref - tries to guess what needs substituting by
- taking remaining << >> tokensr; not recommended
- - a hashref token => @tables - replaces <token> << >> << >> </token>
- subtemplate for each @tables row; table is a hashref as above
- want_librarian => boolean, if set to true triggers librarian details
- substitution from the userenv
- Return value:
- letter fields hashref (title & content useful)
-
-=cut
-
-sub GetProcessedLetter {
- my %params = @_;
-
- my $module = $params{module} or croak "No module";
- my $letter_code = $params{letter_code} or croak "No letter_code";
- my $letter = $params{letter} or croak "No letter";
- my $branchcode = $params{branchcode} || '';
my $tables = $params{tables};
my $substitute = $params{substitute};
my $repeat = $params{repeat};
-
$tables || $substitute || $repeat
or carp( "ERROR: nothing to substitute - both 'tables' and 'substitute' are empty" ),
return;
@@ -770,12 +689,6 @@ sub EnqueueLetter {
return;
}
- # It was found that the some utf8 codes, cause the text to be truncated from that point onward when stored,
- # so we normalize utf8 with NFC so that mysql will store 'all' of the content in its TEXT column type
- # Note: It is also done in _add_attachments accordingly.
- $params->{'letter'}->{'title'} = NFC($params->{'letter'}->{'title'}); # subject
- $params->{'letter'}->{'content'} = NFC($params->{'letter'}->{'content'});
-
# If we have any attachments we should encode then into the body.
if ( $params->{'attachments'} ) {
$params->{'letter'} = _add_attachments(
@@ -946,17 +859,11 @@ sub _add_attachments {
$message->attach(
Type => $letter->{'content-type'} || 'TEXT',
Data => $letter->{'is_html'}
- ? _wrap_html($letter->{'content'}, NFC($letter->{'title'}))
- : NFC($letter->{'content'}),
+ ? _wrap_html($letter->{'content'}, $letter->{'title'})
+ : $letter->{'content'},
);
foreach my $attachment ( @$attachments ) {
-
- if ($attachment->{'content'} =~ m/text/o) { # NFC normailze any "text" related content-type attachments
- $attachment->{'content'} = NFC($attachment->{'content'});
- }
- $attachment->{'filename'} = NFC($attachment->{'filename'});
-
$message->attach(
Type => $attachment->{'type'},
Data => $attachment->{'content'},
View
17 misc/cronjobs/overdue_notices.pl
@@ -432,12 +432,6 @@ =head1 SEE ALSO
next PERIOD;
}
- my $letter_template = C4::Letters::GetLetter (
- module => 'circulation',
- letter_code => $overdue_rules->{"letter$i"},
- branchcode => $branchcode
- );
-
# $letter->{'content'} is the text of the mail that is sent.
# this text contains fields that are replaced by their value. Those fields must be written between brackets
# The following fields are available :
@@ -509,7 +503,6 @@ =head1 SEE ALSO
my $letter = parse_letter(
{ letter_code => $overdue_rules->{"letter$i"},
- letter => $letter_template,
borrowernumber => $borrowernumber,
branchcode => $branchcode,
items => \@items,
@@ -611,12 +604,11 @@ =head1 SEE ALSO
my $attachment = {
filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt',
- type => 'text/plain; charset="utf-8"',
+ type => 'text/plain',
content => $content,
};
my $letter = {
- 'content-type' => 'text/plain; charset="utf-8"',
title => 'Overdue Notices',
content => 'These messages were not sent directly to the patrons.',
};
@@ -683,7 +675,7 @@ sub parse_letter {
and $params->{'letter'}->{'content'} =~ m/<fine>(.*)<\/fine>/o )
{ # process any fine tags...
$currency_format = $1;
- $params->{'letter'}->{'content'} =~ s/<fine>.*<\/fine>/<<items.fine>>/o;
+ $params->{'letter'}->{'content'} =~ s/<fine>.*<\/fine>/<<item.fine>>/o;
}
my @item_tables;
@@ -708,14 +700,13 @@ sub parse_letter {
}
}
- return C4::Letters::GetProcessedLetter (
+ return C4::Letters::GetPreparedLetter (
module => 'circulation',
letter_code => $params->{'letter_code'},
- letter => $params->{'letter'},
branchcode => $params->{'branchcode'},
tables => \%tables,
substitute => $substitute,
- repeat => { item => \@item_tables }
+ repeat => { item => \@item_tables },
);
}

0 comments on commit 5a61a3b

Please sign in to comment.