From ef329c7f0b0e3d614f4ded4253feaf98de69da76 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 15 Dec 2010 13:58:11 +0100 Subject: [PATCH] Bug 5880 : C4/Koha.pm : adding two functions GetAutorisedValueByCode and GetKohaImageurlFromAuthorisedValues just for convenience --- C4/Koha.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 2bdcc28..2f94aa0 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -57,6 +57,8 @@ BEGIN { &GetKohaAuthorisedValues &GetKohaAuthorisedValuesFromField &GetKohaAuthorisedValueLib + &GetAuthorisedValueByCode + &GetKohaImageurlFromAuthorisedValues &GetAuthValCode &GetNormalizedUPC &GetNormalizedISBN @@ -941,6 +943,25 @@ sub displayServers { return \@primaryserverloop; } + +=head2 GetKohaImageurlFromAuthorisedValues + +$authhorised_value = GetKohaImageurlFromAuthorisedValues( $category, $authvalcode ); + +Return the first url of the authorised value image represented by $lib. + +=cut + +sub GetKohaImageurlFromAuthorisedValues { + my ( $category, $lib ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT imageurl FROM authorised_values WHERE category=? AND lib =?"); + $sth->execute( $category, $lib ); + while ( my $data = $sth->fetchrow_hashref ) { + return $data->{'imageurl'}; + } +} + =head2 GetAuthValCode $authvalcode = GetAuthValCode($kohafield,$frameworkcode); @@ -1035,6 +1056,25 @@ sub GetAuthorisedValueCategories { return \@results; } +=head2 GetAuthorisedValueByCode + +$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode ); + +Return an hashref of the authorised value represented by $authvalcode. + +=cut + +sub GetAuthorisedValueByCode { + my ( $category, $authvalcode ) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?"); + $sth->execute( $category, $authvalcode ); + while ( my $data = $sth->fetchrow_hashref ) { + return $data->{'lib'}; + } +} + =head2 GetKohaAuthorisedValues Takes $kohafield, $fwcode as parameters. -- 1.7.1