Bug 10584 - Hide OPAC biblio details if all items are hidden
authorMark Tompsett <mtompset@hotmail.com>
Fri, 12 Jul 2013 03:13:42 +0000 (23:13 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Sat, 7 Sep 2013 21:12:50 +0000 (21:12 +0000)
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, this is done by setting the biblionumber to 0, which
triggers the same output as if the biblionumber does not exist.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, works as advertised.

opac/opac-detail.pl

index d1f5d91..f06b535 100755 (executable)
@@ -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);
+if (scalar @itemsmatchingbiblionumber >= 1) {
+    my @items2hide = GetHiddenItemnumbers(@itemsmatchingbiblionumber);
+
+    if (scalar @items2hide == scalar @itemsmatchingbiblionumber ) {
+        # 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