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.

Arrays used to represent all the items were relocated and used,
added if they didn't exist. Arrays representing the hidden
items were relocated and used if they existed, added if they
didn't exist.

Upon debugging the opac-MARCdetail.pl modification, it was
discovered the reason getHiddenItems was failing was because
'use YAML qw/Load/;' was not mentioned in C4::Items, and other
libraries were triggering the loading of YAML to compensate
for opac-detail.pl and opac-ISBDdetail.pl files.

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Mark Tompsett 2013-07-11 23:13:42 -04:00 committed by Galen Charlton
parent dcbe50cde8
commit e191bb02bf
3 changed files with 35 additions and 13 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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);
my @all_items = GetItemsInfo($biblionumber);
my @hiddenitems;
if (scalar @all_items >= 1) {
push @hiddenitems, GetHiddenItemnumbers(@all_items);
if (scalar @items2hide == scalar @itemsmatchingbiblionumber ) {
# biblionumber=0 effectively hides the biblio record
# since there is no such biblionumber.
$biblionumber = 0;
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;