@@ -, +, @@ --- C4/XSLT.pm | 25 ++++++++++++++++--------- opac/opac-shelves.pl | 15 +++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -297,14 +297,21 @@ Is only used in this module currently. sub buildKohaItemsNamespace { my ($biblionumber, $hidden_items) = @_; - $hidden_items ||= []; - my @items = Koha::Items->search( - { - 'me.biblionumber' => $biblionumber, - 'me.itemnumber' => { not_in => $hidden_items } - }, - { prefetch => [ 'branchtransfers', 'reserves' ] } - ); + if ( ref $hidden_items eq 'Koha::Items' ) { + $items = $items->search( + {}, + { prefetch => [ 'branchtransfers', 'reserves' ] } + ); + } else { + $hidden_items ||= []; + + $items = Koha::Items->search( + { + 'me.biblionumber' => $biblionumber, + 'me.itemnumber' => { not_in => $hidden_items } + { prefetch => [ 'branchtransfers', 'reserves' ] } + ); + } my $shelflocations = { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.location' } ) }; @@ -318,7 +325,7 @@ sub buildKohaItemsNamespace { my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } ); my $ref_status = C4::Context->preference('Reference_NFL_Statuses') || '1|2'; - for my $item (@items) { + while ( my $item = $items->next ) { my $status; my $substatus = ''; --- a/opac/opac-shelves.pl +++ a/opac/opac-shelves.pl @@ -346,23 +346,18 @@ if ( $op eq 'view' ) { }); } - my @items; - my $items = $biblio->items; + my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron }); my $allow_onshelf_holds; - my @hidden_items; while ( my $item = $items->next ) { - if ( $item->hidden_in_opac({rules => C4::Context->yaml_preference('OpacHiddenItems')} ) ) { - push @hidden_items, $item->itemnumber; - next; - } + # This method must take a Koha::Items rs $allow_onshelf_holds ||= Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); - push @items, $item; # This is for non-xslt only } + $this_item->{allow_onshelf_holds} = $allow_onshelf_holds; - $this_item->{'ITEM_RESULTS'} = \@items; + $this_item->{'ITEM_RESULTS'} = $items; if ($xslfile) { my $variables = { @@ -371,7 +366,7 @@ if ( $op eq 'view' ) { $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTListsDisplay", 1, - \@hidden_items, $sysxml, + $items, $sysxml, $xslfile, $lang, $variables ); --