@@ -, +, @@ --- C4/Items.pm | 1 + opac/opac-ISBDdetail.pl | 12 +++++++++++- opac/opac-MARCdetail.pl | 15 +++++++++++++++ opac/opac-detail.pl | 18 ++++++++++++------ 4 files changed, 39 insertions(+), 7 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -30,6 +30,7 @@ use MARC::Record; use C4::ClassSource; use C4::Log; use List::MoreUtils qw/any/; +use YAML qw/Load/; use Data::Dumper; # used as part of logging item record changes, not just for # debugging; so please don't remove this --- 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; @@ -62,6 +63,20 @@ my $itemtype = &GetFrameworkCode($biblionumber); my $tagslib = &GetMarcStructure( 0, $itemtype ); my $biblio = GetBiblioData($biblionumber); $biblionumber = $biblio->{biblionumber}; + +print STDERR "biblionumber: $biblionumber\n"; +my @all_items = GetItemsInfo($biblionumber); +if (scalar @all_items >= 1) { + my @hiddenitems = GetHiddenItemnumbers(@all_items); + print STDERR "Scalar GHI: " . (scalar @hiddenitems) . "\n"; + + if (scalar @hiddenitems == scalar @all_items ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early + exit; + } +} +print STDERR "Scalar AI: " . (scalar @all_items) . "\n"; + my $record = GetMarcBiblio($biblionumber, 1); if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); --- a/opac/opac-detail.pl +++ a/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 @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; + } +} + my $record = GetMarcBiblio($biblionumber); if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early @@ -397,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 @@ -421,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; --