From 9a95b6c061d0aa7a772d573eafc123bf7589978a Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 21 Oct 2025 14:48:07 +0300 Subject: [PATCH] Bug 27734: Use redirect_if_opac_hidden() in opac-*detail.pages --- opac/opac-ISBDdetail.pl | 12 ++---------- opac/opac-MARCdetail.pl | 12 ++---------- opac/opac-detail.pl | 7 ++----- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 45e83c393d4..165c77e7f33 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 redirect_if_opac_suppressed ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_hidden redirect_if_opac_suppressed ); use CGI qw ( -utf8 ); use C4::Biblio qw( CountItemsIssued @@ -93,15 +93,7 @@ my $patron = Koha::Patrons->find($loggedinuser); my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems'); -unless ( $patron and $patron->category->override_hidden_items ) { - - # only skip this check if there's a logged in user - # and its category overrides OpacHiddenItems - if ( $biblio->hidden_in_opac( { rules => $opachiddenitems_rules } ) ) { - print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early - exit; - } -} +redirect_if_opac_hidden( $query, $biblio, $patron ); my $record = $biblio->metadata->record; my @items = $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list; diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 03c2d18dd04..95f6062ffac 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 redirect_if_opac_suppressed ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_hidden redirect_if_opac_suppressed ); use CGI qw ( -utf8 ); use C4::Biblio qw( CountItemsIssued @@ -100,15 +100,7 @@ if ( !$biblio ) { 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 - # and its category overrides OpacHiddenItems - if ( $biblio->hidden_in_opac( { rules => C4::Context->yaml_preference('OpacHiddenItems') } ) ) { - print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early - exit; - } -} +redirect_if_opac_hidden( $query, $biblio, $patron ); my $metadata_extractor = $biblio->metadata_extractor; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 211dac36ea1..8736adb5744 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 redirect_if_opac_suppressed ); +use C4::Output qw( parametrized_url output_html_with_http_headers redirect_if_opac_hidden redirect_if_opac_suppressed ); use C4::Biblio qw( CountItemsIssued GetBiblioData @@ -127,10 +127,7 @@ unless ( $patron and $patron->category->override_hidden_items ) { # only skip this check if there's a logged in user # and its category overrides OpacHiddenItems - if ( $biblio->hidden_in_opac( { rules => C4::Context->yaml_preference('OpacHiddenItems') } ) ) { - print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early - exit; - } + redirect_if_opac_hidden( $query, $biblio, $patron ); if ( $items->count >= 1 ) { $items = $items->filter_by_visible_in_opac( { patron => $patron } ); } -- 2.34.1