Bugzilla – Attachment 4355 Details for
Bug 5929
Use branch admin email for advance_notice.pl emails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Squashed, Signed off commit for fix
0001-Bug-5929-use-branch-admin-email-for-advance_notice.patch (text/plain), 10.28 KB, created by
Ian Walls
on 2011-06-03 20:32:55 UTC
(
hide
)
Description:
Squashed, Signed off commit for fix
Filename:
MIME Type:
Creator:
Ian Walls
Created:
2011-06-03 20:32:55 UTC
Size:
10.28 KB
patch
obsolete
>From f84e9093434733ece4bd18d8655d5e570fa3613f Mon Sep 17 00:00:00 2001 >From: Ian Walls <ian.walls@bywatersolutions.com> >Date: Fri, 3 Jun 2011 16:29:38 -0400 >Subject: [PATCH] Bug 5929: use branch admin email for advance_notice.pl emails >Content-Type: text/plain; charset="utf-8" > >This squash commit takes the two patches from Srdjan and adds a minor fix to work with >template toolkit variable renames. > >Squashed commit of the following: > >commit 2cab669d1fd072600942e1e6fbf3378944255a68 >Author: Ian Walls <ian.walls@bywatersolutions.com> >Date: Thu Jun 2 14:08:40 2011 -0400 > > Bug 5929: Fix advanced_notices to use new template-toolkit compatible message names > > Uses 'item_due' and 'advance_notice' for advance notices names; letters do not send otherwise > >commit caded04702d5eebd0f63a3b93cdddce28257f092 >Author: Srdjan Jankovic <srdjan@catalyst.net.nz> >Date: Tue Mar 29 12:38:49 2011 +1300 > > wr77490 (bug 5929): removed debugging leftover > >commit 1944de0de40f937b1d8748500f24a119390db3f0 >Author: Srdjan Jankovic <srdjan@catalyst.net.nz> >Date: Tue Mar 22 19:05:23 2011 +1300 > > wr77490 (bug 5929): use branch email in preference for due notices > >Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com> >--- > C4/Circulation.pm | 3 +- > misc/cronjobs/advance_notices.pl | 39 ++++++++++++++++++++++++++----------- > 2 files changed, 29 insertions(+), 13 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9a2db4c..5efd090 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2093,9 +2093,10 @@ sub GetUpcomingDueIssues { > my $dbh = C4::Context->dbh; > > my $statement = <<END_SQL; >-SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due >+SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail > FROM issues > LEFT JOIN items USING (itemnumber) >+LEFT OUTER JOIN branches USING (branchcode) > WhERE returndate is NULL > AND ( TO_DAYS( NOW() )-TO_DAYS( date_due ) ) < ? > END_SQL >diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl >index 6a408e4..a573e96 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -63,14 +63,12 @@ my $confirm; # -c: Confir > my $nomail; # -n: No mail. Will not send any emails. > my $mindays = 0; # -m: Maximum number of days in advance to send notices > my $maxdays = 30; # -e: the End of the time period >-my $fromaddress = C4::Context->preference('KohaAdminEmailAddress'); # -f: From address for the emails > my $verbose = 0; # -v: verbose > my $itemscontent = join(',',qw( issuedate title barcode author )); > > GetOptions( 'c' => \$confirm, > 'n' => \$nomail, > 'm:i' => \$maxdays, >- 'f:s' => \$fromaddress, > 'v' => \$verbose, > 'itemscontent=s' => \$itemscontent, > ); >@@ -83,7 +81,6 @@ See the comments in the script for directions on changing the script. > This script has the following parameters : > -c Confirm and remove this help & warning > -m maximum number of days in advance to send advance notices. >- -f from address for the emails. Defaults to KohaAdminEmailAddress system preference > -n send No mail. Instead, all mail messages are printed on screen. Usefull for testing purposes. > -v verbose > -i csv list of fields that get substituted into templates in places >@@ -135,22 +132,28 @@ SELECT biblio.*, items.*, issues.* > AND (TO_DAYS(date_due)-TO_DAYS(NOW()) = ?) > END_SQL > >+my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); >+ > UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > warn 'examining ' . $upcoming->{'itemnumber'} . ' upcoming due items' if $verbose; > # warn( Data::Dumper->Dump( [ $upcoming ], [ 'overdue' ] ) ); > >+ my $from_address = $upcoming->{branchemail} || $admin_adress; >+ > my $letter; > my $borrower_preferences; > if ( 0 == $upcoming->{'days_until_due'} ) { > # This item is due today. Send an 'item due' message. > $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $upcoming->{'borrowernumber'}, >- message_name => 'item due' } ); >+ message_name => 'item_due' } ); > # warn( Data::Dumper->Dump( [ $borrower_preferences ], [ 'borrower_preferences' ] ) ); >- next DUEITEM unless $borrower_preferences; >+ next unless $borrower_preferences; > > if ( $borrower_preferences->{'wants_digest'} ) { > # cache this one to process after we've run through all of the items. >- $due_digest->{$upcoming->{'borrowernumber'}}++; >+ my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {}; >+ $digest->{email} ||= $from_address; >+ $digest->{count}++; > } else { > my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} ); > my $letter_type = 'DUE'; >@@ -172,14 +175,16 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > } > } else { > $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $upcoming->{'borrowernumber'}, >- message_name => 'advance notice' } ); >+ message_name => 'advance_notice' } ); > # warn( Data::Dumper->Dump( [ $borrower_preferences ], [ 'borrower_preferences' ] ) ); > next UPCOMINGITEM unless $borrower_preferences && exists $borrower_preferences->{'days_in_advance'}; > next UPCOMINGITEM unless $borrower_preferences->{'days_in_advance'} == $upcoming->{'days_until_due'}; > > if ( $borrower_preferences->{'wants_digest'} ) { > # cache this one to process after we've run through all of the items. >- $upcoming_digest->{$upcoming->{'borrowernumber'}}++; >+ my $digest = $upcoming_digest->{$upcoming->{'borrowernumber'}} ||= {}; >+ $digest->{email} ||= $from_address; >+ $digest->{count}++; > } else { > my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} ); > my $letter_type = 'PREDUE'; >@@ -211,6 +216,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > foreach my $transport ( @{$borrower_preferences->{'transports'}} ) { > C4::Letters::EnqueueLetter( { letter => $letter, > borrowernumber => $upcoming->{'borrowernumber'}, >+ from_address => $from_address, > message_transport_type => $transport } ); > } > } >@@ -231,9 +237,12 @@ SELECT biblio.*, items.*, issues.* > AND (TO_DAYS(date_due)-TO_DAYS(NOW()) = ?) > END_SQL > >-PATRON: while ( my ( $borrowernumber, $count ) = each %$upcoming_digest ) { >+PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { >+ my $count = $digest->{count}; >+ my $from_address = $digest->{email}; >+ > my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, >- message_name => 'advance notice' } ); >+ message_name => 'advance_notice' } ); > # warn( Data::Dumper->Dump( [ $borrower_preferences ], [ 'borrower_preferences' ] ) ); > next PATRON unless $borrower_preferences; # how could this happen? > >@@ -241,6 +250,7 @@ PATRON: while ( my ( $borrowernumber, $count ) = each %$upcoming_digest ) { > my $letter_type = 'PREDUEDGST'; > my $letter = C4::Letters::getletter( 'circulation', $letter_type ); > die "no letter of type '$letter_type' found. Please see sample_notices.sql" unless $letter; >+ > $sth->execute($borrowernumber,$borrower_preferences->{'days_in_advance'}); > my $titles = ""; > while ( my $item_info = $sth->fetchrow_hashref()) { >@@ -261,15 +271,19 @@ PATRON: while ( my ( $borrowernumber, $count ) = each %$upcoming_digest ) { > foreach my $transport ( @{$borrower_preferences->{'transports'}} ) { > C4::Letters::EnqueueLetter( { letter => $letter, > borrowernumber => $borrowernumber, >+ from_address => $from_address, > message_transport_type => $transport } ); > } > } > } > > # Now, run through all the people that want digests and send them >-PATRON: while ( my ( $borrowernumber, $count ) = each %$due_digest ) { >+PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { >+ my $count = $digest->{count}; >+ my $from_address = $digest->{email}; >+ > my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, >- message_name => 'item due' } ); >+ message_name => 'item_due' } ); > # warn( Data::Dumper->Dump( [ $borrower_preferences ], [ 'borrower_preferences' ] ) ); > next PATRON unless $borrower_preferences; # how could this happen? > >@@ -297,6 +311,7 @@ PATRON: while ( my ( $borrowernumber, $count ) = each %$due_digest ) { > foreach my $transport ( @{$borrower_preferences->{'transports'}} ) { > C4::Letters::EnqueueLetter( { letter => $letter, > borrowernumber => $borrowernumber, >+ from_address => $from_address, > message_transport_type => $transport } ); > } > } >-- >1.5.6.5 >
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 5929
:
3393
|
3484
| 4355