From 8ebc3e74e344feac4731156f3d63aee8869d28c9 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 3bc55cb0f77..efe9458d9a6 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 8b3cb6ec085..89bdaa3fa63 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 @@ -98,31 +98,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 ) { # only skip this check if there's a logged in user diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index ba5238b1c10..72bd477dfeb 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 $metadata_extractor = $biblio->metadata_extractor; -- 2.48.1