From 00976595fcb26ac84f33ff1d5f686e6dff7f69b5 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 10 Sep 2013 16:16:47 -0400 Subject: [PATCH] Bug 10876 - MARC view displays what should be hidden The opac/opac-MARCdetail.pl file is what is viewed when "MARC view" is clicked while viewing a specific search result. Items hidden on opac/opac-detail.pl based on OpacHiddenItems are shown! This should not happen. I believe this bug goes back several versions, not just master. While coding this, a lack of use or require in C4::Items was discovered. See bug 10872. By adding calls to GetItemsInfo and GetHiddenItems, a filter on the items is placed. As this is processing MARC data, GetMarcFromKohaField was used to properly determine what the item number (952$9) is. --- opac/opac-MARCdetail.pl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 2a69244..c967f00 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -52,14 +52,33 @@ use MARC::Record; use C4::Biblio; use C4::Acquisition; use C4::Koha; +use C4::Items; +use List::MoreUtils qw/any/; my $query = new CGI; my $dbh = C4::Context->dbh; my $biblionumber = $query->param('biblionumber'); +if ( ! $biblionumber ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + +my @all_items = GetItemsInfo($biblionumber); +my @items2hide; +if (scalar @all_items >= 1) { + push @items2hide, GetHiddenItemnumbers(@all_items); + + if (scalar @items2hide == scalar @all_items ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; + } +} + my $itemtype = &GetFrameworkCode($biblionumber); my $tagslib = &GetMarcStructure( 0, $itemtype ); +my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$itemtype); my $biblio = GetBiblioData($biblionumber); $biblionumber = $biblio->{biblionumber}; my $record = GetMarcBiblio($biblionumber, 1); @@ -209,7 +228,6 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { $template->param( "tab" . $tabloop . "XX" => \@loop_data ); } - # now, build item tab ! # the main difference is that datas are in lines and not in columns : thus, we build the first, then the values... # loop through each tag @@ -223,6 +241,9 @@ foreach my $field (@fields) { next if ( $field->tag() < 10 ); my @subf = $field->subfields; my %this_row; + next if ( ($field->tag() eq $tag_itemnumber) && + (any { $field->subfield($subtag_itemnumber) eq $_ } + @items2hide) ); # loop through each subfield for my $i ( 0 .. $#subf ) { -- 1.7.9.5