Merge remote branch 'kc/master' into new/enh/bug_5917
[koha_fer] / C4 / Koha.pm
index 2f94aa0..95244bd 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,8 +58,8 @@ BEGIN {
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValueLib
-      &GetAuthorisedValueByCode
-      &GetKohaImageurlFromAuthorisedValues
+    &GetAuthorisedValueByCode
+    &GetKohaImageurlFromAuthorisedValues
                &GetAuthValCode
                &GetNormalizedUPC
                &GetNormalizedISBN
@@ -957,9 +958,9 @@ sub GetKohaImageurlFromAuthorisedValues {
     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'};
-     }
+    while ( my $data = $sth->fetchrow_hashref ) {
+        return $data->{'imageurl'};
+    }
 }
 
 =head2 GetAuthValCode
@@ -1050,7 +1051,7 @@ sub GetAuthorisedValueCategories {
     my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category");
     $sth->execute;
     my @results;
-    while (my $category = $sth->fetchrow_array) {
+    while (defined (my $category  = $sth->fetchrow_array) ) {
         push @results, $category;
     }
     return \@results;
@@ -1060,19 +1061,20 @@ sub GetAuthorisedValueCategories {
 
 $authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
 
-Return an hashref of the authorised value represented by $authvalcode.
+Return the lib attribute from authorised_values from the row identified
+by the passed category and code
 
 =cut
 
 sub GetAuthorisedValueByCode {
-       my ( $category, $authvalcode ) = @_;
-       
+    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'};
-     }
+    while ( my $data = $sth->fetchrow_hashref ) {
+        return $data->{'lib'};
+    }
 }
 
 =head2 GetKohaAuthorisedValues