Bugzilla – Attachment 74110 Details for
Bug 8000
Test mode for notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8000: Redirect all emails to SendAllEmailsTo
Bug-8000-Redirect-all-emails-to-SendAllEmailsTo.patch (text/plain), 6.69 KB, created by
David Bourgault
on 2018-04-12 15:45:57 UTC
(
hide
)
Description:
Bug 8000: Redirect all emails to SendAllEmailsTo
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2018-04-12 15:45:57 UTC
Size:
6.69 KB
patch
obsolete
>From bd3884cedc6e6418f5ecbc9c10703d4efb3967cb Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Fri, 15 Sep 2017 15:06:13 -0400 >Subject: [PATCH] Bug 8000: Redirect all emails to SendAllEmailsTo > >Koha/Email.pm > >Test plan: > >1) Apply path >2) Run updatedatabase.pl >3) Clear all SendAllEmailsTo system preference >4) Send mail to a patron of your choosing, email will go to patron's > email address as usual. >5) Set SendAllEmailsTo to a test email address >6) Send mail to the patron, email will be redirected to the email set > in the systempreference. >7) Run prove -v t/db_dependent/Letters.t > >It does not affect messages in the message_queue. > >This patch obsoletes previous patches, because it achieves the same >functionality in a much more centralized way. (4 lines of code!) > >Signed-off-by: Ed Veal <eveal@mckinneytexas.org> >Signed-off-by: BWS Sandboxes <ByWaterSandboxes@gmail.com> >--- > Koha/Email.pm | 6 ++++++ > .../mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql | 2 ++ > installer/data/mysql/sysprefs.sql | 3 ++- > .../prog/en/modules/admin/preferences/admin.pref | 5 +++++ > t/db_dependent/Letters.t | 12 +++++++++++- > 5 files changed, 26 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql > >diff --git a/Koha/Email.pm b/Koha/Email.pm >index fc392a3..9f63e39 100644 >--- a/Koha/Email.pm >+++ b/Koha/Email.pm >@@ -18,6 +18,7 @@ > package Koha::Email; > > use Modern::Perl; >+use Email::Valid; > > use base qw(Class::Accessor); > use C4::Context; >@@ -49,6 +50,11 @@ sub create_message_headers { > From => $params->{from}, > charset => $params->{charset} > ); >+ >+ if (C4::Context->preference('SendAllEmailsTo') && Email::Valid->address(C4::Context->preference('SendAllEmailsTo'))) { >+ $mail{'To'} = C4::Context->preference('SendAllEmailsTo'); >+ } >+ > if ( C4::Context->preference('ReplytoDefault') ) { > $params->{replyto} ||= C4::Context->preference('ReplytoDefault'); > } >diff --git a/installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql b/installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql >new file mode 100644 >index 0000000..37bdb9c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql >@@ -0,0 +1,2 @@ >+INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) >+VALUES ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'); >\ No newline at end of file >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 1659915..ce8c345 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -1,4 +1,4 @@ >-INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),` ) VALUES > ('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'), > ('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'), > ('AcqItemSetSubfieldsWhenReceiptIsCancelled','', '','Upon cancelling a receipt, update the items subfields if they were created when placing an order (e.g. o=5|a="bar foo")', 'Free'), >@@ -490,6 +490,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SelfCheckoutByLogin','1',NULL,'Have patrons login into the web-based self checkout system with their username/password or their cardnumber','YesNo'), > ('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'), > ('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'), >+('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'), > ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), > ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), > ('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','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 2e8dce7..aa0a211 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 >@@ -16,6 +16,11 @@ Administration: > class: email > - "If you leave this empty, the From address will be used (often defaulting to the admin address)." > - >+ - "Email to redirect all messages to: " >+ - pref: SendAllEmailsTo >+ class: email >+ - "(Leave this field empty to send messages to their normal recipient)" >+ - > - "How much debugging information to show in the browser when an internal error occurs: " > - pref: DebugLevel > default: 0 >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 1a61793..fc92b86 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 77; >+use Test::More tests => 79; > use Test::MockModule; > use Test::Warn; > >@@ -515,6 +515,7 @@ my $borrowernumber = AddMember( > ); > my $alert_id = C4::Letters::addalert($borrowernumber, 'issue', $subscriptionid); > >+t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' ); > > my $err2; > warning_is { >@@ -524,6 +525,15 @@ $err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) } > is($err2, 1, "Successfully sent serial notification"); > is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification"); > is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); >+ >+t::lib::Mocks::mock_preference( 'SendAllEmailsTo', 'robert.tables@mail.com' ); >+ >+my $err3; >+warning_is { >+$err3 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) } >+ "Fake sendmail", >+ "SendAlerts is using the mocked sendmail routine"; >+is($mail{'To'}, 'robert.tables@mail.com', "mailto address overwritten by SendAllMailsTo preference"); > } > > subtest 'GetPreparedLetter' => sub { >-- >2.7.4
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 8000
:
21976
|
22315
|
24784
|
25917
|
25919
|
25920
|
25923
|
25924
|
25925
|
25926
|
25927
|
25928
|
25939
|
25950
|
25951
|
26446
|
37463
|
37464
|
37465
|
37466
|
37467
|
37468
|
37469
|
37472
|
37473
|
37474
|
37475
|
37476
|
37477
|
37478
|
37481
|
37482
|
37483
|
37484
|
37485
|
37486
|
37487
|
39985
|
39986
|
39987
|
39988
|
39989
|
39990
|
39991
|
39992
|
40215
|
40216
|
40217
|
40218
|
40219
|
40220
|
40221
|
40222
|
40223
|
40224
|
40225
|
40226
|
40227
|
40228
|
40229
|
40230
|
46354
|
46355
|
46356
|
46357
|
46358
|
46359
|
46360
|
46361
|
46362
|
49991
|
49992
|
49993
|
49998
|
49999
|
50000
|
55940
|
58434
|
62863
|
67155
|
70086
|
70087
|
70484
|
74110
|
74111
|
74848
|
80370
|
81487
|
81488
|
81589
|
81590
|
81591
|
84801
|
84802
|
84803
|
84804
|
84805
|
86861
|
86862
|
86863
|
86864
|
86865
|
88874
|
88875
|
88876
|
88877
|
88878
|
88879