@@ -, +, @@ (See 942c in case of MARC21.) Log out. Search for B1 and B2, verify that only B1 has AR link. Log in as P1. Verify that only B1 has AR link. Log in as P2. Verify that no biblio has AR link. Log out. Search for B1 and B2, verify that both have AR links. Log in as P1. Verify that only B1 has AR link. Log in as P2. Verify that only B2 has AR link. --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 2 +- opac/opac-search.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -509,7 +509,7 @@ [% END # IF RequestOnOpac %] [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %] - [% IF Koha.Preference('ArticleRequests') %] + [% IF SEARCH_RESULT.artreqpossible %] Request article [% END %] [% END %] --- a/opac/opac-search.pl +++ a/opac/opac-search.pl @@ -56,6 +56,7 @@ use Koha::ItemTypes; use Koha::Ratings; use Koha::Virtualshelves; use Koha::Library::Groups; +use Koha::Patrons; use POSIX qw(ceil floor strftime); use URI::Escape; @@ -644,6 +645,12 @@ for (my $i=0;$i<@servers;$i++) { } $hits = 0 unless @newresults; + my $categorycode; # needed for may_article_request + if( $borrowernumber && C4::Context->preference('ArticleRequests') ) { + my $patron = Koha::Patrons->find( $borrowernumber ); + $categorycode = $patron ? $patron->categorycode : undef; + } + foreach my $res (@newresults) { # must define a value for size if not present in DB @@ -699,6 +706,12 @@ for (my $i=0;$i<@servers;$i++) { $res->{ratings} = $ratings; $res->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef; } + + # BZ17530: 'Intelligent' guess if result can be article requested + $res->{artreqpossible} = Koha::Biblio->may_article_request({ + categorycode => $categorycode, + itemtype => $res->{itemtype}, + }); } if ($results_hashref->{$server}->{"hits"}){ --