X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FItems.pm;h=04cb4174f1fbf07ccd4169b226f086f135eaee7c;hb=refs%2Fheads%2Fffzg-1059-zebra_spine_label;hp=72fdf8ea19a47accf1bac8289a6665902d8d8313;hpb=92ca5a13e57f6254a4f6b504fbd3f68d4709c6a3;p=koha.git diff --git a/C4/Items.pm b/C4/Items.pm index 72fdf8ea19..04cb4174f1 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1629,41 +1629,45 @@ sub GetHiddenItemnumbers { my @resultitems; my $yaml = C4::Context->preference('OpacHiddenItems'); + $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt my $hidingrules; eval { - $hidingrules = YAML::Load($yaml); + $hidingrules = YAML::Load($yaml); }; if ($@) { - warn "Unable to parse OpacHiddenItems syspref : $@"; - return (); - } else { + warn "Unable to parse OpacHiddenItems syspref : $@"; + return (); + } my $dbh = C4::Context->dbh; - # For each item - foreach my $item (@items) { + # For each item + foreach my $item (@items) { - # We check each rule - foreach my $field (keys %$hidingrules) { - my $query = "SELECT $field from items where itemnumber = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($item->{'itemnumber'}); - my ($result) = $sth->fetchrow; + # We check each rule + foreach my $field (keys %$hidingrules) { + my $val; + if (exists $item->{$field}) { + $val = $item->{$field}; + } + else { + my $query = "SELECT $field from items where itemnumber = ?"; + $val = $dbh->selectrow_array($query, undef, $item->{'itemnumber'}); + } + $val = '' unless defined $val; - # If the results matches the values in the yaml file - if (any { $result eq $_ } @{$hidingrules->{$field}}) { + # If the results matches the values in the yaml file + if (any { $val eq $_ } @{$hidingrules->{$field}}) { - # We add the itemnumber to the list - push @resultitems, $item->{'itemnumber'}; + # We add the itemnumber to the list + push @resultitems, $item->{'itemnumber'}; - # If at least one rule matched for an item, no need to test the others - last; - } - } - } - return @resultitems; + # If at least one rule matched for an item, no need to test the others + last; + } + } } - - } + return @resultitems; +} =head3 get_item_authorised_values