From 3a03d7d777fc79528fbd6a491fec53d24d3647b3 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Wed, 21 Jul 2021 16:32:36 +0200 Subject: [PATCH] Use patron object instead of userenv https://bugs.koha-community.org/show_bug.cgi?id=27859 --- catalogue/search.pl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index fb565a9dd9..f9fba25bf3 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -550,23 +550,20 @@ my $export_user_email = undef; if ($template_name eq 'catalogue/results.tt' && $export && $preferred_format && C4::Context->preference('SearchEngine') eq 'Elasticsearch') { - my $uid; - my $userenv = C4::Context->userenv; - if ($userenv) { - $uid = $userenv->{number}; - if ($userenv->{emailaddress}) { - $export_user_email = $userenv->{emailaddress}; + my $patron = Koha::Patrons->find( $borrowernumber ); + + if ($patron) { + if ($patron->email) { + $export_user_email = $patron->email; } else { die "Unable to fetch user email"; } } else { - die "Unable to fetch userenv"; + die "Unable to fetch user"; } - my $patron = Koha::Patrons->find( $borrowernumber ); - if (!($patron && $patron->has_permission({ tools => 'export_catalog' }))) { die "Missing permission \"export_catalog\" required for exporting search results"; } @@ -647,7 +644,7 @@ if ($template_name eq 'catalogue/results.tt' && $export && $preferred_format && filename => $filename, dir => $category, filesize => $size, - owner => $uid, + owner => $borrowernumber, uploadcategorycode => 'search_marc_export', public => 0, permanent => 1, -- 2.20.1