@@ -, +, @@
OpacHiddenRecordMessage system preferences
biblionumber: [303]
---
installer/data/mysql/mandatory/sysprefs.sql | 2 ++
.../intranet-tmpl/prog/en/modules/admin/preferences/opac.pref | 9 +++++++++
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt | 10 ++++++++--
opac/opac-blocked.pl | 4 +++-
opac/opac-detail.pl | 6 +++++-
5 files changed, 27 insertions(+), 4 deletions(-)
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ a/installer/data/mysql/mandatory/sysprefs.sql
@@ -413,6 +413,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('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'),
+('OpacHiddenRecordRedirect','0','Redirect the opac detail page for records hidden by OpacHiddenItems to an explanatory page (otherwise redirect to 404 error page)','','YesNo'),
+('OpacHiddenRecordMessage','','Display this message on the redirect page for hidden biblios','70|10','Textarea'),
('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'),
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -662,6 +662,15 @@ OPAC:
0: "Don't hide"
1: Hide
- "the bibliographic record when all its items are hidden by OpacHiddenItems."
+ -
Redirect the opac detail page for hidden records to
+ - pref: OpacHiddenRecordRedirect
+ choices:
+ 1: "an explanatory page ('This record is blocked')."
+ 0: "the 404 error page ('Not found')."
+ - "
Display the following message on the redirect page for suppressed bibliographic records:"
+ - pref: OpacHiddenRecordMessage
+ type: textarea
+ class: code
-
- pref: OpacAllowPublicListCreation
default: 1
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt
@@ -1,4 +1,5 @@
[% USE raw %]
+[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
Record blocked ›
@@ -31,9 +32,14 @@
Blocked
You are not authorized to view this record.
- [% IF ( OpacSuppressionMessage ) %]
+ [% IF hidden %]
+ [% SET OpacBlockedMessage = Koha.Preference("OpacHiddenRecordMessage") %]
+ [% ELSE %]
+ [% SET OpacBlockedMessage = Koha.Preference("OpacSuppressionMessage") %]
+ [% END %]
+ [% IF ( OpacBlockedMessage ) %]
- [% OpacSuppressionMessage | $raw %]
+ [% OpacBlockedMessage | $raw %]
[% END %]
--- a/opac/opac-blocked.pl
+++ a/opac/opac-blocked.pl
@@ -33,6 +33,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
-$template->param ( OpacSuppressionMessage => C4::Context->preference('OpacSuppressionMessage'));
+if ( $query->param('hidden') ) {
+ $template->param( hidden => 1 );
+}
output_with_http_headers $query, $cookie, $template->output, 'html';
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -103,7 +103,11 @@ 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 => C4::Context->yaml_preference('OpacHiddenItems') }) ) {
- print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
+ if ( C4::Context->preference("OpacHiddenRecordRedirect") ) {
+ print $query->redirect("/cgi-bin/koha/opac-blocked.pl?hidden=1");
+ } else {
+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
+ }
exit;
}
if ( scalar @all_items >= 1 ) {
--