From 46020284de29408ff32339295c7cab9fe61e2ae3 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Thu, 14 Mar 2019 13:23:19 +0000 Subject: [PATCH] Bug 8995: (follow-up) Tak system preference item-level_itypes into account Signed-off-by: Magnus Enger Tested with all 9 current patches. Works as advertised, including OPACURLOpenInNewWindow. If a record has no items, no OpenURL link is displayed. All the suggested tests pass. I did not test with XSLT turned off. --- C4/XSLT.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index b18ccda9a1..d7aee656ce 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -247,11 +247,18 @@ sub XSLTParse4Display { $variables ||= {}; if (C4::Context->preference('OPACShowOpenURL')) { - my $biblio_object = Koha::Biblios->find($biblionumber); - my $biblio = $biblio_object->biblioitem->unblessed; + my @biblio_itemtypes; + my $biblio = Koha::Biblios->find($biblionumber); + if (C4::Context->preference('item-level_itypes')) { + @biblio_itemtypes = $biblio->items->get_column("itype"); + } else { + push @biblio_itemtypes, $biblio->biblioitem->itemtype; + } my @itypes = split( /\s/, C4::Context->preference('OPACOpenURLItemTypes') ); - if (grep /^$biblio->{itemtype}$/, @itypes) { - $variables->{OpenURLResolverURL} = $biblio_object->get_openurl; + my %original = (); + map { $original{$_} = 1 } @biblio_itemtypes; + if ( grep { $original{$_} } @itypes ) { + $variables->{OpenURLResolverURL} = $biblio->get_openurl; } } my $varxml = "\n"; -- 2.11.0