Bugzilla – Attachment 13903 Details for
Bug 9223
Multiple values of AdvancedSearchTypes in suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-9223-Multiple-values-of-AdvancedSearchTypes-in-s.patch (text/plain), 4.05 KB, created by
Fridolin Somers
on 2012-12-06 13:04:13 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2012-12-06 13:04:13 UTC
Size:
4.05 KB
patch
obsolete
>From 585cb1dc0dd9f38c6a82bd5fb35ed3fa4f606e8b Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Thu, 6 Dec 2012 13:56:26 +0100 >Subject: [PATCH] Bug 9223: Multiple values of AdvancedSearchTypes in > suggestions > >--- > C4/Koha.pm | 87 +++++++++++++++++++++++++++++------------------------------- > 1 file changed, 42 insertions(+), 45 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 3892468..16e7953 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -25,6 +25,7 @@ use strict; > > use C4::Context; > use C4::Branch qw(GetBranchesCount); >+use C4::ItemType; > use Memoize; > use DateTime; > use DateTime::Format::MySQL; >@@ -130,33 +131,23 @@ Returns a string with the name of the itemtype. > > =cut > >-sub GetSupportName{ >- my ($codestring)=@_; >- return if (! $codestring); >- my $resultstring; >- my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); >- if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { >- my $query = qq| >- SELECT description >- FROM itemtypes >- WHERE itemtype=? >- order by description >- |; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute($codestring); >- ($resultstring)=$sth->fetchrow; >- return $resultstring; >- } else { >- my $sth = >- C4::Context->dbh->prepare( >- "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?" >- ); >- $sth->execute( $advanced_search_types, $codestring ); >- my $data = $sth->fetchrow_hashref; >- return $$data{'lib'}; >- } >- >+sub GetSupportName { >+ my $codestring = shift; >+ return '' unless $codestring; >+ my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || 'itemtypes'; >+ for my $support_type ( split /\|/, $advanced_search_types ) { >+ if ( $support_type eq 'itemtypes' ) { >+ my $itemtype = getitemtypeinfo($codestring); >+ return $itemtype->{'description'} if $itemtype; >+ } >+ else { >+ my $lib = GetKohaAuthorisedValueLib( $support_type, $codestring ); >+ return $lib if $lib; >+ } >+ } >+ return ''; > } >+ > =head2 GetSupportList > > $itemtypes = &GetSupportList(); >@@ -185,23 +176,29 @@ build a HTML select with the following code : > > =cut > >-sub GetSupportList{ >- my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); >- if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { >- my $query = qq| >- SELECT * >- FROM itemtypes >- order by description >- |; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute; >- return $sth->fetchall_arrayref({}); >- } else { >- my $advsearchtypes = GetAuthorisedValues($advanced_search_types); >- my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes; >- return \@results; >- } >+sub GetSupportList { >+ my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || 'itemtypes'; >+ my @all_supports; >+ for my $support_type ( split /\|/, $advanced_search_types ) { >+ my @supports; >+ if ( $support_type eq 'itemtypes' ) { >+ @supports = C4::ItemType->all; >+ } >+ else { >+ my $authorised_values = GetAuthorisedValues($support_type); >+ @supports = map { >+ { >+ itemtype => $_->{authorised_value}, >+ description => $_->{lib}, >+ imageurl => $_->{imageurl} >+ } >+ } @$authorised_values; >+ } >+ push @all_supports, @supports; >+ } >+ return \@all_supports; > } >+ > =head2 GetItemTypes > > $itemtypes = &GetItemTypes(); >@@ -437,9 +434,9 @@ sub getitemtypeinfo { > my $sth = $dbh->prepare("select * from itemtypes where itemtype=?"); > $sth->execute($itemtype); > my $res = $sth->fetchrow_hashref; >- >- $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} ); >- >+ if ( $res ) { >+ $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} ); >+ } > return $res; > } > >-- >1.7.9.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 9223
:
13903
|
14427
|
14428
|
20015
|
20016
|
20017
|
35492
|
35493
|
35494
|
36178
|
36179
|
36702
|
36703
|
36704
|
40011
|
40012
|
40013
|
40014
|
40015
|
40016
|
42287
|
42288
|
42289
|
42290
|
42291
|
42336
|
42337
|
42338
|
42339
|
42340
|
44111
|
44113
|
44114
|
44115
|
44116
|
44117
|
44118