[Koha-patches] [PATCH] Bug 5880 : C4/Koha.pm : adding two functions GetAutorisedValueByCode and GetKohaImageurlFromAuthorisedValues
Chris Cormack
chrisc at catalyst.net.nz
Wed Mar 16 04:06:45 CET 2011
From: Paul Poulain <paul.poulain at biblibre.com>
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
More information about the Koha-patches
mailing list