Bugzilla – Attachment 120138 Details for
Bug 18989
Allow displaying biblios with all items hidden by OpacHiddenItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[OPTIONAL] Bug 18989: (QA follow-up) Make controllers use Koha::Biblio->hidden_in_opac
OPTIONAL-Bug-18989-QA-follow-up-Make-controllers-u.patch (text/plain), 7.11 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-04-23 19:55:56 UTC
(
hide
)
Description:
[OPTIONAL] Bug 18989: (QA follow-up) Make controllers use Koha::Biblio->hidden_in_opac
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-04-23 19:55:56 UTC
Size:
7.11 KB
patch
obsolete
>From fb57c2ea4281518e6882239b04d84e3260d26361 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 23 Apr 2021 16:55:35 -0300 >Subject: [PATCH] [OPTIONAL] Bug 18989: (QA follow-up) Make controllers use > Koha::Biblio->hidden_in_opac > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > opac/opac-ISBDdetail.pl | 2 +- > opac/opac-MARCdetail.pl | 22 ++++++++++++---------- > opac/opac-basket.pl | 5 ++++- > opac/opac-detail.pl | 19 +++++++------------ > opac/opac-tags.pl | 13 ++++++++++--- > 5 files changed, 34 insertions(+), 27 deletions(-) > >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index e4b54f068d3..d1076e76ef8 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -84,7 +84,7 @@ 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 ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) { >+ if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) { > print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early > exit; > } >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index 3211f61df37..e07d28beba0 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -102,17 +102,19 @@ if ( ! $record ) { > exit; > } > >-my @all_items = GetItemsInfo($biblionumber); > my $biblio = Koha::Biblios->find( $biblionumber ); >-my $framework = $biblio ? $biblio->frameworkcode : q{}; >-my $tagslib = &GetMarcStructure( 0, $framework ); >-my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField( 'items.itemnumber' ); >-my @nonhiddenitems = $record->field($tag_itemnumber); >-if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @nonhiddenitems == 0 ) { >- print $query->redirect("/cgi-bin/koha/errors/404.pl"); >- 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 >+ if ( $biblio->hidden_in_opac({ rules => C4::Context->yaml_preference('OpacHiddenItems') }) ) { >+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early >+ exit; >+ } > } > >+my $framework = $biblio ? $biblio->frameworkcode : q{}; >+my $tagslib = &GetMarcStructure( 0, $framework ); >+ > my $record_processor = Koha::RecordProcessor->new({ > filters => 'ViewPolicy', > options => { >@@ -137,8 +139,8 @@ $template->param( > $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; > > my $allow_onshelf_holds; >-for my $itm (@all_items) { >- my $item = Koha::Items->find( $itm->{itemnumber} ); >+my $items = $bibio->items; >+while ( my $item = $items->next ) { > $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); > last if $allow_onshelf_holds; > } >diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl >index cc3d9753553..2de55f4be64 100755 >--- a/opac/opac-basket.pl >+++ b/opac/opac-basket.pl >@@ -66,6 +66,8 @@ if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { > } > > my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' }); >+my $rules = C4::Context->yaml_preference('OpacHiddenItems'); >+ > foreach my $biblionumber ( @bibs ) { > $template->param( biblionumber => $biblionumber ); > >@@ -96,7 +98,8 @@ foreach my $biblionumber ( @bibs ) { > my @hidden_items = GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat }); > > # If every item is hidden, then the biblio should be hidden too. >- next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @all_items >= 1 && scalar @hidden_items == scalar @all_items); >+ next >+ if $biblio->hidden_in_opac({ rules => $rules }); > > # copy the visible ones into the items array. > my @items; >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 26d3ef01515..e2ea7e709e3 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -89,10 +89,6 @@ if( $specific_item ) { > } > my @hiddenitems; > my $patron = Koha::Patrons->find( $borrowernumber ); >-our $borcat= q{}; >-if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >- $borcat = $patron ? $patron->categorycode : q{}; >-} > > my $record = GetMarcBiblio({ > biblionumber => $biblionumber, >@@ -102,17 +98,16 @@ if ( ! $record ) { > exit; > } > >-if ( scalar @all_items >= 1 ) { >- push @hiddenitems, >- GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } ); >- >- if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && scalar @hiddenitems == scalar @all_items ) { >- print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early >+my $biblio = Koha::Biblios->find( $biblionumber ); >+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; > } > } > >-my $biblio = Koha::Biblios->find( $biblionumber ); > my $framework = $biblio ? $biblio->frameworkcode : q{}; > my $record_processor = Koha::RecordProcessor->new({ > filters => 'ViewPolicy', >@@ -280,7 +275,7 @@ if ($session->param('busc')) { > my @newresults; > my $search_context = { > 'interface' => 'opac', >- 'category' => $borcat >+ 'category' => ($patron) ? $patron->categorycode : q{} > }; > for (my $i=0;$i<@servers;$i++) { > my $server = $servers[$i]; >diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl >index 1f15149cb2f..05a4c1a74ae 100755 >--- a/opac/opac-tags.pl >+++ b/opac/opac-tags.pl >@@ -233,8 +233,8 @@ my $borcat = q{}; > if ($loggedinuser) { > my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); > $borcat = $patron ? $patron->categorycode : $borcat; >- my $should_hide = C4::Context->preference('OpacHiddenItems') // q{}; >- $should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0; >+ my $rules = C4::Context->yaml_preference('OpacHiddenItems'); >+ my $should_hide = ( $rules ) ? 1 : 0; > $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); > my $my_approved_tags = get_approval_rows({ approved => 1 }); > >@@ -270,7 +270,14 @@ if ($loggedinuser) { > borcat => $borcat }); > $hidden_items = \@hidden_itemnumbers; > } >- next if ( C4::Context->preference('OpacHiddenItemsHidesRecord') && $should_hide && scalar @all_items == scalar @hidden_itemnumbers ); >+ next >+ if ( >+ ( >+ !$patron >+ or ( $patron and !$patron->category->override_hidden_items ) >+ ) >+ and $biblio->hidden_in_opac( { rules => $rules } ) >+ ); > $tag->{title} = $biblio->title; > $tag->{subtitle} = $biblio->subtitle; > $tag->{medium} = $biblio->medium; >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18989
:
109656
|
109657
|
114738
|
116000
|
116001
|
116002
|
116003
|
119524
|
119784
|
119785
|
119786
|
119787
|
119788
|
120137
|
120138
|
120171
|
120431
|
120432
|
120558