Bugzilla – Attachment 91158 Details for
Bug 23247
Use EmbedItems in opac-MARCdetail.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23247: Simplify visibility logic used in opac-MARCdetail.pl
Bug-23247-Simplify-visibility-logic-used-in-opac-M.patch (text/plain), 5.12 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-07-01 19:12:19 UTC
(
hide
)
Description:
Bug 23247: Simplify visibility logic used in opac-MARCdetail.pl
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-07-01 19:12:19 UTC
Size:
5.12 KB
patch
obsolete
>From 0ea2b663bcde4a737f26ae4d1a492d26a6da4faa Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 1 Jul 2019 15:34:26 -0300 >Subject: [PATCH] Bug 23247: Simplify visibility logic used in > opac-MARCdetail.pl > >This patch uses the OO code, with prefetching and all, to make decisions >on visibility. It shouldn't change any behaviour, unless you are >counting DB queries, execution time, etc. > >To test: >- Find a known record, go to the OPAC MARC page of it. >- Play with several options in OpacHiddenItems, refreshing it >- Play with OpacHiddenItemsExceptions as well >=> SUCCESS: Things work as expected >- Apply this patch >- Repeate the tests above >=> SUCCESS: Things work as expected! >- Sign off :-D >--- > opac/opac-MARCdetail.pl | 59 +++++++++++++++++++---------------------- > 1 file changed, 28 insertions(+), 31 deletions(-) > >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index dd709003a8..45c634db58 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -59,7 +59,6 @@ use C4::Koha; > use List::MoreUtils qw( any uniq ); > use Koha::Biblios; > use Koha::IssuingRules; >-use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; > use Koha::RecordProcessor; >@@ -84,39 +83,38 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $patron = Koha::Patrons->find( $loggedinuser ); >-my $borcat = q{}; >-if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >- # we need to fetch the borrower info here, so we can pass the category >- $borcat = $patron ? $patron->categorycode : $borcat; >-} >+my $biblio = Koha::Biblios->find( $biblionumber, { prefetch => [ 'metadata', 'items' ] } ); > >-my $record = GetMarcBiblio({ >- biblionumber => $biblionumber, >- embed_items => 1, >- opac => 1, >- borcat => $borcat }); >-if ( ! $record ) { >+unless ( $biblio ) { > print $query->redirect("/cgi-bin/koha/errors/404.pl"); > 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',$framework); >-my @nonhiddenitems = $record->field($tag_itemnumber); >-if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) { >- print $query->redirect("/cgi-bin/koha/errors/404.pl"); >- exit; >+my $patron = Koha::Patrons->find( $loggedinuser ); >+ >+my $opachiddenitems_rules; >+eval { >+ my $yaml = C4::Context->preference('OpacHiddenItems') . "\n\n"; >+ $opachiddenitems_rules = YAML::Load($yaml); >+}; >+ >+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; >+ } > } > >+my $record = $biblio->metadata->record; >+my $marcflavour = C4::Context->preference("marcflavour"); >+ > my $record_processor = Koha::RecordProcessor->new({ > filters => 'ViewPolicy', > options => { > interface => 'opac', >- frameworkcode => $framework >+ frameworkcode => $biblio->frameworkcode > } > }); > $record_processor->process($record); >@@ -128,18 +126,18 @@ if(my $cart_list = $query->cookie("bib_list")){ > $template->param( incart => 1 ); > } > } >- >-my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); >+my $tagslib = &GetMarcStructure( 0, $biblio->frameworkcode ); >+my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$biblio->frameworkcode); > $template->param( > bibliotitle => $biblio->title, > ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. > $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} ); >- $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >- last if $allow_onshelf_holds; >+my $items = $biblio->items; >+while ( my $item = $items->next ) { >+ $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) >+ unless $allow_onshelf_holds; > } > > if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { >@@ -307,7 +305,7 @@ foreach my $field (@fields) { > push @item_loop, $item if $item; > } > my ( $holdingbrtagf, $holdingbrtagsubf ) = >- &GetMarcFromKohaField( "items.holdingbranch", $framework ); >+ &GetMarcFromKohaField( "items.holdingbranch", $biblio->frameworkcode ); > @item_loop = > sort { ($a->{$holdingbrtagsubf}||'') cmp ($b->{$holdingbrtagsubf}||'') } @item_loop; > >@@ -326,7 +324,6 @@ if ( C4::Context->preference("OPACISBD") ) { > } > > #Search for title in links >-my $marcflavour = C4::Context->preference("marcflavour"); > my $dat = TransformMarcToKoha( $record ); > my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); > my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour); >-- >2.22.0
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 23247
:
91158
|
91253
|
93528
|
102094
|
102095
|
138059
|
144689
|
146813