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

(-)a/Koha/Patron.pm (-4 / +11 lines)
Lines 1616-1627 sub notice_email_address{ Link Here
1616
    my ( $self ) = @_;
1616
    my ( $self ) = @_;
1617
1617
1618
    my $which_address = C4::Context->preference("EmailFieldPrimary");
1618
    my $which_address = C4::Context->preference("EmailFieldPrimary");
1619
    # if syspref is set to 'first valid' (value == OFF), look up email address
1619
    my @addresses;
1620
    if ( $which_address eq 'OFF' ) {
1620
    for my $email_field ( split ",", $which_address ) {
1621
        return $self->first_valid_email_address;
1621
1622
        # if syspref is set to 'first valid' (value == OFF), look up email address
1623
        if ( $email_field eq 'OFF' ) {
1624
            return $self->first_valid_email_address;
1625
        }
1626
1627
        my $email_address = $self->$email_field;
1628
        push @addresses, $email_address if $email_address;
1622
    }
1629
    }
1623
1630
1624
    return $self->$which_address || '';
1631
    return join(",",@addresses);
1625
}
1632
}
1626
1633
1627
=head3 first_valid_email_address
1634
=head3 first_valid_email_address
(-)a/t/db_dependent/Koha/Patron.t (-2 / +4 lines)
Lines 1790-1796 subtest 'notify_library_of_registration()' => sub { Link Here
1790
};
1790
};
1791
1791
1792
subtest 'notice_email_address' => sub {
1792
subtest 'notice_email_address' => sub {
1793
    plan tests => 2;
1793
    plan tests => 3;
1794
    $schema->storage->txn_begin;
1794
    $schema->storage->txn_begin;
1795
1795
1796
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1796
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
Lines 1802-1807 subtest 'notice_email_address' => sub { Link Here
1802
    t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' );
1802
    t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' );
1803
    is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro");
1803
    is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro");
1804
1804
1805
    t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'email,emailpro' );
1806
    is ($patron->notice_email_address, $patron->email.",".$patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is email|emailpro");
1807
1805
    $patron->delete;
1808
    $patron->delete;
1806
    $schema->storage->txn_rollback;
1809
    $schema->storage->txn_rollback;
1807
};
1810
};
1808
- 

Return to bug 12802