From 1953ea51e9a6bf69be38e9ced186bb5064595f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Olangcay=20Brisebois?= Date: Thu, 14 Feb 2019 12:30:18 -0500 Subject: [PATCH] Bug 12532 - (follow up) clean up --- Koha/Patron.pm | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index e8ea95d..c73b067 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1023,31 +1023,37 @@ Returns the empty string if no email address. =cut sub notice_email_address{ - my ( $self ) = @_; - my $address; - - my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); - # if syspref is set to 'first valid' (value == OFF), look up email address - if ( $which_address eq 'OFF' ) { - $address = $self->first_valid_email_address; - } else { - $address = $self->$which_address || ''; - } - - my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail'); - if ($use_guarantor) { - my $guarantor = $self->guarantor; - if ($guarantor) { - my $guarantor_address = $guarantor->notice_email_address; - if ($address){ - $address .= ', '; - } - $address .= $guarantor_address if $guarantor_address; - } - } - return $address; + my ( $self ) = @_; + my $address; + my $guarantor_address; + + my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); + # if syspref is set to 'first valid' (value == OFF), look up email address + if ( $which_address eq 'OFF' ) { + $address = $self->first_valid_email_address; + } else { + $address = $self->$which_address || ''; + } + + my $use_guarantor = C4::Context->preference('RedirectGuaranteeEmail'); + if ($use_guarantor) { + my $guarantor = $self->guarantor; + if ($guarantor) { + if ( $which_address eq 'OFF' ) { + $guarantor_address = $guarantor->first_valid_email_address; + } else { + $guarantor_address = $guarantor->$which_address || ''; + } + if ($address){ + $address .= ', '; + } + $address .= $guarantor_address if $guarantor_address; + } + } + return $address; } + =head3 first_valid_email_address my $first_valid_email_address = $patron->first_valid_email_address -- 2.7.4