From 076ea9818e73eee49f4c0d7ab41ebf13eb5e32a4 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 11 Jul 2013 23:13:42 -0400 Subject: [PATCH] Bug 10584 - Hide OPAC biblio details if all items are hidden If there are items for a given biblio number, and they are all hidden, then biblio needs to be hidden. If the biblio needs to be hidden, it immediately redirects to a 404.pl page, just as if the biblionumber does not exist. --- opac/opac-detail.pl | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index d1f5d91..e235435 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -70,9 +70,20 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $biblionumber = $query->param('biblionumber') || $query->param('bib'); +my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; $biblionumber = int($biblionumber); +my @itemsmatchingbiblionumber = GetItemsInfo($biblionumber); +my @hiddenitems; +if (scalar @itemsmatchingbiblionumber >= 1) { + push @hiddenitems, GetHiddenItemnumbers(@itemsmatchingbiblionumber); + + if (scalar @hiddenitems == scalar @itemsmatchingbiblionumber ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early + exit; + } +} + my $record = GetMarcBiblio($biblionumber); if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early @@ -397,8 +408,10 @@ $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") ); +# FIXME -- Perhaps this 2002 comment no longer applies? +# Bug 10584 just changed the line following it. # change back when ive fixed request.pl -my @all_items = GetItemsInfo( $biblionumber ); +my @all_items = @itemsmatchingbiblionumber; # adding items linked via host biblios @@ -421,9 +434,6 @@ foreach my $hostfield ( $record->field($analyticfield)) { my @items; -# Getting items to be hidden -my @hiddenitems = GetHiddenItemnumbers(@all_items); - # Are there items to hide? my $hideitems; $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0; -- 1.7.9.5