Bug 18989: Allow displaying biblios with all items hidden by OpacHiddenItems

Bug 10584 made Koha hide biblios for which all items match some criteria (in OpacHiddenItems) so they are hidden.
Add syspref OpacHiddenItemsHidesRecord controlling this behaviour.

Test plan :
1)
1.1) Create some biblio records with one item having damaged=1
1.2) Define system preference OpacHiddenItems = damaged: 1
2)
2.1) Set system preference OpacHiddenItemsHidesRecord to 'don't hide'
2.2) At OPAC : perform a search showing those records and some more
2.3) Check you see the all the records
2.4) For a record with hidden item check you don't get HTTP 404 for : normal view, ISBD view, MARC view
2.5) Check you can had tags on this record
2.6) Add record to basket, check you see it in basket
3)
3.1) Set system preference OpacHiddenItemsHidesRecord to 'hide'
3.2) At OPAC : perform a search showing those records and some more
3.3) Check you don't see the records with hidden item
3.4) For a record with hidden item check you get HTTP 404 for : normal view, ISBD view, MARC view
3.5) Show basket, check you see the records with hidden item

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Fridolin Somers 2020-09-04 14:33:12 +02:00 committed by Jonathan Druart
parent 21658717de
commit 2a0be09d63
8 changed files with 14 additions and 6 deletions

View File

@ -1992,7 +1992,7 @@ sub searchResults {
} # notforloan, item level and biblioitem level
# if all items are hidden, do not show the record
if ($items_count > 0 && $hideatopac_count == $items_count) {
if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $items_count > 0 && $hideatopac_count == $items_count) {
next;
}

View File

@ -412,6 +412,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'),
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See http://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'),
('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea'),
('OpacHiddenItemsHidesRecord','1','','Hide biblio record when all its items are hidden because of OpacHiddenItems','YesNo'),
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
('OPACHoldingsDefaultSortField','first_column','first_column|homebranch|holdingbranch','Default sort field for the holdings table at the OPAC','choice'),
('OPACHoldsHistory','0','','If ON, enables display of Patron Holds History in OPAC','YesNo'),

View File

@ -655,6 +655,13 @@ OPAC:
-
- 'List of patron categories, separated by |, that can see items otherwise hidden by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OpacHiddenItems">OpacHiddenItems</a>:'
- pref: OpacHiddenItemsExceptions
-
- pref: OpacHiddenItemsHidesRecord
default: 1
choices:
no: "Don't hide"
yes: Hide
- "biblio record when all its items are hidden by <code>OpacHiddenItems</code>."
-
- pref: OpacAllowPublicListCreation
default: 1

View File

@ -84,7 +84,7 @@ my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
unless ( $patron and $patron->category->override_hidden_items ) {
# only skip this check if there's a logged in user
# and its category overrides OpacHiddenItems
if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) {
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
exit;
}

View File

@ -108,7 +108,7 @@ my $framework = $biblio ? $biblio->frameworkcode : q{};
my $tagslib = &GetMarcStructure( 0, $framework );
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField( 'items.itemnumber' );
my @nonhiddenitems = $record->field($tag_itemnumber);
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @nonhiddenitems == 0 ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl");
exit;
}

View File

@ -96,7 +96,7 @@ foreach my $biblionumber ( @bibs ) {
my @hidden_items = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
# If every item is hidden, then the biblio should be hidden too.
next if (scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items);
next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items);
# copy the visible ones into the items array.
my @items;

View File

@ -106,7 +106,7 @@ if ( scalar @all_items >= 1 ) {
push @hiddenitems,
GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } );
if (scalar @hiddenitems == scalar @all_items ) {
if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @hiddenitems == scalar @all_items ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
exit;
}

View File

@ -270,7 +270,7 @@ if ($loggedinuser) {
borcat => $borcat });
$hidden_items = \@hidden_itemnumbers;
}
next if ( $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $should_hide && scalar @all_items == scalar @hidden_itemnumbers );
$tag->{title} = $biblio->title;
$tag->{subtitle} = $biblio->subtitle;
$tag->{medium} = $biblio->medium;