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

(-)a/C4/Letters.pm (-2 / +6 lines)
Lines 1319-1332 sub _send_message_by_email { Link Here
1319
1319
1320
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1320
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1321
    my $to_address = $message->{'to_address'};
1321
    my $to_address = $message->{'to_address'};
1322
    unless ($to_address) {
1322
1323
        unless ($patron) {
1323
    my $use_garantor = C4::Context->preference('RedirectGuaranteeEmail');
1324
    if($use_garantor || !$to_address) {
1325
        unless ($patron or $to_address) {
1324
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1326
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1325
            _set_message_status( { message_id => $message->{'message_id'},
1327
            _set_message_status( { message_id => $message->{'message_id'},
1326
                                   status     => 'failed' } );
1328
                                   status     => 'failed' } );
1327
            return;
1329
            return;
1328
        }
1330
        }
1331
        if ($patron) {
1329
        $to_address = $patron->notice_email_address;
1332
        $to_address = $patron->notice_email_address;
1333
        }
1330
        unless ($to_address) {  
1334
        unless ($to_address) {  
1331
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
1335
            # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})";
1332
            # warning too verbose for this more common case?
1336
            # warning too verbose for this more common case?
(-)a/Koha/Patron.pm (-1 / +3 lines)
Lines 1235-1241 sub notice_email_address{ Link Here
1235
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1235
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
1236
    # if syspref is set to 'first valid' (value == OFF), look up email address
1236
    # if syspref is set to 'first valid' (value == OFF), look up email address
1237
    if ( $which_address eq 'OFF' ) {
1237
    if ( $which_address eq 'OFF' ) {
1238
        return $self->first_valid_email_address;
1238
        $address = $self->first_valid_email_address;
1239
    } else {
1240
        $address = $self->$which_address || '';
1239
    }
1241
    }
1240
1242
1241
    return $self->$which_address || '';
1243
    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 541-546 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
541
('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'),
541
('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'),
542
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
542
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
543
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
543
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
544
('RedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
544
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
545
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
545
('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'),
546
('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'),
546
('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'),
547
('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 298-303 Patrons: Link Here
298
               yes: Allow
298
               yes: Allow
299
               no: "Don't allow"
299
               no: "Don't allow"
300
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
300
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
301
     -
302
         - pref: RedirectGuaranteeEmail
303
           choices:
304
               yes: Enable
305
               no: Disable
306
         - sending emails to both guarantees and their guarantor. This does not affect patrons without guarantors.
301
     -
307
     -
302
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
308
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
303
           choices:
309
           choices:
(-)a/t/db_dependent/Members.t (-2 / +38 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 48;
20
use Test::More tests => 50;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
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