From f54f582d346b7a8570e08307c17e561a3838f30d Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 21 Apr 2020 23:21:20 +0000 Subject: [PATCH] Bug 24197: Added new local use syspref which sets the email address that failed overdue notices are set to. Test plan: 1. Set no email addresses in patron record then checkout items to the patron making the due date in the past 2. Visit patron's home library page: Administration > Libraries Set a branch email and in global system preferences observe there is no syspref named RedirectAddressForFailedOverdueNotices 3. Manually run overdue_notices.pl 4. Check the message_queue database table and observe there is a print overdue notice and a email notice with to_address of the branch email address 5. Apply patch 6. Run database update: cd installer/data/mysql sudo koha-shell ./updatedb.pl 7. Confirm there is a new system preference named: RedirectAddressForFailedOverdueNotices Give it a different email address to that in the branch email. 7. Repeat steps 1,3,4 and observe that the failed overdue notices have been sent to the email defined in RedirectAddressForFailedOverdueNotices Sponsored-By: Catalyst IT Signed-off-by: Martin Renvoize --- ...7-new_RedirectAddressForFailedOverdueNotices_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/admin.pref | 6 ++++++ misc/cronjobs/overdue_notices.pl | 4 +++- 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_24197-new_RedirectAddressForFailedOverdueNotices_syspref.sql diff --git a/installer/data/mysql/atomicupdate/bug_24197-new_RedirectAddressForFailedOverdueNotices_syspref.sql b/installer/data/mysql/atomicupdate/bug_24197-new_RedirectAddressForFailedOverdueNotices_syspref.sql new file mode 100644 index 0000000000..957645a72e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24197-new_RedirectAddressForFailedOverdueNotices_syspref.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('RedirectAddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then the branch email or KohaAdminEmailAddress syspref will be the email address that failed overdue notices are sent to', 'free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e39352448c..59650b5fa2 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -524,6 +524,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'), ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), +('RedirectAddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then the branch email or KohaAdminEmailAddress syspref will be the email address that failed overdue notices are sent to', 'free'), ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), ('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), ('RenewAccruingItemInOpac','0','','If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index d2255fdf3f..ab39e5a197 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -21,6 +21,12 @@ Administration: class: email - "(Leave this field empty to send messages to their normal recipient)" - + - "Email address failed overdue notices are sent to: " + - pref: RedirectAddressForFailedOverdueNotices + class: email + - "If left empty then the branch email or KohaAdminEmailAddress will be set as the destination address for failed overdue notices" + - + - "How much debugging information to show in the browser when an internal error occurs: " - pref: DebugLevel default: 0 diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index d8fa4eef7d..fd2ab40a6a 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -455,7 +455,8 @@ foreach my $branchcode (@branches) { my $library = Koha::Libraries->find($branchcode); my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); - my $branch_email_address = $library->inbound_email_address; + my $branch_email_address = C4::Context->preference('RedirectAddressForFailedOverdueNotices') + || $library->inbound_email_address; my @output_chunks; # may be sent to mail or stdout or csv file. $verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $branch_email_address; @@ -817,6 +818,7 @@ END_SQL title => 'Overdue Notices', content => 'These messages were not sent directly to the patrons.', }; + C4::Letters::EnqueueLetter( { letter => $letter, borrowernumber => undef, -- 2.20.1