Bugzilla – Attachment 30747 Details for
Bug 12532
Copy guarantee email to guarantor (or redirect if guarantee has no email set)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12532 - Redirect guarantee email to guarantor
Bug-12532---Redirect-guarantee-email-to-guarantor.patch (text/plain), 7.62 KB, created by
simith.doliveira
on 2014-08-12 20:06:27 UTC
(
hide
)
Description:
Bug 12532 - Redirect guarantee email to guarantor
Filename:
MIME Type:
Creator:
simith.doliveira
Created:
2014-08-12 20:06:27 UTC
Size:
7.62 KB
patch
obsolete
>From a6d50c6367cf616cb64686cfd21137eeff424ddc Mon Sep 17 00:00:00 2001 >From: simith <simith@inlibro.com> >Date: Tue, 12 Aug 2014 15:59:28 -0400 >Subject: [PATCH] Bug 12532 - Redirect guarantee email to guarantor > >All email message placed in message_queue table will be affected. > >Patch updated; system preference EnableRedirectGuaranteeEmail added to enable this feature. > >Testing: > >I Apply the patch >II Run updatedatabase.pl > >0) Enable EnhancedMessagingPreferences preference; >0) Enable EnableRedirectGuaranteeEmail preference; >1) Select a patron with child; >2) Enable Item checkout -> email in patron messaging preferences; >3) Select the patron's child; >4) Checkout an item; >5) Valide child checkout message in patron's inbox; > >sponsored by the ville de victoriaville >--- > C4/Letters.pm | 30 ++++++++++---------- > C4/Members.pm | 32 ++++++++++++++-------- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++++ > .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++ > 5 files changed, 50 insertions(+), 26 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 1d916e0..78e32f8 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -926,23 +926,25 @@ sub _send_message_by_email { > > my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); > my $to_address = $message->{'to_address'}; >- unless ($to_address) { >- unless ($member) { >- warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; >- _set_message_status( { message_id => $message->{'message_id'}, >- status => 'failed' } ); >- return; >- } >- $to_address = C4::Members::GetNoticeEmailAddress( $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? >- _set_message_status( { message_id => $message->{'message_id'}, >- status => 'failed' } ); >- return; >+ >+ if ($member) { >+ my $guarantorid = $member->{'guarantorid'}; >+ if ($guarantorid){ >+ $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} ); >+ } else { >+ unless ($to_address) { >+ $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} ); >+ } > } > } > >+ unless ($to_address) { >+ warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; >+ _set_message_status( { message_id => $message->{'message_id'}, >+ status => 'failed' } ); >+ return; >+ } >+ > my $utf8 = decode('MIME-Header', $message->{'subject'} ); > $message->{subject}= encode('MIME-Header', $utf8); > my $subject = encode('utf8', $message->{'subject'}); >diff --git a/C4/Members.pm b/C4/Members.pm >index 326344d..78b462d 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -1500,22 +1500,30 @@ Returns the empty string if no email address. > > sub GetNoticeEmailAddress { > my $borrowernumber = shift; >+ my $dbh = C4::Context->dbh(); >+ >+ my $member = C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); >+ my $guarantorid = $member->{'guarantorid'}; >+ my $borrowerNumberToSendEmail = $guarantorid ? $guarantorid : $borrowernumber; >+ >+ my $enableRedirectGuaranteeEmail = C4::Context->preference("EnableRedirectGuaranteeEmail"); >+ if (!$enableRedirectGuaranteeEmail){ >+ $borrowerNumberToSendEmail = $borrowernumber; >+ $guarantorid = undef; >+ } > > my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); > # if syspref is set to 'first valid' (value == OFF), look up email address >+ my $to_address = $member->{$which_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'} || ''; >+ $to_address = GetFirstValidEmailAddress($borrowerNumberToSendEmail); >+ } elsif( $guarantorid ) { >+ my $guarantor = C4::Members::GetMember( 'borrowernumber' => $guarantorid ); >+ if ( $guarantor ){ >+ $to_address = $guarantor->{ $which_address }; >+ } >+ } >+ return $to_address || ''; > } > > =head2 GetExpiryDate >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 03a3f1e..7c07074 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -111,6 +111,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), > ('EnableSearchHistory','0','','Enable or disable search history','YesNo'), > ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), >+('EnableRedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'), > ('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), > ('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'), > ('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 3f1af57..2579154 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8603,6 +8603,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('EnableRedirectGuaranteeEmail','0',NULL,'Enable the ability to redirect guarantee email messages to guarantor.','YesNo')"); >+ print "Upgrade to $DBversion done (Bug 12532 - Redirect guarantee email to guarantor)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 2469431..586f4dd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -138,3 +138,9 @@ Patrons: > - pref: CardnumberLength > - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')." > - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one." >+ - >+ - pref: EnableRedirectGuaranteeEmail >+ choices: >+ yes: Do >+ no: "Don't" >+ - enable the ability to redirect guarantee email messages to guarantor. All email message placed in message_queue table will be affected. >-- >1.9.1
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 12532
:
29510
|
30747
|
35313
|
36752
|
39787
|
39925
|
48645
|
53649
|
53689
|
53690
|
53699
|
53700
|
55985
|
56052
|
56053
|
59445
|
59446
|
59447
|
63197
|
64802
|
64824
|
67115
|
68340
|
70865
|
72064
|
72617
|
75099
|
77606
|
80313
|
85134
|
85135
|
87815
|
87816
|
88208
|
88209
|
88210
|
88211
|
88212
|
88213
|
88295
|
88296
|
114455
|
114456
|
114457
|
114458
|
114459
|
114460
|
114461
|
131091
|
131092
|
131093
|
131094
|
149233
|
150071
|
150208
|
150217
|
150240
|
150256
|
151028
|
151029
|
154854
|
154855
|
154856
|
154857
|
155036
|
155037
|
155828
|
155829
|
155830
|
155831
|
155832
|
155833
|
155834
|
155835
|
155836
|
155837
|
155873
|
155874
|
155875
|
155876
|
155877
|
155878
|
155879
|
155880
|
155881
|
155882
|
155883
|
155886
|
155934
|
155935
|
155936
|
155937
|
155938
|
155939
|
155940
|
155941
|
155942
|
155943
|
155944
|
155945
|
155946