View | Details | Raw Unified | Return to bug 8000
Collapse All | Expand All

(-)a/Koha/Email.pm (+6 lines)
Lines 18-23 Link Here
18
package Koha::Email;
18
package Koha::Email;
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Email::Valid;
21
22
22
use base qw(Class::Accessor);
23
use base qw(Class::Accessor);
23
use C4::Context;
24
use C4::Context;
Lines 49-54 sub create_message_headers { Link Here
49
        From    => $params->{from},
50
        From    => $params->{from},
50
        charset => $params->{charset}
51
        charset => $params->{charset}
51
    );
52
    );
53
54
    if (C4::Context->preference('SendAllEmailsTo') && Email::Valid->address(C4::Context->preference('SendAllEmailsTo'))) {
55
        $mail{'To'} = C4::Context->preference('SendAllEmailsTo');
56
    }
57
52
    if ( C4::Context->preference('ReplytoDefault') ) {
58
    if ( C4::Context->preference('ReplytoDefault') ) {
53
        $params->{replyto} ||= C4::Context->preference('ReplytoDefault');
59
        $params->{replyto} ||= C4::Context->preference('ReplytoDefault');
54
    }
60
    }
(-)a/installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) 
2
VALUES ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'); 
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 1-4 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
1
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
2
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
2
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
3
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
3
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
4
('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'),
4
('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'),
Lines 473-478 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
473
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
473
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
474
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
474
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
475
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
475
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
476
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
476
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
477
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
477
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
478
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
478
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
479
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+5 lines)
Lines 16-21 Administration: Link Here
16
              class: email
16
              class: email
17
            - "If you leave this empty, the From address will be used (often defaulting to the admin address)."
17
            - "If you leave this empty, the From address will be used (often defaulting to the admin address)."
18
        -
18
        -
19
            - "Email to redirect all messages to: "
20
            - pref: SendAllEmailsTo
21
              class: email
22
            - "(Leave this field empty to send messages to their normal recipient)"
23
        -
19
            - "How much debugging information to show in the browser when an internal error occurs: "
24
            - "How much debugging information to show in the browser when an internal error occurs: "
20
            - pref: DebugLevel
25
            - pref: DebugLevel
21
              default: 0
26
              default: 0
(-)a/t/db_dependent/Letters.t (-2 / +11 lines)
Lines 18-24 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 76;
21
use Test::More tests => 78;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 513-518 my $borrowernumber = AddMember( Link Here
513
);
513
);
514
my $alert_id = C4::Letters::addalert($borrowernumber, 'issue', $subscriptionid);
514
my $alert_id = C4::Letters::addalert($borrowernumber, 'issue', $subscriptionid);
515
515
516
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' );
516
517
517
my $err2;
518
my $err2;
518
warning_is {
519
warning_is {
Lines 522-527 $err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) } Link Here
522
is($err2, 1, "Successfully sent serial notification");
523
is($err2, 1, "Successfully sent serial notification");
523
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
524
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
524
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
525
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
526
527
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', 'robert.tables@mail.com' );
528
529
my $err3;
530
warning_is {
531
$err3 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
532
    "Fake sendmail",
533
    "SendAlerts is using the mocked sendmail routine";
534
is($mail{'To'}, 'robert.tables@mail.com', "mailto address overwritten by SendAllMailsTo preference");
525
}
535
}
526
536
527
subtest 'GetPreparedLetter' => sub {
537
subtest 'GetPreparedLetter' => sub {
528
- 

Return to bug 8000