Bugzilla – Attachment 13511 Details for
Bug 9103
overdue_notices.pl should use AutoEmailPrimaryAddress syspref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-9103-overdue_notices.pl-should-use-AutoEmailPrim.patch (text/plain), 5.23 KB, created by
Fridolin Somers
on 2012-11-19 13:02:51 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2012-11-19 13:02:51 UTC
Size:
5.23 KB
patch
obsolete
>From 429635105e90048321feb95580b826de78d1d46d Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Mon, 19 Nov 2012 13:58:16 +0100 >Subject: [PATCH] Bug 9103: overdue_notices.pl should use > AutoEmailPrimaryAddress syspref > >--- > C4/Letters.pm | 8 +------- > C4/Members.pm | 30 ++++++++++++++++++++++++++++++ > C4/Reserves.pm | 9 +-------- > misc/cronjobs/overdue_notices.pl | 10 +++++++--- > 4 files changed, 39 insertions(+), 18 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index f646241..0f2f5be 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1015,13 +1015,7 @@ sub _send_message_by_email { > status => 'failed' } ); > return; > } >- my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); >- # If the system preference is set to 'first valid' (value == OFF), look up email address >- if ($which_address eq 'OFF') { >- $to_address = GetFirstValidEmailAddress( $message->{'borrowernumber'} ); >- } else { >- $to_address = $member->{$which_address}; >- } >+ $to_address = GetPrimaryEmailAddress( $message->{'borrowernumber'} ); > unless ($to_address) { > # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})"; > # warning too verbose for this more common case? >diff --git a/C4/Members.pm b/C4/Members.pm >index b2f45b9..0ef9446 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -65,6 +65,7 @@ BEGIN { > &getidcity > > &GetFirstValidEmailAddress >+ &GetPrimaryEmailAddress > > &GetAge > &GetCities >@@ -1312,6 +1313,35 @@ sub GetFirstValidEmailAddress { > } > } > >+=head2 GetPrimaryEmailAddress >+ >+ $email = GetPrimaryEmailAddress($borrowernumber); >+ >+Return the primary email address for a borrower, given the borrowernumber. >+Returns the empty string if no email address. >+ >+=cut >+ >+sub GetPrimaryEmailAddress { >+ my $borrowernumber = shift; >+ >+ my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); >+ # if syspref is set to 'first valid' (value == OFF), look up email address >+ if ( $which_address eq 'OFF' ) { >+ return GetFirstValidEmailAddress($borrowernumber); >+ } >+ # specified email address field >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare( qq{ >+ SELECT $which_address AS primaryemail >+ FROM borrowers >+ WHERE borrowernumber=? >+ } ); >+ $sth->execute($borrowernumber); >+ my $data = $sth->fetchrow_hashref; >+ return $data->{'primaryemail'} || ''; >+} >+ > =head2 GetExpiryDate > > $expirydate = GetExpiryDate($categorycode, $dateenrolled); >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 1dc6f72..6bedaed 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1835,14 +1835,7 @@ sub _koha_notify_reserve { > my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); > > # Try to get the borrower's email address >- my $to_address; >- my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); >- # If the system preference is set to 'first valid' (value == OFF), look up email address >- if ($which_address eq 'OFF') { >- $to_address = C4::Members::GetFirstValidEmailAddress( $borrowernumber ); >- } else { >- $to_address = $borrower->{$which_address}; >- } >+ my $to_address = C4::Members::GetPrimaryEmailAddress( $borrowernumber ); > > my $letter_code; > my $print_mode = 0; >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index e83bd39..64917ce 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -40,6 +40,7 @@ use C4::Dates qw/format_date/; > use C4::Debug; > use C4::Letters; > use C4::Overdues qw(GetFine); >+use C4::Members; > > =head1 NAME > >@@ -445,7 +446,7 @@ END_SQL > # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> > > my $borrower_sql = <<'END_SQL'; >-SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country, email >+SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country > FROM issues,borrowers,categories > WHERE issues.borrowernumber=borrowers.borrowernumber > AND borrowers.categorycode=categories.categorycode >@@ -474,11 +475,14 @@ END_SQL > $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows"; > > while ( my ( $borrowernumber, $firstname, $lastname, >- $address1, $address2, $city, $postcode, $country, $email >+ $address1, $address2, $city, $postcode, $country > ) = $sth->fetchrow ) > { > $verbose and warn "borrower $firstname, $lastname ($borrowernumber) has items triggering level $i."; >- >+ >+ # Try to get the borrower's email address >+ my $email = GetPrimaryEmailAddress($borrowernumber); >+ > if ( $overdue_rules->{"debarred$i"} ) { > > #action taken is debarring >-- >1.7.9.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 9103
:
13511
|
15931
|
16110
|
16248
|
16452