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

(-)a/C4/Letters.pm (-2 / +6 lines)
Lines 1333-1340 sub _send_message_by_email { Link Here
1333
1333
1334
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1334
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1335
    my $to_address = $message->{'to_address'};
1335
    my $to_address = $message->{'to_address'};
1336
    unless ($to_address) {
1336
1337
        unless ($patron) {
1337
    my $use_garantor = C4::Context->preference('RedirectGuaranteeEmail');
1338
    if($use_garantor || !$to_address) {
1339
        unless ($patron or $to_address) {
1338
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1340
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1339
            _set_message_status(
1341
            _set_message_status(
1340
                {
1342
                {
Lines 1345-1351 sub _send_message_by_email { Link Here
1345
            );
1347
            );
1346
            return;
1348
            return;
1347
        }
1349
        }
1350
        if ($patron) {
1348
        $to_address = $patron->notice_email_address;
1351
        $to_address = $patron->notice_email_address;
1352
        }
1349
        unless ($to_address) {  
1353
        unless ($to_address) {  
1350
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
1354
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
1351
            # warning too verbose for this more common case?
1355
            # warning too verbose for this more common case?
(-)a/Koha/Patron.pm (-1 / +3 lines)
Lines 1329-1335 sub notice_email_address{ Link Here
1329
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1329
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1330
    # if syspref is set to 'first valid' (value == OFF), look up email address
1330
    # if syspref is set to 'first valid' (value == OFF), look up email address
1331
    if ( $which_address eq 'OFF' ) {
1331
    if ( $which_address eq 'OFF' ) {
1332
        return $self->first_valid_email_address;
1332
        $address = $self->first_valid_email_address;
1333
    } else {
1334
        $address = $self->$which_address || '';
1333
    }
1335
    }
1334
1336
1335
    return $self->$which_address || '';
1337
    return $self->$which_address || '';
(-)a/installer/data/mysql/atomicupdate/bug_12532-RedirectGuaranteeEmail_syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
2
VALUES ('RedirectGuaranteeEmail','0',NULL,'Enable the ability to redirect guarantee email messages to guarantor.','YesNo');
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 552-557 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
552
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
552
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
553
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
553
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
554
('Reference_NFL_Statuses','1|2',NULL,'Contains not for loan statuses considered as available for reference','Free'),
554
('Reference_NFL_Statuses','1|2',NULL,'Contains not for loan statuses considered as available for reference','Free'),
555
('RedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
555
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
556
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
556
('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'),
557
('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'),
557
('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'),
558
('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'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 320-325 Patrons: Link Here
320
               1: Allow
320
               1: Allow
321
               0: "Don't allow"
321
               0: "Don't allow"
322
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
322
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
323
     -
324
         - pref: RedirectGuaranteeEmail
325
           choices:
326
               yes: Enable
327
               no: Disable
328
         - sending emails to both guarantees and their guarantor. This does not affect patrons without guarantors.
323
     -
329
     -
324
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
330
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
325
           choices:
331
           choices:
(-)a/t/db_dependent/Members.t (-1 / +37 lines)
Lines 119-124 C4::Context->clear_syspref_cache(); Link Here
119
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
119
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
120
is ($checkcardnum, "2", "Card number is too long");
120
is ($checkcardnum, "2", "Card number is too long");
121
121
122
# Test notice_email_address
123
# Add Guarantor for testing
124
my $GUARANTOR_EMAIL = "Robert\@email.com";
125
%data = (
126
    cardnumber => "2997924548",
127
    firstname =>  "Robert",
128
    surname => "Tables",
129
    categorycode => $patron_category->{categorycode},
130
    branchcode => $BRANCHCODE,
131
    dateofbirth => '',
132
    dateexpiry => '9999-12-31',
133
    userid => 'bobbytables',
134
    email => $GUARANTOR_EMAIL
135
);
136
137
$member->{guarantorid} = Koha::Patron->new(\%data)->store->borrowernumber;
138
$patron->set($member)->store;
139
140
$member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } );
141
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' );
142
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
143
C4::Context->clear_syspref_cache();
144
145
my $notice_email = $member->notice_email_address;
146
is ($notice_email, $EMAIL, "notice_email_address returns correct value when AutoEmailPrimaryAddress is off");
147
148
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
149
C4::Context->clear_syspref_cache();
150
151
$notice_email = $member->notice_email_address;
152
is ($notice_email, $EMAILPRO, "notice_email_address returns correct value when AutoEmailPrimaryAddress is emailpro");
153
154
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
155
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' );
156
C4::Context->clear_syspref_cache();
157
$notice_email = $member->notice_email_address;
158
is ($notice_email, $EMAIL . ", " . $GUARANTOR_EMAIL, "notice_email_address returns correct value when RedirectGuaranteeEmail is enabled");
122
159
123
# Add a new borrower
160
# Add a new borrower
124
%data = (
161
%data = (
125
- 

Return to bug 12532