Bugzilla – Attachment 188256 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 system preference
Bug-27734-Add-OpacHiddenRecordRedirect-system-pref.patch (text/plain), 8.91 KB, created by
Lari Taskula
on 2025-10-21 17:59:39 UTC
(
hide
)
Description:
Bug 27734: Add OpacHiddenRecordRedirect system preference
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2025-10-21 17:59:39 UTC
Size:
8.91 KB
patch
obsolete
>From ecf33c37ca6bc4bda06882d8d940e7f700879159 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 system preference > >This patch adds option analogous to OpacSuppressionRedirect for OpacHiddtenItems > >Test plan: >1. Apply patch >2. Create a bibiliographic record and add an item to it. Note down its biblionumber. > >It will be later reffered to as <biblionumber>. > >3. Set system preference OpacHiddenRecordRedirect on >4. Create HTML customization OpacHiddenRecordMessage. Add some placeholder > content in it. >5. Enable OpacHiddenItemsHidesRecord and hide a biblio using OpacHiddenItems: > >biblionumber: [<biblionumber>] > >e.g. > >biblionumber: [123] > >6. Test OpacHiddenRecordRedirect and OpacHiddenRecordMessage to ensure they work > as expected >7. Hit these links: > >http://koha/cgi-bin/koha/opac-detail.pl?biblionumber=<biblionumber> >http://koha/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<biblionumber> >http://koha/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<biblionumber> > >8. When OpacHiddenRecordRedirect set to 404 you get a 404 >9. When OpacHiddenRecordRedirect set to 'an explanatory page' you get 'opac-blocked.pl' >10. If you set a message in OpacHiddenRecordMessage it displays on opac-blocked.pl >11. Using preference OpacHiddenItemsExceptions, exclude your patron category >12. Observe the record is no longer blocked when your patron category is excluded >--- > Koha/AdditionalContents.pm | 2 +- > installer/data/mysql/atomicupdate/bug_27734.perl | 9 +++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../prog/en/includes/html-customization-help.inc | 4 ++++ > .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ > .../opac-tmpl/bootstrap/en/modules/opac-blocked.tt | 11 +++++++++-- > opac/opac-blocked.pl | 4 ++++ > 7 files changed, 34 insertions(+), 3 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_27734.perl > >diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm >index 98a1b162194..e65848565c7 100644 >--- a/Koha/AdditionalContents.pm >+++ b/Koha/AdditionalContents.pm >@@ -170,7 +170,7 @@ sub get_html_customizations_options { > 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'OpacSuppressionMessage', 'SCOMainUserBlock', > 'SelfCheckInMainUserBlock', 'SelfCheckHelpMessage', 'CatalogConcernHelp', 'CatalogConcernTemplate', > 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions', >- 'ILLModuleCopyrightClearance' >+ 'ILLModuleCopyrightClearance', 'OpacHiddenRecordMessage' > ]; > } > >diff --git a/installer/data/mysql/atomicupdate/bug_27734.perl b/installer/data/mysql/atomicupdate/bug_27734.perl >new file mode 100644 >index 00000000000..9c65a21bda2 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_27734.perl >@@ -0,0 +1,9 @@ >+$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') >+ }); >+ >+ NewVersion( $DBversion, 27734, "Add OpacHiddenRecordRedirect preference"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index c3fa93d5041..a2e47247ae8 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -514,6 +514,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See https://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'), > ('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/includes/html-customization-help.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc >index 13730322962..2d5c3107819 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html-customization-help.inc >@@ -26,6 +26,10 @@ > > <div id="OpacLibraryInfo_notes" class="hint customization_note"> Include this content on the library information page in the OPAC. </div> > >+<div id="OpacHiddenRecordMessage_notes" class="hint customization_note"> >+ Display the following message on the redirect page for hidden bibliographic records. Depends on the system preferences OpacHiddenItems and OpacHiddenRecordRedirect. >+</div> >+ > <div id="OpacLoginInstructions_notes" class="hint customization_note"> Show this content on the OPAC login form when a patron is not logged in. </div> > > <div id="OpacMaintenanceNotice_notes" class="hint customization_note"> Show this content on the OPAC when the OpacMaintenance system preference is enabled. </div> >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 e7645752111..86f5bffdd60 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 >@@ -681,6 +681,12 @@ 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 a message on the redirect page for suppressed bibliographic records with HTML customization <strong>OpacHiddenRecordMessage</strong>." > - > - 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 df59d8765db..f3f4cc29688 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE AdditionalContents %] > [% SET OpacSuppressionMessage = AdditionalContents.get( location => "OpacSuppressionMessage", lang => lang, library => branchcode || default_branch ) %] >+[% SET OpacHiddenRecordMessage = AdditionalContents.get( location => "OpacHiddenRecordMessage", lang => lang, library => branchcode || default_branch ) %] > [% PROCESS 'i18n.inc' %] > [% PROCESS 'html_helpers.inc' %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -29,8 +30,14 @@ > <div id="opac-blocked-message" class="maincontent"> > <h1>Record blocked</h1> > <p>You are not authorized to view this record.</p> >- [% IF ( OpacSuppressionMessage ) %] >- <div id="opacsuppressionmessage"> [% PROCESS koha_news_block news => OpacSuppressionMessage %] </div> >+ [% IF ( OpacSuppressionMessage ) || ( hidden ) %] >+ <div id="opacsuppressionmessage"> >+ [% IF hidden %] >+ [% PROCESS koha_news_block news => OpacHiddenRecordMessage %] >+ [% ELSE %] >+ [% PROCESS koha_news_block news => OpacSuppressionMessage %] >+ [% END %] >+ </div> > [% END %] > </div> > </div> >diff --git a/opac/opac-blocked.pl b/opac/opac-blocked.pl >index 27d9ef458b0..64d19ce41c7 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'; >-- >2.34.1
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
|
188253
|
188254
|
188255
| 188256