From 01b578de1519c4e1251a267e3a2908d2b02615d8 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 18 Oct 2022 16:44:39 +0100 Subject: [PATCH] Bug 31224: Support 'interface' on metadata_record We replace the 'opac' boolean with an 'interface' param here to allow for ViewPolicy filtering depending on 'opac', 'intranet' or 'nothing' being passed. Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- Koha/Biblio.pm | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index ada72137ff..7badd607c1 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -134,10 +134,12 @@ sub record_schema { my $record = $biblio->metadata_record( { - [ embed_items => 1|0, - opac => 1|0, - patron => $patron, - expand_coded_fields => 1|0 ] + [ + embed_items => 1 | 0, + interface => 'opac' | 'intranet', + patron => $patron, + expand_coded_fields => 1 | 0 + ] } ); @@ -153,32 +155,26 @@ sub metadata_record { my $record = $self->metadata->record; - if ( $params->{embed_items} or $params->{opac} ) { + if ( $params->{embed_items} or $params->{interface} ) { # There's need for a RecordProcessor, let's do it! my @filters; my $options = { - interface => 'opac', + interface => $params->{interface}, frameworkcode => $self->frameworkcode, }; if ( $params->{embed_items} ) { push @filters, 'EmbedItems'; - if ( $params->{opac} ) { + if ( $params->{interface} eq 'opac' ) { $options->{items} = $self->items->filter_by_visible_in_opac( - { - ( - $params->{patron} ? ( patron => $params->{patron} ) : () - ) - } - ); - } - else { + { ( $params->{patron} ? ( patron => $params->{patron} ) : () ) } ); + } else { $options->{items} = $self->items; } } - if ( $params->{opac} ) { + if ( $params->{interface} ) { push @filters, 'ViewPolicy'; } -- 2.39.5