From 8b493d6b86c849a6878657bd102022f87f9288d9 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 By counting the items associated with the biblionumber, and comparing that against the number of items which would be hidden, it is possible to determine if all items are hidden. If there are items and they are all hidden, the biblio needs to be hidden, the biblionumber is changed to 0, which triggers the same output as if the biblionumber does not exist. --- opac/opac-detail.pl | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 9d0851f..4921072 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -70,9 +70,32 @@ 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 $dbh = C4::Context->dbh; +my $sth = $dbh->prepare("SELECT * FROM items WHERE biblionumber=?;"); +$sth->execute($biblionumber); + +my @itemsmatchingbiblionumber; +my $matchingitem = $sth->fetchrow_hashref; +while ($matchingitem) { + push @itemsmatchingbiblionumber,$matchingitem; + $matchingitem = $sth->fetchrow_hashref; +} + +my @items2hide; +if ($#itemsmatchingbiblionumber >= 0) { + @items2hide =GetHiddenItemnumbers(@itemsmatchingbiblionumber); +} + +# only hide if there are hidden items. $#items2hide=-1 for no items. +if ($#items2hide==$#itemsmatchingbiblionumber && $#items2hide>=0) { + # biblionumber=0 effectively hides the biblio record + # since there is no such biblionumber. + $biblionumber = 0; +} + my $record = GetMarcBiblio($biblionumber); if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early @@ -628,7 +651,6 @@ if (scalar(@itemloop) >= 50 && !$viewallitems) { } ## get notes and subjects from MARC record -my $dbh = C4::Context->dbh; my $marcnotesarray = GetMarcNotes ($record,$marcflavour); my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour); -- 1.7.9.5