From 8b12d5ecffa082edc53409a49ede06e9937ff8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Olangcay=20Brisebois?= Date: Wed, 17 Apr 2019 11:50:48 -0400 Subject: [PATCH] Bug 12532 - (follow-up) clean up --- Koha/Patron.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) mode change 100644 => 100755 Koha/Patron.pm diff --git a/Koha/Patron.pm b/Koha/Patron.pm old mode 100644 new mode 100755 index 2899062dd0..d22f9637fe --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1325,6 +1325,8 @@ Returns the empty string if no email address. sub notice_email_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 @@ -1334,7 +1336,22 @@ sub notice_email_address{ $address = $self->$which_address || ''; } - return $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 -- 2.25.1