Bug 28478: Make opac-*detail.pl scripts use Koha::Biblio->opac_suppressed()
This patch makes the following scripts use the new method for checking
suppression:
* opac/opac-ISBDdetail.pl
* opac/opac-MARCdetail.pl
* opac/opac-detail.pl
In the `opac-detail.pl` case, it is a simple change by removing MARC
data traversal in favor of the new method. The code checking
suppression gets moved up so we don't process or make any other
calculations if the record is suppressed.
The other two scripts where completely missing the check and thus
leaking suppressed records.
To test:
1. Pick two records, one marked as suppressed, and the other not
suppressed.
2. Try acessing them in the OPAC detail page.
=> SUCCESS: Suppressed records are suppressed, and not suppressed ones
are not.
3. Try the same records on the ISBD and MARC view
=> FAIL: They are not suppressed!
4. Apply this patch
5. Repeat 2
=> SUCCESS: Suppression is still respected
6. Repeat 3
=> SUCCESS: Suppression is respected on the ISBD and MARC views
7. Sign off :-D
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised. Remember to activate OPAC suppression with
OpacSuppression.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
(cherry picked from commit 5b775aee69)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
55821c5558
commit
ae442f2de8
|
|
@ -76,6 +76,33 @@ if( !$biblio ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
# If record should be suppressed, handle it early
|
||||
if ( C4::Context->preference('OpacSuppression') ) {
|
||||
|
||||
# redirect to opac-blocked info page or 404?
|
||||
my $redirect_url;
|
||||
if ( C4::Context->preference("OpacSuppressionRedirect") ) {
|
||||
$redirect_url = "/cgi-bin/koha/opac-blocked.pl";
|
||||
} else {
|
||||
$redirect_url = "/cgi-bin/koha/errors/404.pl";
|
||||
}
|
||||
if ( $biblio->opac_suppressed() ) {
|
||||
|
||||
# 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($redirect_url);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
print $query->redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#open template
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,6 +99,33 @@ if ( ! $record ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
# If record should be suppressed, handle it early
|
||||
if ( C4::Context->preference('OpacSuppression') ) {
|
||||
|
||||
# redirect to opac-blocked info page or 404?
|
||||
my $redirect_url;
|
||||
if ( C4::Context->preference("OpacSuppressionRedirect") ) {
|
||||
$redirect_url = "/cgi-bin/koha/opac-blocked.pl";
|
||||
} else {
|
||||
$redirect_url = "/cgi-bin/koha/errors/404.pl";
|
||||
}
|
||||
if ( $biblio->opac_suppressed() ) {
|
||||
|
||||
# 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($redirect_url);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
print $query->redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unless ( $patron and $patron->category->override_hidden_items ) {
|
||||
# only skip this check if there's a logged in user
|
||||
# and its category overrides OpacHiddenItems
|
||||
|
|
|
|||
|
|
@ -112,6 +112,33 @@ unless ( $biblio && $record ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
# If record should be suppressed, handle it early
|
||||
if ( C4::Context->preference('OpacSuppression') ) {
|
||||
|
||||
# redirect to opac-blocked info page or 404?
|
||||
my $redirect_url;
|
||||
if ( C4::Context->preference("OpacSuppressionRedirect") ) {
|
||||
$redirect_url = "/cgi-bin/koha/opac-blocked.pl";
|
||||
} else {
|
||||
$redirect_url = "/cgi-bin/koha/errors/404.pl";
|
||||
}
|
||||
if ( $biblio->opac_suppressed() ) {
|
||||
|
||||
# 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($redirect_url);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
print $query->redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $items = $biblio->items->search_ordered;
|
||||
if ($specific_item) {
|
||||
$items = $items->search( { itemnumber => scalar $query->param('itemnumber') } );
|
||||
|
|
@ -140,37 +167,6 @@ my $record_processor = Koha::RecordProcessor->new({
|
|||
});
|
||||
$record_processor->process($record);
|
||||
|
||||
# redirect if opacsuppression is enabled and biblio is suppressed
|
||||
if (C4::Context->preference('OpacSuppression')) {
|
||||
# FIXME hardcoded; the suppression flag ought to be materialized
|
||||
# as a column on biblio or the like
|
||||
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 &&
|
||||
$opacsuppressionfieldvalue->subfield("n") &&
|
||||
$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(
|
||||
biblio => $biblio
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue