Bugzilla – Attachment 175807 Details for
Bug 27734
OpacHiddenItems produces a 404 from borrower holds list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27734: Add OpacHiddenRecordRedirect and OpacHiddenRecordMessage system preferences
Bug-27734-Add-OpacHiddenRecordRedirect-and-OpacHid.patch (text/plain), 7.78 KB, created by
Roman Dolny
on 2024-12-19 22:24:44 UTC
(
hide
)
Description:
Bug 27734: Add OpacHiddenRecordRedirect and OpacHiddenRecordMessage system preferences
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2024-12-19 22:24:44 UTC
Size:
7.78 KB
patch
obsolete
>From 21f936be4d35d0a6ea26357eb8e816c44e3bc7c8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 9 Jun 2021 19:29:19 +0000 >Subject: [PATCH] Bug 27734: Add OpacHiddenRecordRedirect and > OpacHiddenRecordMessage system preferences > >This patch adds options analogous to OpacSuppressionRedirect and OpacSuppressionMessage for OpacHiddtenItems > >Test plan: >1 - Apply patch >2 - Test OpacSupressionsRedirect and OpacSuppressionMessage prefs to ensure they work as before >3 - Enable OpacHiddenItemsHidesRecord and hide a biblio using OpacHiddenItems: > biblionumber: [303] >3 - Test OpacHiddenRecordRedirect and OpacHiddenRecordMessage to ensure they work as expected >4 - Hit the link: http://localhost:8080/cgi-bin/koha/opac-detail.pl?biblionumber=303 >5 - When OpacHiddenRecordRedirect set to 404 you get a 404 >6 - When OpacHiddenRecordRedirect set to 'an explanatory page' you get 'opac-blocked.pl' >7 - If you set a message in OpacHiddenRecordMessage it displays on opac-blocked.pl > >Signed-off-by: marti <mfuerst@hmcpl.org> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > installer/data/mysql/atomicupdate/bug_27734.perl | 12 ++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 2 ++ > .../prog/en/modules/admin/preferences/opac.pref | 9 +++++++++ > .../opac-tmpl/bootstrap/en/modules/opac-blocked.tt | 8 +++++++- > opac/opac-blocked.pl | 4 ++++ > opac/opac-detail.pl | 6 +++++- > 6 files changed, 39 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_27734.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_27734.perl b/installer/data/mysql/atomicupdate/bug_27734.perl >new file mode 100644 >index 0000000000..990b4b6672 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_27734.perl >@@ -0,0 +1,12 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('OpacHiddenRecordRedirect','0','Redirect the opac detail page for records hidden by OpacHiddenItems to an explanatory page (otherwise redirect to 404 error page)','','YesNo') >+ }); >+ $dbh->do(q{ >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('OpacHiddenRecordMessage','','Display this message on the redirect page for hidden biblios','70|10','Textarea') >+ }); >+ NewVersion( $DBversion, 27734, "Add OpacHiddenRecordRedirect and OpacHiddenRecordMessage preferences"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index f49557be9c..dde0db602e 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -497,6 +497,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 comma, 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'), > ('OpacHoldNotes','0','','Show hold notes on 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 96431944a9..58d7752e8b 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 >@@ -650,6 +650,15 @@ OPAC: > 0: "Don't hide" > 1: Hide > - "the bibliographic record when all its items are hidden by <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OpacHiddenItems'>OpacHiddenItems</a>." >+ - <br />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')." >+ - "<br />Display the following message on the redirect page for suppressed bibliographic records:" >+ - pref: OpacHiddenRecordMessage >+ type: textarea >+ class: code > - > - pref: OpacAllowPublicListCreation > default: 1 >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt >index 906ebeb7d5..1c7fbafba3 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt >@@ -3,6 +3,7 @@ > [% SET OpacSuppressionMessage = AdditionalContents.get( location => "OpacSuppressionMessage", lang => lang, library => branchcode || default_branch ) %] > [% PROCESS 'i18n.inc' %] > [% PROCESS 'html_helpers.inc' %] >+[% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% FILTER collapse %] > [% t("Record blocked") | html %] › >@@ -26,7 +27,12 @@ > <div id="opac-blocked-message" class="maincontent"> > <h1>Record blocked</h1> > <p>You are not authorized to view this record.</p> >- [% IF ( OpacSuppressionMessage ) %] >+ [% IF hidden %] >+ [% SET OpacBlockedMessage = Koha.Preference("OpacHiddenRecordMessage") %] >+ [% ELSE %] >+ [% SET OpacBlockedMessage = Koha.Preference("OpacSuppressionMessage") %] >+ [% END %] >+ [% IF ( OpacBlockedMessage ) %] > <div id="opacsuppressionmessage"> > [% PROCESS koha_news_block news => OpacSuppressionMessage %] > </div> >diff --git a/opac/opac-blocked.pl b/opac/opac-blocked.pl >index a604fefdbd..ac669c2e86 100755 >--- a/opac/opac-blocked.pl >+++ b/opac/opac-blocked.pl >@@ -33,4 +33,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >+if ( $query->param('hidden') ) { >+ $template->param( hidden => 1 ); >+} >+ > output_with_http_headers $query, $cookie, $template->output, 'html'; >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 348e509f6a..24c61a3610 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -124,7 +124,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 ( $items->count >= 1 ) { >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27734
:
121749
|
121797
|
121988
|
121989
|
121990
|
173166
|
173167
|
173168
| 175807 |
175808