From 5c44f8580f402a9a51c25501edaa94a70b0c1800 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 47fed26850..0c402ace66 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1231,6 +1231,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 @@ -1240,7 +1242,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