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

(-)a/C4/Letters.pm (-1 / +3 lines)
Lines 1308-1314 sub _send_message_by_email { Link Here
1308
1308
1309
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1309
    my $patron = Koha::Patrons->find( $message->{borrowernumber} );
1310
    my $to_address = $message->{'to_address'};
1310
    my $to_address = $message->{'to_address'};
1311
    unless ($to_address) {
1311
1312
    my $use_garantor = C4::Context->preference('RedirectGuaranteeEmail');
1313
    if($use_garantor || !$to_address) {
1312
        unless ($patron) {
1314
        unless ($patron) {
1313
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1315
            warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
1314
            _set_message_status( { message_id => $message->{'message_id'},
1316
            _set_message_status( { message_id => $message->{'message_id'},
(-)a/Koha/Patron.pm (-2 / +16 lines)
Lines 631-644 Returns the empty string if no email address. Link Here
631
631
632
sub notice_email_address{
632
sub notice_email_address{
633
    my ( $self ) = @_;
633
    my ( $self ) = @_;
634
    my $address;
634
635
635
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
636
    my $which_address = C4::Context->preference("AutoEmailPrimaryAddress");
636
    # if syspref is set to 'first valid' (value == OFF), look up email address
637
    # if syspref is set to 'first valid' (value == OFF), look up email address
637
    if ( $which_address eq 'OFF' ) {
638
    if ( $which_address eq 'OFF' ) {
638
        return $self->first_valid_email_address;
639
	$address = $self->first_valid_email_address;
640
    } else {
641
	$address = $self->$which_address || '';
639
    }
642
    }
640
643
641
    return $self->$which_address || '';
644
    my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail');
645
    if ($use_guarantor) {
646
	my $guarantor = $self->guarantor;
647
	if ($guarantor) {
648
	    my $guarantor_address = $guarantor->notice_email_address;
649
	    if ($address){
650
		$address .= ', ';
651
	    }
652
	    $address .=  $guarantor_address if $guarantor_address;
653
	}
654
    }
655
    return $address;
642
}
656
}
643
657
644
=head3 first_valid_email_address
658
=head3 first_valid_email_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/sysprefs.sql (+1 lines)
Lines 447-452 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
447
('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'),
447
('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'),
448
('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'),
448
('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'),
449
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
449
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
450
('RedirectGuaranteeEmail', '0', NULL, 'Enable the ability to redirect guarantee email messages to guarantor.', 'YesNo'),
450
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
451
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
451
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
452
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
452
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
453
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 205-210 Patrons: Link Here
205
         - pref: FailedLoginAttempts
205
         - pref: FailedLoginAttempts
206
           class: integer
206
           class: integer
207
         - failed login attempts.
207
         - failed login attempts.
208
     -
209
         - pref: RedirectGuaranteeEmail
210
           choices:
211
               yes: Enable
212
               no: Disable
213
         - sending emails to both guarantees and their guarantor. This does not affect patrons without guarantors.
208
    "Norwegian patron database":
214
    "Norwegian patron database":
209
     -
215
     -
210
         - pref: NorwegianPatronDBEnable
216
         - pref: NorwegianPatronDBEnable
(-)a/t/db_dependent/Members.t (-2 / +37 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 62;
20
use Test::More tests => 65;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 138-143 C4::Context->clear_syspref_cache(); Link Here
138
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
138
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
139
is ($checkcardnum, "2", "Card number is too long");
139
is ($checkcardnum, "2", "Card number is too long");
140
140
141
# Test notice_email_address
142
# Add Guarantor for testing
143
my $GUARANTOR_EMAIL = "Robert\@email.com";
144
%data = (
145
    cardnumber => "2997924548",
146
    firstname =>  "Robert",
147
    surname => "Tables",
148
    categorycode => $patron_category->{categorycode},
149
    branchcode => $BRANCHCODE,
150
    dateofbirth => '',
151
    dateexpiry => '9999-12-31',
152
    userid => 'bobbytables',
153
    email => $GUARANTOR_EMAIL
154
);
155
$member->{guarantorid} = AddMember( %data );
156
ModMember( %$member );
157
158
$member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } );
159
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' );
160
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
161
C4::Context->clear_syspref_cache();
162
163
my $notice_email = $member->notice_email_address;
164
is ($notice_email, $EMAIL, "notice_email_address returns correct value when AutoEmailPrimaryAddress is off");
165
166
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
167
C4::Context->clear_syspref_cache();
168
169
$notice_email = $member->notice_email_address;
170
is ($notice_email, $EMAILPRO, "notice_email_address returns correct value when AutoEmailPrimaryAddress is emailpro");
171
172
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
173
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' );
174
C4::Context->clear_syspref_cache();
175
$notice_email = $member->notice_email_address;
176
is ($notice_email, $EMAIL . ", " . $GUARANTOR_EMAIL, "notice_email_address returns correct value when RedirectGuaranteeEmail is enabled");
141
177
142
# Check_Userid tests
178
# Check_Userid tests
143
%data = (
179
%data = (
144
- 

Return to bug 12532