Bug 29046: Use EmailFieldPrecedence in first_valid_email_address

This patch update the Koha::Patron->first_valid_email_address method to
use the newly defined EmailFieldPrecedence preference.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-03-10 10:47:51 +00:00 committed by Tomas Cohen Arazi
parent ca4283c585
commit fb7bf8f95e
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -1436,7 +1436,16 @@ Returns the empty string if the borrower has no email addresses.
sub first_valid_email_address {
my ($self) = @_;
return $self->email() || $self->emailpro() || $self->B_email() || q{};
my $email = q{};
my @fields = split /\s*\|\s*/,
C4::Context->preference('EmailFieldPrecedence');
for my $field (@fields) {
$email = $self->$field;
last if ( $email ne q{} );
}
return $email;
}
=head3 get_club_enrollments