[Koha-patches] [PATCH] C4::Koha - added GetAuthorisedValueCategories

Galen Charlton galen.charlton at liblime.com
Sat May 10 01:08:16 CEST 2008


New convenience function to get list of authorised
value categories.

No user-visible changes.
---
 C4/Koha.pm |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/C4/Koha.pm b/C4/Koha.pm
index c473644..af9b913 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -51,6 +51,7 @@ BEGIN {
 		&getitemtypeimagedir
 		&getitemtypeimagesrc
 		&GetAuthorisedValues
+		&GetAuthorisedValueCategories
 		&GetKohaAuthorisedValues
 		&GetAuthValCode
 		&GetManagedTagSubfields
@@ -969,6 +970,26 @@ sub GetAuthorisedValues {
     return \@results; #$data;
 }
 
+=head2 GetAuthorisedValueCategories
+
+$auth_categories = GetAuthorisedValueCategories();
+
+Return an arrayref of all of the available authorised
+value categories.
+
+=cut
+
+sub GetAuthorisedValueCategories {
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category");
+    $sth->execute;
+    my @results;
+    while (my $category = $sth->fetchrow_array) {
+        push @results, $category;
+    }
+    return \@results;
+}
+
 =head2 GetKohaAuthorisedValues
 	
 	Takes $kohafield, $fwcode as parameters.
-- 
1.5.5.rc0.16.g02b00




More information about the Koha-patches mailing list