diff --git a/C4/Search.pm b/C4/Search.pm
index a4fafd1e01..0db460a808 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -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;
}
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index 2ae86ad3d2..0a86168ee0 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -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'),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
index c1c211d7a4..d9a9023543 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -655,6 +655,13 @@ OPAC:
-
- 'List of patron categories, separated by |, that can see items otherwise hidden by OpacHiddenItems:'
- pref: OpacHiddenItemsExceptions
+ -
+ - pref: OpacHiddenItemsHidesRecord
+ default: 1
+ choices:
+ no: "Don't hide"
+ yes: Hide
+ - "biblio record when all its items are hidden by OpacHiddenItems."
-
- pref: OpacAllowPublicListCreation
default: 1
diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl
index d1076e76ef..e4b54f068d 100755
--- a/opac/opac-ISBDdetail.pl
+++ b/opac/opac-ISBDdetail.pl
@@ -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;
}
diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl
index 39cb10eecf..3211f61df3 100755
--- a/opac/opac-MARCdetail.pl
+++ b/opac/opac-MARCdetail.pl
@@ -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;
}
diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl
index b746abde67..cc3d975355 100755
--- a/opac/opac-basket.pl
+++ b/opac/opac-basket.pl
@@ -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;
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index e4e4a8341d..26d3ef0151 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -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;
}
diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl
index be3c3d5886..1f15149cb2 100755
--- a/opac/opac-tags.pl
+++ b/opac/opac-tags.pl
@@ -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;