From 59b41bad66232e68fb3d1343eaf430688a612806 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 21 Jan 2025 08:33:06 -0300 Subject: [PATCH] [24.05.x] 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 88317276c0f..26746a8abfe 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -43,7 +43,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 @@ -77,31 +77,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 2710de2fa80..514c511fe9e 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -47,7 +47,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 @@ -100,31 +100,8 @@ if ( ! $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'); unless ( $patron and $patron->category->override_hidden_items ) { # only skip this check if there's a logged in user diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 4730c52c65c..046217dc4b6 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -34,7 +34,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 @@ -113,31 +113,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 $items = $biblio->items->search_ordered; if ($specific_item) { -- 2.48.1