Bugzilla – Attachment 190475 Details for
Bug 41435
Use template plugin with built in caching for authorised value conversions in search results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41435: Use AuthorisedValues.GetDescriptionByKohaField for search results
Bug-41435-Use-AuthorisedValuesGetDescriptionByKoha.patch (text/plain), 9.59 KB, created by
David Nind
on 2025-12-13 02:01:53 UTC
(
hide
)
Description:
Bug 41435: Use AuthorisedValues.GetDescriptionByKohaField for search results
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-12-13 02:01:53 UTC
Size:
9.59 KB
patch
obsolete
>From 6734000f6f3ae7767c90cf48702f5f5f4e138478 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 11 Dec 2025 21:27:27 +0000 >Subject: [PATCH] Bug 41435: Use AuthorisedValues.GetDescriptionByKohaField for > search results > >To test: > 1 - Do some search on the interface > 2 - Check the results > 3 - Apply patch > 4 - Restart all > 5 - Confirm notforloan, collectioncode, and shelving locations are still correctly described > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Search.pm | 50 +++---------------- > .../prog/en/modules/catalogue/results.tt | 6 +-- > 2 files changed, 11 insertions(+), 45 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 5d6f3c6e33..23dd75db4f 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -541,20 +541,14 @@ sub getRecords { > > # also, if it's a location code, use the name instead of the code > if ( $link_value =~ /location/ ) { >- >- # 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 : ''; >+ $facet_label_value = Koha::AuthorisedValues->search( >+ { kohafield => 'items.location', authorised_value => $one_facet } ); > } > > # also, if it's a collection code, use the name instead of the code > if ( $link_value =~ /ccode/ ) { >- >- # TODO Retrieve all authorised values at once, instead of 1 query per entry >- my $av = Koha::AuthorisedValues->search( >- { category => 'CCODE', authorised_value => $one_facet } ); >- $facet_label_value = $av->count ? $av->next->opac_description : ''; >+ $facet_label_value = Koha::AuthorisedValues->search( >+ { kohafield => 'items.ccode', authorised_value => $one_facet } ); > } > > # but we're down with the whole label being in the link's title. >@@ -1678,24 +1672,6 @@ sub searchResults { > my %branches = > map { $_->branchcode => $_->branchname } Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list; > >- # FIXME - We build an authorised values hash here, using the default framework >- # though it is possible to have different authvals for different fws. >- >- my $shelflocations = { >- map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( >- { frameworkcode => '', kohafield => 'items.location' } >- ) >- }; >- >- # get notforloan authorised value list (see $shelflocations FIXME) >- my $av = Koha::MarcSubfieldStructures->search( >- { >- frameworkcode => '', kohafield => 'items.notforloan', >- authorised_value => [ -and => { '!=' => undef }, { '!=' => '' } ] >- } >- ); >- my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef; >- > #Get itemtype hash > my $itemtypes = Koha::ItemTypes->search_with_localization; > my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed }; >@@ -1912,15 +1888,13 @@ sub searchResults { > $onloan_items->{$key}->{count}++ if $item->{$hbranch}; > $onloan_items->{$key}->{branchname} = $item->{branchname}; > $onloan_items->{$key}->{branchcode} = $item->{branchcode}; >- $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; > $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber}; > $onloan_items->{$key}->{description} = $item->{description}; > $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( > $search_context->{'interface'}, > $itemtypes{ $item->{itype} }->{imageurl} > ); >- $onloan_items->{$key}->{collectioncode} = >- GetAuthorisedValueDesc( '', '', $item->{ccode}, '', '', 'CCODE' ); >+ $onloan_items->{$key}->{collectioncode} = $item->{ccode}; > > # if something's checked out and lost, mark it as 'long overdue' > if ( $item->{itemlost} ) { >@@ -2026,18 +2000,13 @@ sub searchResults { > $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0; > $other_items->{$key}->{recalled} = ($recallstatus) ? 1 : 0; > $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0; >- $other_items->{$key}->{notforloan} = >- GetAuthorisedValueDesc( '', '', $item->{notforloan}, '', '', $notforloan_authorised_value ) >- if $notforloan_authorised_value and $item->{notforloan}; > $other_items->{$key}->{count}++ if $item->{$hbranch}; >- $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; > $other_items->{$key}->{description} = $item->{description}; > $other_items->{$key}->{imageurl} = getitemtypeimagelocation( > $search_context->{'interface'}, > $itemtypes{ $item->{itype} // q{} }->{imageurl} > ); >- $other_items->{$key}->{collectioncode} = >- GetAuthorisedValueDesc( '', '', $item->{ccode}, '', '', 'CCODE' ); >+ $other_items->{$key}->{collectioncode} = $item->{ccode}; > } > > # item is available >@@ -2051,14 +2020,11 @@ sub searchResults { > } > $available_items->{$prefix}->{branchavailablecount} = $branch_available_count; > $available_items->{$prefix}->{branchcode} = $item->{branchcode}; >- $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } >- if $item->{location}; >- $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( >+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( > $search_context->{'interface'}, > $itemtypes{ $item->{itype} // q{} }->{imageurl} > ); >- $available_items->{$prefix}->{collectioncode} = >- GetAuthorisedValueDesc( '', '', $item->{ccode}, '', '', 'CCODE' ); >+ $available_items->{$prefix}->{collectioncode} = $item->{ccode}; > } > } > } # notforloan, item level and biblioitem level >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index c04479af86..0fb03cc9db 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -827,10 +827,10 @@ > [% items_loo.branchname | html %] > [% END %] > [% IF ( items_loo.location ) %] >- <span class="shelvingloc">[% items_loo.location | html %]</span> >+ <span class="shelvingloc">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => items_loo.location ) | html %]</span> > [% END %] > [% IF ( items_loo.collectioncode ) %] >- <span class="ccode">[% items_loo.collectioncode | html %]</span> >+ <span class="ccode">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => items_loo.collectioncode ) | html %]</span> > [% END %] > > [% IF ( items_loo.itemcallnumber ) %] >@@ -853,7 +853,7 @@ > (<span>On hold</span>) > [% END %] > [% IF ( items_loo.notforloan ) %] >- [% items_loo.notforloan | html %] >+ [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => items_loo.notforloan ) | html %] > [% END %] > <span class="item_count">[% items_loo.count | html %]</span> > </div> >-- >2.39.5
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 41435
:
190447
|
190448
| 190475