From d054db623f1edcaab616205ee21d0ccfd19e4f53 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 21 Jan 2025 08:33:06 -0300 Subject: [PATCH] Bug 38936: Use redirect_if_opac_suppressed() in opac-*detail.pl pages Signed-off-by: Tomas Cohen Arazi --- opac/opac-ISBDdetail.pl | 29 +++-------------------------- opac/opac-MARCdetail.pl | 29 +++-------------------------- opac/opac-detail.pl | 29 +++-------------------------- 3 files changed, 9 insertions(+), 78 deletions(-) diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 0e9b5787ce2..4651132f137 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -42,7 +42,7 @@ use Modern::Perl; use C4::Auth qw( get_template_and_user ); use C4::Context; -use C4::Output qw( parametrized_url output_html_with_http_headers ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_suppressed ); use CGI qw ( -utf8 ); use C4::Biblio qw( CountItemsIssued @@ -76,31 +76,8 @@ if ( !$biblio ) { } # 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; - } - } -} +redirect_if_opac_suppressed( $query, $biblio ) + if C4::Context->preference('OpacSuppression'); #open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index e3786764555..e78de9bc887 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -46,7 +46,7 @@ use Modern::Perl; use C4::Auth qw( get_template_and_user ); use C4::Context; -use C4::Output qw( parametrized_url output_html_with_http_headers ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_suppressed ); use CGI qw ( -utf8 ); use C4::Biblio qw( CountItemsIssued @@ -97,31 +97,8 @@ if ( !$biblio ) { } # 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; - } - } -} +redirect_if_opac_suppressed( $query, $biblio ) + if C4::Context->preference('OpacSuppression'); unless ( $patron and $patron->category->override_hidden_items ) { diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 7222edc6d65..516877d88d6 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -33,7 +33,7 @@ use C4::Koha qw( ); use C4::Search qw( new_record_from_zebra searchResults getRecords ); use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); -use C4::Output qw( parametrized_url output_html_with_http_headers ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_suppressed ); use C4::Biblio qw( CountItemsIssued GetBiblioData @@ -112,31 +112,8 @@ unless ( $biblio && $record ) { } # 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; - } - } -} +redirect_if_opac_suppressed( $query, $biblio ) + if C4::Context->preference('OpacSuppression'); my $metadata_extractor = $biblio->metadata_extractor; -- 2.50.1