Merge remote branch 'kc/master' into new/enh/bug_5917
[koha_gimpoz] / C4 / Koha.pm
index 2bdcc28..eba9ae7 100644 (file)
@@ -2,6 +2,7 @@ package C4::Koha;
 
 # Copyright 2000-2002 Katipo Communications
 # Parts Copyright 2010 Nelsonville Public Library
+# Parts copyright 2010 BibLibre
 #
 # This file is part of Koha.
 #
@@ -57,6 +58,8 @@ BEGIN {
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValueLib
+      &GetAuthorisedValueByCode
+      &GetKohaImageurlFromAuthorisedValues
                &GetAuthValCode
                &GetNormalizedUPC
                &GetNormalizedISBN
@@ -941,6 +944,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 +1057,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.