Bugzilla – Attachment 56267 Details for
Bug 17248
Koha::AuthorisedValues - Remove GetKohaAuthorisedValueLib
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 17248 - Koha::AuthorisedValues - Remove GetKohaAuthorisedValueLib
PASSED-QA-Bug-17248---KohaAuthorisedValues---Remov.patch (text/plain), 17.13 KB, created by
Katrin Fischer
on 2016-10-12 12:36:23 UTC
(
hide
)
Description:
[PASSED QA] Bug 17248 - Koha::AuthorisedValues - Remove GetKohaAuthorisedValueLib
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-10-12 12:36:23 UTC
Size:
17.13 KB
patch
obsolete
>From 4d6dae70fd23f01e0f931c7de713e657d8c388a9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 10 Aug 2016 13:04:48 +0100 >Subject: [PATCH] [PASSED QA] Bug 17248 - Koha::AuthorisedValues - Remove > GetKohaAuthorisedValueLib > >The subroutine C4::Koha::GetKohaAuthorisedValueLib just retrieves a description >(lib) for a given authorised value. > >We can easily replace it using: > Koha::AuthorisedValues->search({ category => $cat, authorised_value => $av })->lib >or > Koha::AuthorisedValues->search({ category => $cat, authorised_value => $av })->opac_description > >Test plan: >- On the detail page of a bibliographic record, the description for notforloan, >restricted and stack (?) should be correctly displayed >- View a shelf, the location (LOC) description should be displayed >- On the search result page, the location description should be displayed in the > facets >- Set AcqCreateItem=ordering and receiving items. >The description for notforloan, restricted, location, ccode, etc. field >should be displayed. >- When creating item in the acquisition module, the dropdown list for > field linked to AV should display the AV' descriptions >- On the transfers page, the description of the location should be > displayed. >- On the checkout list from the circulation.pl and returns.pl pages, the > description for "materials" should be displayed >- Fill some OPAC_SUG AV and create a suggestion, the reason dropdown > list should display the description of OPAC_SUG > >Signed-off-by: Claire Gravely <claire_gravely@hotmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > C4/Circulation.pm | 1 - > C4/Items.pm | 23 ++++++++++++++++------- > C4/Koha.pm | 22 ---------------------- > C4/Search.pm | 8 +++++--- > acqui/orderreceive.pl | 15 ++++++++++----- > catalogue/getitem-ajax.pl | 17 ++++++++++++----- > circ/branchtransfers.pl | 8 ++++++-- > circ/circulation.pl | 4 +++- > circ/returns.pl | 4 +++- > opac/opac-suggestions.pl | 5 ++++- > serials/subscription-detail.pl | 6 ++++-- > 11 files changed, 63 insertions(+), 50 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e2c2ec5..9940d44 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -37,7 +37,6 @@ use C4::Log; # logaction > use C4::Koha qw( > GetAuthorisedValueByCode > GetAuthValCode >- GetKohaAuthorisedValueLib > ); > use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units); > use C4::RotatingCollections qw(GetCollectionItemBranches); >diff --git a/C4/Items.pm b/C4/Items.pm >index 71b1619..7c5dfe6 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -34,6 +34,8 @@ use YAML qw/Load/; > use DateTime::Format::MySQL; > use Data::Dumper; # used as part of logging item record changes, not just for > # debugging; so please don't remove this >+ >+use Koha::AuthorisedValues; > use Koha::DateUtils qw/dt_from_string/; > use Koha::Database; > >@@ -1381,19 +1383,24 @@ sub GetItemsInfo { > > # get notforloan complete status if applicable > if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) { >- $data->{notforloanvalue} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan} ); >- $data->{notforloanvalueopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan}, 1 ); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} }); >+ $av = $av->count ? $av->next : undef; >+ $data->{notforloanvalue} = $av ? $av->lib : ''; >+ $data->{notforloanvalueopac} = $av ? $av->opac_description : ''; > } > > # get restricted status and description if applicable > if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) { >- $data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 ); >- $data->{restricted} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} ); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} }); >+ $av = $av->count ? $av->next : undef; >+ $data->{restricted} = $av ? $av->lib : ''; >+ $data->{restrictedopac} = $av ? $av->opac_description : ''; > } > > # my stack procedures > if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) { >- $data->{stack} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} ); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} }); >+ $data->{stack} = $av->count ? $av->next->lib : ''; > } > > # Find the last 3 people who borrowed this item. >@@ -1478,8 +1485,10 @@ sub GetItemsLocationInfo { > $sth->execute($biblionumber); > > while ( my $data = $sth->fetchrow_hashref ) { >- $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location}); >- $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1); >+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $data->{location} }); >+ $av = $av->count ? $av->next : undef; >+ $data->{location_intranet} = $av ? $av->lib : ''; >+ $data->{location_opac} = $av ? $av->opac_description : ''; > push @results, $data; > } > return @results; >diff --git a/C4/Koha.pm b/C4/Koha.pm >index de4e6a4..5c93cc2 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -55,7 +55,6 @@ BEGIN { > &GetKohaAuthorisedValues > &GetKohaAuthorisedValuesFromField > &GetKohaAuthorisedValuesMapping >- &GetKohaAuthorisedValueLib > &GetAuthorisedValueByCode > &GetAuthValCode > &GetNormalizedUPC >@@ -1153,27 +1152,6 @@ sub xml_escape { > return $str; > } > >-=head2 GetKohaAuthorisedValueLib >- >-Takes $category, $authorised_value as parameters. >- >-If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist. >- >-Returns authorised value description >- >-=cut >- >-sub GetKohaAuthorisedValueLib { >- my ($category,$authorised_value,$opac) = @_; >- my $value; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?"); >- $sth->execute($category,$authorised_value); >- my $data = $sth->fetchrow_hashref; >- $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'}; >- return $value; >-} >- > =head2 display_marc_indicators > > my $display_form = C4::Koha::display_marc_indicators($field); >diff --git a/C4/Search.pm b/C4/Search.pm >index a1296f9..ef61338 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -31,6 +31,8 @@ use C4::XSLT; > use C4::Reserves; # GetReserveStatus > use C4::Debug; > use C4::Charset; >+use Koha::AuthorisedValues; >+use Koha::Libraries; > use YAML; > use URI::Escape; > use Business::ISBN; >@@ -577,9 +579,9 @@ sub getRecords { > > # also, if it's a location code, use the name instead of the code > if ( $link_value =~ /location/ ) { >- $facet_label_value = >- GetKohaAuthorisedValueLib( 'LOC', >- $one_facet, $opac ); >+ # TODO Retrieve all authorised values at once, instead of 1 query per entry >+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet }); >+ $facet_label_value = $av->count ? $av->next->opac_description : ''; > } > > # but we're down with the whole label being in the link's title. >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 5be38a2..33c07cd 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -129,19 +129,24 @@ if ($AcqCreateItem eq 'receiving') { > foreach (@itemnumbers) { > my $item = GetItem($_); > if(my $code = GetAuthValCode("items.notforloan", $fw)) { >- $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} }); >+ $item->{notforloan} = $av->count ? $av->next->lib : ''; > } > if(my $code = GetAuthValCode("items.restricted", $fw)) { >- $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} }); >+ $item->{restricted} = $av->count ? $av->next->lib : ''; > } > if(my $code = GetAuthValCode("items.location", $fw)) { >- $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} }); >+ $item->{location} = $av->count ? $av->next->lib : ''; > } > if(my $code = GetAuthValCode("items.ccode", $fw)) { >- $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} }); >+ $item->{collection} = $av->count ? $av->next->lib : ''; > } > if(my $code = GetAuthValCode("items.materials", $fw)) { >- $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} }); >+ $item->{materials} = $av->count ? $av->next->lib : ''; > } > my $itemtype = getitemtypeinfo($item->{itype}); > $item->{itemtype} = $itemtype->{description}; >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >index fa0aa61..f79e4ad 100755 >--- a/catalogue/getitem-ajax.pl >+++ b/catalogue/getitem-ajax.pl >@@ -28,6 +28,8 @@ use C4::Koha; > use C4::Output; > use Koha::Libraries; > >+use Koha::AuthorisedValues; >+ > my $cgi = new CGI; > > my ( $status, $cookie, $sessionID ) = C4::Auth::check_api_auth( $cgi, { acquisition => 'order_receive' } ); >@@ -54,23 +56,28 @@ if($itemnumber) { > } > > if(my $code = GetAuthValCode("items.notforloan", $fw)) { >- $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{notforloan} }); >+ $item->{notforloan} = $av->count ? $av->next->lib : ''; > } > > if(my $code = GetAuthValCode("items.restricted", $fw)) { >- $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{restricted} }); >+ $item->{restricted} = $av->count ? $av->next->lib : ''; > } > > if(my $code = GetAuthValCode("items.location", $fw)) { >- $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{location} }); >+ $item->{location} = $av->count ? $av->next->lib : ''; > } > > if(my $code = GetAuthValCode("items.ccode", $fw)) { >- $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{collection} }); >+ $item->{collection} = $av->count ? $av->next->lib : ''; > } > > if(my $code = GetAuthValCode("items.materials", $fw)) { >- $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); >+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{materials} }); >+ $item->{materials} = $av->count ? $av->next->lib : ''; > } > > my $itemtype = getitemtypeinfo($item->{itype}); >diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl >index 5ed99b9..864db53 100755 >--- a/circ/branchtransfers.pl >+++ b/circ/branchtransfers.pl >@@ -32,6 +32,8 @@ use C4::Auth qw/:DEFAULT get_session/; > use C4::Koha; > use C4::Members; > >+use Koha::AuthorisedValues; >+ > ############################################### > # Getting state > >@@ -127,7 +129,8 @@ if ($barcode) { > $item{'itemtype'} = $iteminformation->{'itemtype'}; > $item{'ccode'} = $iteminformation->{'ccode'}; > $item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'}; >- $item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'}); >+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} }); >+ $item{'location'} = $av->count ? $av->next->lib : ''; > # } > $item{counter} = 0; > $item{barcode} = $barcode; >@@ -158,7 +161,8 @@ foreach ( $query->param ) { > $item{'itemtype'} = $iteminformation->{'itemtype'}; > $item{'ccode'} = $iteminformation->{'ccode'}; > $item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'}; >- $item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'}); >+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} }); >+ $item{'location'} = $av->count ? $av->next->lib : ''; > push( @trsfitemloop, \%item ); > } > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index fcd967d..848f0d4 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -42,6 +42,7 @@ use Koha::Holds; > use C4::Context; > use CGI::Session; > use C4::Members::Attributes qw(GetBorrowerAttributes); >+use Koha::AuthorisedValues; > use Koha::Patron; > use Koha::Patron::Debarments qw(GetDebarments); > use Koha::DateUtils; >@@ -391,7 +392,8 @@ if (@$barcodes) { > my $materials = $iteminfo->{'materials'}; > my $avcode = GetAuthValCode('items.materials'); > if ($avcode) { >- $materials = GetKohaAuthorisedValueLib($avcode, $materials); >+ my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials }); >+ $materials = $av->count ? $av->next->lib : ''; > } > $template_params->{additional_materials} = $materials; > $template_params->{itemhomebranch} = $iteminfo->{'homebranch'}; >diff --git a/circ/returns.pl b/circ/returns.pl >index e849a46..ec13c04 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -47,6 +47,7 @@ use C4::Members; > use C4::Members::Messaging; > use C4::Koha; # FIXME : is it still useful ? > use C4::RotatingCollections; >+use Koha::AuthorisedValues; > use Koha::DateUtils; > use Koha::Calendar; > >@@ -280,7 +281,8 @@ if ($barcode) { > my $materials = $biblio->{'materials'}; > my $avcode = GetAuthValCode('items.materials'); > if ($avcode) { >- $materials = GetKohaAuthorisedValueLib($avcode, $materials); >+ my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials }); >+ $materials = $av->count ? $av->next->lib : ''; > } > > $template->param( >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index 388e04a..cd8816a 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -27,6 +27,8 @@ use C4::Output; > use C4::Suggestions; > use C4::Koha; > use C4::Scrubber; >+ >+use Koha::AuthorisedValues; > use Koha::Libraries; > > use Koha::DateUtils qw( dt_from_string ); >@@ -184,7 +186,8 @@ foreach my $suggestion(@$suggestions_loop) { > $suggestion->{'showcheckbox'} = 0; > } > if($suggestion->{'patronreason'}){ >- $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1); >+ my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} }); >+ $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : ''; > } > } > >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index 824ffc2..6a2fdbd 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -25,8 +25,9 @@ use C4::Serials; > use C4::Output; > use C4::Context; > use C4::Search qw/enabled_staff_search_views/; >-use Koha::DateUtils; > >+use Koha::AuthorisedValues; >+use Koha::DateUtils; > use Koha::Acquisition::Bookseller; > > use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/; >@@ -103,7 +104,8 @@ for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) > $subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } ) > if $subs->{$date}; > } >-$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location}); >+my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} }); >+$subs->{location} = $av->count ? $av->next->lib : ''; > $subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid}); > $template->param(%{ $subs }); > $template->param(biblionumber_for_new_subscription => $subs->{bibnum}); >-- >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 17248
:
55175
|
55183
|
55267
|
55377
| 56267