Bugzilla – Attachment 66537 Details for
Bug 14385
Extend OpacHiddenItems to allow specifying exempt borrower categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14385: Modify opac-ISBDdetail and opac-MARCdetail
SIGNED-OFF-Bug-14385-Modify-opac-ISBDdetail-and-op.patch (text/plain), 10.22 KB, created by
Aleisha Amohia
on 2017-08-27 23:43:22 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14385: Modify opac-ISBDdetail and opac-MARCdetail
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2017-08-27 23:43:22 UTC
Size:
10.22 KB
patch
obsolete
>From 347bc445ad39dd75411aa4e2955736619de0c5d4 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Fri, 18 Aug 2017 18:33:31 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 14385: Modify opac-ISBDdetail and > opac-MARCdetail > >Both files had similar logic. They were rearranged and >optimized, so that both files would have practically identical >initial blocks of code. > >Optimizations were possible, because GetMarcBiblio >returns a filtered record, so that there is no double call >(once in the opac-### file and once in GetMarcBiblio) to >GetHiddenItemnumbers. > >Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com> >--- > opac/opac-ISBDdetail.pl | 79 ++++++++++++++++++++++---------------------- > opac/opac-MARCdetail.pl | 87 ++++++++++++++++++++++--------------------------- > 2 files changed, 79 insertions(+), 87 deletions(-) > >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index b003509..9fd472c 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -58,6 +58,15 @@ use Koha::RecordProcessor; > > > my $query = CGI->new(); >+ >+my $biblionumber = $query->param('biblionumber'); >+if ( ! $biblionumber ) { >+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); >+ exit; >+} >+$biblionumber = int($biblionumber); >+ >+#open template > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "opac-ISBDdetail.tt", >@@ -68,51 +77,32 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $biblionumber = $query->param('biblionumber'); >-$biblionumber = int($biblionumber); >- >-# get biblionumbers stored in the cart >-if(my $cart_list = $query->cookie("bib_list")){ >- my @cart_list = split(/\//, $cart_list); >- if ( grep {$_ eq $biblionumber} @cart_list) { >- $template->param( incart => 1 ); >- } >-} >- >-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); >- >-my $marcflavour = C4::Context->preference("marcflavour"); >- >-my @items = GetItemsInfo($biblionumber); >-if (scalar @items >= 1) { >- my $borrowernumber; >- my $borcat; >- if (C4::Context->userenv) { >- $borrowernumber = C4::Context->userenv->{'number'}; >- } >- if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >- >- # we need to fetch the borrower info here, so we can pass the category >- my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } ); >- $borcat = $borrower ? $borrower->categorycode : q{}; >- } >- >- my @hiddenitems = GetHiddenItemnumbers( { items => \@items, borcat => $borcat }); >- >- if (scalar @hiddenitems == scalar @items ) { >- print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early >- exit; >- } >+my $borcat = q{}; >+if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >+ # we need to fetch the borrower info here, so we can pass the category >+ my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); >+ $borcat = $borrower ? $borrower->categorycode : $borcat; > } > > my $record = GetMarcBiblio({ > biblionumber => $biblionumber, >- embed_items => 1 }); >+ embed_items => 1, >+ opac => 1, >+ borcat => $borcat }); > if ( ! $record ) { > print $query->redirect("/cgi-bin/koha/errors/404.pl"); > exit; > } >-my $framework = GetFrameworkCode( $biblionumber ); >+ >+my @all_items = GetItemsInfo($biblionumber); >+my $framework = &GetFrameworkCode( $biblionumber ); >+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'); # escape early >+ exit; >+} >+ > my $record_processor = Koha::RecordProcessor->new({ > filters => 'ViewPolicy', > options => { >@@ -122,6 +112,18 @@ my $record_processor = Koha::RecordProcessor->new({ > }); > $record_processor->process($record); > >+# get biblionumbers stored in the cart >+if(my $cart_list = $query->cookie("bib_list")){ >+ my @cart_list = split(/\//, $cart_list); >+ if ( grep {$_ eq $biblionumber} @cart_list) { >+ $template->param( incart => 1 ); >+ } >+} >+ >+$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); >+ >+my $marcflavour = C4::Context->preference("marcflavour"); >+ > # some useful variables for enhanced content; > # in each case, we're grabbing the first value we find in > # the record and normalizing it >@@ -143,7 +145,6 @@ $template->param( > > #coping with subscriptions > my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); >-my $dbh = C4::Context->dbh; > my $dat = TransformMarcToKoha( $record ); > > my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' }); >@@ -179,7 +180,7 @@ my $res = GetISBDView({ > > my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; > my $patron = Koha::Patrons->find( $loggedinuser ); >-for my $itm (@items) { >+for my $itm (@all_items) { > $norequests = 0 > if $norequests > && !$itm->{'withdrawn'} >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index cc6bb53..64a5214 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -61,50 +61,51 @@ use Koha::Biblios; > use Koha::Patrons; > use Koha::RecordProcessor; > >-my $query = new CGI; >- >-my $dbh = C4::Context->dbh; >+my $query = CGI->new(); > > my $biblionumber = $query->param('biblionumber'); > if ( ! $biblionumber ) { > print $query->redirect("/cgi-bin/koha/errors/404.pl"); > exit; > } >+$biblionumber = int($biblionumber); >+ >+# open template >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-MARCdetail.tt", >+ query => $query, >+ type => "opac", >+ authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), >+ debug => 1, >+ } >+); >+ >+my $borcat = q{}; >+if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >+ # we need to fetch the borrower info here, so we can pass the category >+ my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); >+ $borcat = $borrower ? $borrower->categorycode : $borcat; >+} > > my $record = GetMarcBiblio({ > biblionumber => $biblionumber, >- embed_items => 1 }); >+ embed_items => 1, >+ opac => 1, >+ borcat => $borcat }); > if ( ! $record ) { > print $query->redirect("/cgi-bin/koha/errors/404.pl"); > exit; > } > > my @all_items = GetItemsInfo($biblionumber); >-my @items2hide; >-if (scalar @all_items >= 1) { >- my $borrowernumber; >- my $borcat; >- if (C4::Context->userenv) { >- $borrowernumber = C4::Context->userenv->{'number'}; >- } >- if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { >- >- # we need to fetch the borrower info here, so we can pass the category >- my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } ); >- $borcat = $borrower ? $borrower->categorycode : q{}; >- } >- push @items2hide, GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat }); >- >- if (scalar @items2hide == scalar @all_items ) { >- print $query->redirect("/cgi-bin/koha/errors/404.pl"); >- exit; >- } >-} >- > my $framework = &GetFrameworkCode( $biblionumber ); >-my $tagslib = &GetMarcStructure( 0, $framework ); > my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); >-my $biblio = Koha::Biblios->find( $biblionumber ); >+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 $record_processor = Koha::RecordProcessor->new({ > filters => 'ViewPolicy', >@@ -115,23 +116,6 @@ my $record_processor = Koha::RecordProcessor->new({ > }); > $record_processor->process($record); > >-# open template >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >- { >- template_name => "opac-MARCdetail.tt", >- query => $query, >- type => "opac", >- authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), >- debug => 1, >- } >-); >- >-my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); >-$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; >- > # get biblionumbers stored in the cart > if(my $cart_list = $query->cookie("bib_list")){ > my @cart_list = split(/\//, $cart_list); >@@ -140,6 +124,16 @@ if(my $cart_list = $query->cookie("bib_list")){ > } > } > >+$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); >+ >+my $biblio = Koha::Biblios->find( $biblionumber ); >+my $tagslib = &GetMarcStructure( 0, $framework ); >+my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); >+$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; > my $patron = Koha::Patrons->find( $loggedinuser ); > for my $itm (@all_items) { >@@ -148,7 +142,6 @@ for my $itm (@all_items) { > } > > $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds ); >-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); > > # adding the $RequestOnOpac param > my $RequestOnOpac; >@@ -278,6 +271,7 @@ for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { > # loop through each tag > # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary > # then construct template. >+# $record has already had all the item fields filtered above. > my @fields = $record->fields(); > my %witness > ; #---- stores the list of subfields used at least once, with the "meaning" of the code >@@ -285,9 +279,6 @@ my @item_subfield_codes; > my @item_loop; > foreach my $field (@fields) { > next if ( $field->tag() < 10 ); >- next if ( ( $field->tag() eq $tag_itemnumber ) && >- ( any { $field->subfield($subtag_itemnumber) eq $_ } >- @items2hide) ); > my @subf = $field->subfields; > my $item; > >-- >2.1.4
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 14385
:
40158
|
53483
|
53494
|
53505
|
53506
|
53507
|
55593
|
64688
|
64689
|
64690
|
64691
|
64692
|
64693
|
65322
|
65323
|
65324
|
65325
|
65376
|
65377
|
65378
|
65379
|
65380
|
65381
|
65382
|
65383
|
65384
|
65385
|
65386
|
65387
|
65388
|
65389
|
65408
|
65409
|
65410
|
65411
|
66103
|
66104
|
66105
|
66106
|
66107
|
66108
|
66109
|
66110
|
66111
|
66112
|
66113
|
66114
|
66115
|
66116
|
66117
|
66118
|
66125
|
66126
|
66127
|
66128
|
66129
|
66130
|
66131
|
66132
|
66192
|
66193
|
66194
|
66195
|
66196
|
66197
|
66198
|
66199
|
66200
|
66201
|
66202
|
66203
|
66204
|
66205
|
66206
|
66207
|
66208
|
66209
|
66210
|
66302
|
66303
|
66347
|
66361
|
66372
|
66401
|
66403
|
66520
|
66521
|
66522
|
66523
|
66524
|
66525
|
66526
|
66527
|
66528
|
66529
|
66530
|
66531
|
66532
|
66533
|
66534
|
66535
|
66536
|
66537
|
66538
|
66539
|
66540
|
66541
|
66542
|
66543
|
66544
|
66545
|
70256
|
70257
|
70258
|
70259
|
72445
|
72446
|
72447
|
72448
|
72449
|
72450
|
72451
|
72452
|
72453
|
72454
|
74001
|
78654
|
78655
|
78656
|
78657
|
78825
|
78826
|
78827
|
78828
|
80411
|
80463
|
80464
|
80465
|
80466
|
80467
|
89963
|
90038