@@ -, +, @@ --- opac/opac-ISBDdetail.pl | 12 +++++++++++- opac/opac-MARCdetail.pl | 17 +++++++++++++++++ opac/opac-detail.pl | 21 ++++++++------------- 3 files changed, 36 insertions(+), 14 deletions(-) --- a/opac/opac-ISBDdetail.pl +++ a/opac/opac-ISBDdetail.pl @@ -84,6 +84,17 @@ $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHo $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); my $marcflavour = C4::Context->preference("marcflavour"); + +my @items = GetItemsInfo($biblionumber); +if (scalar @items >= 1) { + my @hiddenitems = GetHiddenItemnumbers(@items); + + if (scalar @hiddenitems == scalar @items ) { + 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"); @@ -138,7 +149,6 @@ $template->param( my $norequests = 1; my $res = GetISBDView($biblionumber, "opac"); -my @items = GetItemsInfo( $biblionumber ); my $itemtypes = GetItemTypes(); for my $itm (@items) { --- a/opac/opac-MARCdetail.pl +++ a/opac/opac-MARCdetail.pl @@ -50,6 +50,7 @@ use C4::Output; use CGI; use MARC::Record; use C4::Biblio; +use C4::Items; use C4::Acquisition; use C4::Koha; @@ -58,6 +59,22 @@ 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 $biblio = GetBiblioData($biblionumber); --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -73,14 +73,14 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( 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 @all_items = GetItemsInfo($biblionumber); +my @hiddenitems; +if (scalar @all_items >= 1) { + push @hiddenitems, GetHiddenItemnumbers(@all_items); + + if (scalar @hiddenitems == scalar @all_items ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early + exit; } } @@ -408,8 +408,6 @@ $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); $template->param('OPACShowBarcode' => C4::Context->preference("OPACShowBarcode") ); -# change back when ive fixed request.pl -my @all_items = GetItemsInfo( $biblionumber ); # adding items linked via host biblios @@ -432,9 +430,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; --