Bugzilla – Attachment 61972 Details for
Bug 17843
Move C4::Koha::getitemtypeinfo to Koha::ItemTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17843: Replace C4::Koha::getitemtypeinfo with Koha::ItemTypes
Bug-17843-Replace-C4Kohagetitemtypeinfo-with-KohaI.patch (text/plain), 15.21 KB, created by
Lari Taskula
on 2017-04-07 10:53:58 UTC
(
hide
)
Description:
Bug 17843: Replace C4::Koha::getitemtypeinfo with Koha::ItemTypes
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2017-04-07 10:53:58 UTC
Size:
15.21 KB
patch
obsolete
>From 255d7f343d8bea0701333bab32bce783d0003a28 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 Jan 2017 10:30:47 +0100 >Subject: [PATCH] Bug 17843: Replace C4::Koha::getitemtypeinfo with > Koha::ItemTypes > >The C4::Koha::getitemtypeinfo subroutine did the almost same job as >GetItemTypes. On top of that it returned the imageurl value processed by >C4::Koha::getitemtypeimagelocation. >This value is only used from the 2 [opac-]shelves.pl scripts. Then it's >better not retrieve it only when we need it. > >Test plan: >Play with the different scripts touched by this patch and focus on item >types. The same description as prior to this patch must be displayed. >Note that sometimes it is not the translated description which is >displayed, but that should be fixed on another bug report. Indeed we do >not expect this patch to change any behaviors. > >Signed-off-by: Lari Taskula <lari.taskula@jns.fi> >--- > C4/Biblio.pm | 4 +++- > Koha/Template/Plugin/ItemTypes.pm | 6 +----- > acqui/orderreceive.pl | 5 +++-- > catalogue/getitem-ajax.pl | 5 +++-- > circ/transferstoreceive.pl | 5 +++-- > circ/waitingreserves.pl | 5 +++-- > members/summary-print.pl | 6 +++--- > opac/opac-browser.pl | 1 - > opac/opac-search.pl | 3 ++- > opac/opac-shelves.pl | 9 +++++---- > opac/opac-tags_subject.pl | 1 - > svc/checkouts | 5 +++-- > svc/holds | 5 +++-- > virtualshelves/shelves.pl | 9 +++++---- > 14 files changed, 37 insertions(+), 32 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index d52d780..80ca362 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -44,6 +44,7 @@ use Koha::Acquisition::Currencies; > use Koha::Biblio::Metadata; > use Koha::Biblio::Metadatas; > use Koha::Holds; >+use Koha::ItemTypes; > use Koha::SearchEngine; > use Koha::Libraries; > >@@ -1629,7 +1630,8 @@ sub GetAuthorisedValueDesc { > > #---- itemtypes > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) { >- return getitemtypeinfo($value)->{translated_description}; >+ my $itemtype = Koha::ItemTypes->find( $value ); >+ return $itemtype ? $itemtype->translated_description : q||; > } > > #---- "true" authorized value >diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm >index 449a491..74ccacc 100644 >--- a/Koha/Template/Plugin/ItemTypes.pm >+++ b/Koha/Template/Plugin/ItemTypes.pm >@@ -22,15 +22,11 @@ use Modern::Perl; > use Template::Plugin; > use base qw( Template::Plugin ); > >-use C4::Koha; > use Koha::ItemTypes; > > sub GetDescription { > my ( $self, $itemtype ) = @_; >- >- $itemtype = C4::Koha::getitemtypeinfo( $itemtype ); >- return $itemtype->{translated_description}; >- >+ return Koha::ItemTypes->find( $itemtype )->translated_description; > } > > sub Get { >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index f0dd664..f86a7a6 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -74,6 +74,7 @@ use C4::Suggestions; > > use Koha::Acquisition::Booksellers; > use Koha::DateUtils qw( dt_from_string ); >+use Koha::ItemTypes; > > my $input = new CGI; > >@@ -143,8 +144,8 @@ if ($AcqCreateItem eq 'receiving') { > $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); > $item->{materials} = $descriptions->{lib} // ''; > >- my $itemtype = getitemtypeinfo($item->{itype}); >- $item->{itemtype} = $itemtype->{description}; >+ my $itemtype = Koha::ItemsTypes->find( $item->{itype} ); >+ $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? > push @items, $item; > } > $template->param(items => \@items); >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >index 99814dc..10df69e 100755 >--- a/catalogue/getitem-ajax.pl >+++ b/catalogue/getitem-ajax.pl >@@ -29,6 +29,7 @@ use C4::Output; > use Koha::Libraries; > > use Koha::AuthorisedValues; >+use Koha::ItemTypes; > > my $cgi = new CGI; > >@@ -71,8 +72,8 @@ if($itemnumber) { > $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); > $item->{materials} = $descriptions->{lib} // ''; > >- my $itemtype = getitemtypeinfo($item->{itype}); >- $item->{itemtype} = $itemtype->{description}; >+ my $itemtype = Koha::ItemTypes->find( $item->{itype} ); >+ $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? > } > > my $json_text = to_json( $item, { utf8 => 1 } ); >diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl >index 20f14d1..27de65c 100755 >--- a/circ/transferstoreceive.pl >+++ b/circ/transferstoreceive.pl >@@ -35,6 +35,7 @@ use Date::Calc qw( > > use C4::Koha; > use C4::Reserves; >+use Koha::ItemTypes; > use Koha::Libraries; > use Koha::DateUtils; > use Koha::BiblioFrameworks; >@@ -88,10 +89,10 @@ while ( my $library = $libraries->next ) { > $getransf{'diff'} = $diff; > } > my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); >- my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} ); >+ my $itemtype = Koha::ItemTypes->find( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} ); > > $getransf{'datetransfer'} = $num->{'datesent'}; >- $getransf{'itemtype'} = $itemtypeinfo ->{'description'}; >+ $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? > foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) { > $getransf{$_} = $gettitle->{$_}; > } >diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl >index d0b3942..1249eed 100755 >--- a/circ/waitingreserves.pl >+++ b/circ/waitingreserves.pl >@@ -37,6 +37,7 @@ use C4::Reserves; > use C4::Koha; > use Koha::DateUtils; > use Koha::BiblioFrameworks; >+use Koha::ItemTypes; > > my $input = new CGI; > >@@ -105,7 +106,7 @@ foreach my $num (@getreserves) { > # fix up item type for display > $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'}; > my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'}); >- my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype >+ my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype > $getreserv{'waitingdate'} = $num->{'waitingdate'}; > my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'}); > >@@ -114,7 +115,7 @@ foreach my $num (@getreserves) { > $max_pickup_delay); > my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day ); > >- $getreserv{'itemtype'} = $itemtypeinfo->{'description'}; >+ $getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? > $getreserv{'title'} = $gettitle->{'title'}; > $getreserv{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'})); > $getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; >diff --git a/members/summary-print.pl b/members/summary-print.pl >index 14df30f..2d5eb47 100755 >--- a/members/summary-print.pl >+++ b/members/summary-print.pl >@@ -22,11 +22,11 @@ use CGI; > use C4::Auth; > use C4::Output; > use C4::Members; >-use C4::Koha qw( getitemtypeinfo ); > use C4::Circulation qw( GetIssuingCharges ); > use C4::Reserves; > use C4::Items; > use Koha::Holds; >+use Koha::ItemTypes; > > my $input = CGI->new; > my $borrowernumber = $input->param('borrowernumber'); >@@ -94,8 +94,8 @@ sub build_issue_data { > my ( $charge, $itemtype ) = > GetIssuingCharges( $issue->{itemnumber}, $borrowernumber ); > >- my $itemtypeinfo = getitemtypeinfo($itemtype); >- $row{'itemtype_description'} = $itemtypeinfo->{description}; >+ my $itemtype = Koha::ItemTypes->find( $itemtype ); >+ $row{'itemtype_description'} = $itemtype->description; #FIXME Should not it be translated_description > > $row{'charge'} = sprintf( "%.2f", $charge ); > >diff --git a/opac/opac-browser.pl b/opac/opac-browser.pl >index 64abf21..b2e8a60 100755 >--- a/opac/opac-browser.pl >+++ b/opac/opac-browser.pl >@@ -32,7 +32,6 @@ use C4::Context; > use C4::Output; > use CGI qw ( -utf8 ); > use C4::Biblio; >-use C4::Koha; # use getitemtypeinfo > > my $query = new CGI; > >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index e190fcd..faa0ca3 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -52,6 +52,7 @@ use C4::Tags qw(get_tags); > use C4::SocialData; > use C4::External::OverDrive; > >+use Koha::ItemTypes; > use Koha::LibraryCategories; > use Koha::Ratings; > use Koha::Virtualshelves; >@@ -225,7 +226,7 @@ my $itemtypes = GetItemTypesCategorized; > # add translated_description to itemtypes > foreach my $itemtype ( keys %{$itemtypes} ) { > # Itemtypes search categories don't have (yet) translated descriptions, they are auth values >- my $translated_description = getitemtypeinfo( $itemtype, 'opac' )->{translated_description}; >+ my $translated_description = Koha::ItemTypes->find( $itemtype )->translated_description; > $itemtypes->{$itemtype}->{translated_description} = > ( $translated_description ) ? $translated_description : $itemtypes->{$itemtype}->{description}; > } >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index 3240506..a27e5f6 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -30,6 +30,7 @@ use C4::Tags qw( get_tags ); > use C4::XSLT; > > use Koha::Biblioitems; >+use Koha::ItemTypes; > use Koha::Virtualshelves; > use Koha::RecordProcessor; > >@@ -280,10 +281,10 @@ if ( $op eq 'view' ) { > > my $marcflavour = C4::Context->preference("marcflavour"); > my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype; >- my $itemtypeinfo = getitemtypeinfo( $itemtype, 'opac' ); >- $this_item->{imageurl} = $itemtypeinfo->{imageurl}; >- $this_item->{description} = $itemtypeinfo->{description}; >- $this_item->{notforloan} = $itemtypeinfo->{notforloan}; >+ $itemtype = Koha::ItemTypes->find( $itemtype ); >+ $this_item->{imageurl} = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl ); >+ $this_item->{description} = $itemtype->description; #FIXME Should not it be translated_description? >+ $this_item->{notforloan} = $itemtype->notforloan; > $this_item->{'coins'} = GetCOinSBiblio($record); > $this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) ); > $this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour ); >diff --git a/opac/opac-tags_subject.pl b/opac/opac-tags_subject.pl >index 590e7a5..e5e182b 100755 >--- a/opac/opac-tags_subject.pl >+++ b/opac/opac-tags_subject.pl >@@ -32,7 +32,6 @@ use C4::Context; > use C4::Output; > use CGI qw ( -utf8 ); > use C4::Biblio; >-use C4::Koha; # use getitemtypeinfo > > my $query = new CGI; > >diff --git a/svc/checkouts b/svc/checkouts >index 0b0d329..d8d6156 100755 >--- a/svc/checkouts >+++ b/svc/checkouts >@@ -31,6 +31,7 @@ use C4::Context; > > use Koha::AuthorisedValues; > use Koha::DateUtils; >+use Koha::ItemTypes; > > my $input = new CGI; > >@@ -148,7 +149,7 @@ while ( my $c = $sth->fetchrow_hashref() ) { > my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = > GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); > >- my $itemtype = C4::Koha::getitemtypeinfo( $item_level_itypes ? $c->{itype} : $c->{itemtype} ); >+ my $itemtype = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} ); > my $location; > if ( $c->{location} ) { > my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} }); >@@ -170,7 +171,7 @@ while ( my $c = $sth->fetchrow_hashref() ) { > author => $c->{author}, > barcode => $c->{barcode}, > itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, >- itemtype_description => $itemtype->{translated_description}, >+ itemtype_description => $itemtype->translated_description, > location => $location, > homebranch => $c->{homebranch}, > itemnotes => $c->{itemnotes}, >diff --git a/svc/holds b/svc/holds >index 3c3a2b0..d84235b 100755 >--- a/svc/holds >+++ b/svc/holds >@@ -30,6 +30,7 @@ use C4::Context; > > use Koha::DateUtils; > use Koha::Holds; >+use Koha::ItemTypes; > use Koha::Libraries; > > my $input = new CGI; >@@ -75,8 +76,8 @@ while ( my $h = $holds_rs->next() ) { > > my $itemtype_limit; > if ( $h->itemtype ) { >- my $itemtype = C4::Koha::getitemtypeinfo( $h->itemtype ); >- $itemtype_limit = $itemtype->{translated_description}; >+ my $itemtype = Koha::ItemTypes->find( $h->itemtype ); >+ $itemtype_limit = $itemtype->translated_description; > } > > my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index c328869..2a74111 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -29,6 +29,7 @@ use C4::XSLT; > > use Koha::Biblios; > use Koha::Biblioitems; >+use Koha::ItemTypes; > use Koha::CsvProfiles; > use Koha::Virtualshelves; > >@@ -244,14 +245,14 @@ if ( $op eq 'view' ) { > > my $marcflavour = C4::Context->preference("marcflavour"); > my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype; >- my $itemtypeinfo = getitemtypeinfo( $itemtype, 'intranet' ); >+ $itemtype = Koha::ItemTypes->find( $itemtype ); > my $biblio = Koha::Biblios->find( $content->biblionumber ); > $this_item->{title} = $biblio->title; > $this_item->{author} = $biblio->author; > $this_item->{dateadded} = $content->dateadded; >- $this_item->{imageurl} = $itemtypeinfo->{imageurl}; >- $this_item->{description} = $itemtypeinfo->{description}; >- $this_item->{notforloan} = $itemtypeinfo->{notforloan}; >+ $this_item->{imageurl} = C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ); >+ $this_item->{description} = $itemtype->description; #FIXME Should not it be translated_description >+ $this_item->{notforloan} = $itemtype->notforloan; > $this_item->{'coins'} = GetCOinSBiblio($record); > $this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) ); > $this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour ); >-- >2.7.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 17843
:
58583
|
58584
|
61972
|
61973
|
62266
|
62267
|
64400
|
64401
|
64582
|
64583
|
64584