Bugzilla – Attachment 19697 Details for
Bug 10195
Records hidden with OpacSuppression can still be accessed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10195 Records hidden with OpacSuppression can still be accessed
Bug-10195-Records-hidden-with-OpacSuppression-can-.patch (text/plain), 10.52 KB, created by
Mirko Tietgen
on 2013-07-16 18:35:51 UTC
(
hide
)
Description:
Bug 10195 Records hidden with OpacSuppression can still be accessed
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2013-07-16 18:35:51 UTC
Size:
10.52 KB
patch
obsolete
>From 08db5dba4e820d97a1e0d064c5c8c6264f963c30 Mon Sep 17 00:00:00 2001 >From: Mirko Tietgen <mirko@abunchofthings.net> >Date: Thu, 4 Jul 2013 00:50:43 +0200 >Subject: [PATCH] Bug 10195 Records hidden with OpacSuppression can still be accessed > >Records hidden with OpacSuppression are filtered from the search results, but the opac-detail page is still visible if you know the biblio number. This patch hides the detail page for suppressed biblios by redirecting (controlled by the syspref OpacSuppressionRedirect) either to opac-blocked (default), explaining that the record is blocked (including optional explanatory text from the syspref OpacSuppressionMessage) or to Koha's 404 page, giving no hint that a biblio with that number exists in the system. > >Test plan: > >Make sure you have at least one record with 942$n == 1. >Set OpacSuppression to "Don't hide". > >Do an OPAC search that should bring up your hidden record and other records. > Observe that your record is found. >Open the detail page for the record. > Observe that it is accessible. Copy the URL for later(!). > >Set OpacSuppression to "Hide". >Leave OpacSuppressionByIPRange blank. >Set OpacSuppressionRedirect to "an explanatory page ('This record is blocked')." >Leave OpacSuppressionMessage blank for now. >Disable queryparser(!) (because of bug 10542). > >Do a full zebra reindex. > >Do an OPAC search that should bring up your hidden record and other records. > Observe that your record is not found. >Open the opac-detail URL of the record (the one you copied before). > Observe that you are redirected to opac-blocked and it displays a short standard message. > >Edit OpacSuppressionMessage and input some text. >Open the opac-detail URL of the record again (the one you copied before). > Observe that the text you entered in OpacSuppressionMessage is displayed under the standard text you have seen before. > >Set OpacSuppressionRedirect to "the 404 error page ('Not found')." >Open the opac-detail URL of the record again (the one you copied before). > Observe that you are redirected to Koha's 404 error page. > >Sign off the patch. :) >--- > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 9 +++++ > .../en/modules/admin/preferences/cataloguing.pref | 11 +++++- > .../opac-tmpl/prog/en/modules/opac-blocked.tt | 32 ++++++++++++++++ > opac/opac-blocked.pl | 38 ++++++++++++++++++++ > opac/opac-detail.pl | 30 +++++++++++++++ > 6 files changed, 121 insertions(+), 1 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-blocked.tt > create mode 100755 opac/opac-blocked.pl > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0a3f20f..795e9ed 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -428,3 +428,5 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionMessage','','Display this message on the redirect page for suppressed biblios','70|10','Textarea'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 1f7b491..328ccec 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7044,6 +7044,15 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo')"); >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionMessage', '','Display this message on the redirect page for suppressed biblios','70|10','Textarea')"); >+ print "Upgrade to $DBversion done (Bug 10195: Records hidden with OpacSuppression can still be accessed)\n"; >+ SetVersion($DBversion); >+} >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index 96f3603..79056ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -156,10 +156,19 @@ Cataloging: > yes: Hide > no: "Don't hide" > - items marked as suppressed from OPAC search results. Note that you must have the <code>Suppress</code> index set up in Zebra and at least one suppressed item, or your searches will be broken. >- - Restrict the suppression to IP adresses outside of the IP range >+ - <br />Restrict the suppression to IP adresses outside of the IP range > - pref: OpacSuppressionByIPRange > class: short > - (Leave blank if not used. Define a range like <code>192.168.</code>.) >+ - <br />Redirect the opac detail page for suppressed records to >+ - pref: OpacSuppressionRedirect >+ choices: >+ yes: "an explanatory page ('This record is blocked')." >+ no: "the 404 error page ('Not found')." >+ - <br />Display the following message on the redirect page for suppressed biblios >+ - pref: OpacSuppressionMessage >+ type: textarea >+ class: code > - > - pref: SeparateHoldings > choices: >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-blocked.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-blocked.tt >new file mode 100644 >index 0000000..d3d86bb >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-blocked.tt >@@ -0,0 +1,32 @@ >+[% USE Koha %] >+[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Blocked >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="opac-blocked"> >+[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %] >+<div id="bd"> >+[% INCLUDE 'masthead.inc' %] >+ >+<div id="yui-main"> >+<div class="yui-b"> >+<div class="yui-g"> >+ <div id="opac-blocked-message"> >+ <h3>Blocked</h3> >+ <p>You are not authorized to view this record.</p> >+ [% IF ( OpacSuppressionMessage ) %] >+ <div id="opacsuppressionmessage"> >+ <p>[% OpacSuppressionMessage %]</p> >+ </div> >+ [% END %] >+ </div> >+</div> >+</div> >+</div> >+[% IF ( OpacNav ) %] >+<div class="yui-b"> >+<div id="leftmenus" class="container"> >+[% INCLUDE 'navigation.inc' %] >+</div> >+</div>[% END %] >+</div> >+[% INCLUDE 'opac-bottom.inc' %] >diff --git a/opac/opac-blocked.pl b/opac/opac-blocked.pl >new file mode 100755 >index 0000000..7c889da >--- /dev/null >+++ b/opac/opac-blocked.pl >@@ -0,0 +1,38 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along with >+# Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >+ >+ >+use strict; >+use warnings; >+use CGI; >+use C4::Auth; >+use C4::Output; >+use C4::Context; >+ >+my $query = new CGI; >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-blocked.tt", >+ query => $query, >+ type => "opac", >+ authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), >+ } >+); >+ >+$template->param ( OpacSuppressionMessage => C4::Context->preference('OpacSuppressionMessage')); >+ >+output_with_http_headers $query, $cookie, $template->output, 'html'; >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 9d0851f..2c4f8bd 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -78,6 +78,36 @@ if ( ! $record ) { > print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early > exit; > } >+ >+# redirect if opacsuppression is enabled and biblio is suppressed >+if (C4::Context->preference('OpacSuppression')) { >+ my $opacsuppressionfield = '942'; >+ my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield); >+ # redirect to opac-blocked info page or 404? >+ my $opacsuppressionredirect; >+ if ( C4::Context->preference("OpacSuppressionRedirect") ) { >+ $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl"; >+ } >+ else { >+ $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl"; >+ } >+ if ( $opacsuppressionfieldvalue->subfield("n") == 1) { >+ # if OPAC suppression by IP address >+ if (C4::Context->preference('OpacSuppressionByIPRange')) { >+ my $IPAddress = $ENV{'REMOTE_ADDR'}; >+ my $IPRange = C4::Context->preference('OpacSuppressionByIPRange'); >+ if ($IPAddress !~ /^$IPRange/) { >+ print $query->redirect($opacsuppressionredirect); >+ exit; >+ } >+ } >+ else { >+ print $query->redirect($opacsuppressionredirect); >+ exit; >+ } >+ } >+} >+ > $template->param( biblionumber => $biblionumber ); > > # get biblionumbers stored in the cart >-- >1.7.2.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 10195
:
19691
|
19693
|
19697
|
19873
|
20428