From 801cace195429b0c682468a4ea29bfd7bcc0a5ec Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 22 Jul 2022 16:46:51 -0300 Subject: [PATCH] Bug 23247: Use EmbedItems in opac-MARCdetail.pl This patch uses the EmbedItems processor to add the items to the MARC record. To test: - Find a known record, go to the OPAC MARC page of it. - Play with several options in OpacHiddenItems, refreshing it - Play with OpacHiddenItemsExceptions as well => SUCCESS: Things work as expected - Apply this patch - Repeate the tests above => SUCCESS: Things work as expected! - Sign off :-D Seems to work as advertised. Signed-off-by: Tomas Cohen Arazi Signed-off-by: LMSCloudPaulD Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- opac/opac-MARCdetail.pl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index c902f849c4..f55d6bf5ef 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -92,13 +92,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $patron = Koha::Patrons->find($loggedinuser); my $biblio = Koha::Biblios->find($biblionumber); -my $record = $biblio->metadata->record( - { - embed_items => 1, - opac => 1, - patron => $patron, - } -); +my $record = $biblio->metadata->record; + if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); exit; @@ -113,14 +108,16 @@ unless ( $patron and $patron->category->override_hidden_items ) { } } +my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron }); my $framework = $biblio ? $biblio->frameworkcode : q{}; my $tagslib = &GetMarcStructure( 0, $framework ); my $record_processor = Koha::RecordProcessor->new({ - filters => 'ViewPolicy', + filters => [ 'EmbedItems', 'ViewPolicy' ], options => { - interface => 'opac', - frameworkcode => $framework + interface => 'opac', + frameworkcode => $framework, + items => [ $items->as_list ], } }); $record_processor->process($record); @@ -140,7 +137,7 @@ $template->param( $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; my $allow_onshelf_holds; -my $items = $biblio->items; +$items->reset; while ( my $item = $items->next ) { $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) -- 2.39.5