adding authtype management (MARC authority types)
authortipaul <tipaul>
Fri, 28 May 2004 08:26:57 +0000 (08:26 +0000)
committertipaul <tipaul>
Fri, 28 May 2004 08:26:57 +0000 (08:26 +0000)
C4/Koha.pm

index 7faad9d..b8cf506 100644 (file)
@@ -58,6 +58,7 @@ Koha.pm provides many functions for Koha scripts.
                        &getbranches &getbranch
                        &getprinters &getprinter
                        &getitemtypes &getitemtypeinfo
+                       &getauthtypes
                        $DEBUG);
 
 use vars qw();
@@ -221,7 +222,7 @@ sub getbranches {
        return (\%branches);
 }
 
-=head2 itemtypes
+=head2 getitemtypes
 
   $itemtypes = &getitemtypes();
 
@@ -271,8 +272,57 @@ sub getitemtypes {
        return (\%itemtypes);
 }
 
+=head2 getauthtypes
 
-=head2 itemtypes
+  $authtypes = &getauthtypes();
+
+Returns information about existing authtypes.
+
+build a HTML select with the following code :
+
+=head3 in PERL SCRIPT
+
+my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype (keys %$authtypes) {
+       my $selected = 1 if $thisauthtype eq $authtype;
+       my %row =(value => $thisauthtype,
+                               selected => $selected,
+                               authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'},
+                       );
+       push @authtypesloop, \%row;
+}
+$template->param(itemtypeloop => \@itemtypesloop);
+
+=head3 in TEMPLATE
+
+<form action='<!-- TMPL_VAR name="script_name" -->' method=post>
+       <select name="authtype">
+       <!-- TMPL_LOOP name="authtypeloop" -->
+               <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="authtypetext" --></option>
+       <!-- /TMPL_LOOP -->
+       </select>
+       <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
+       <input type="submit" value="OK" class="button">
+</form>
+
+
+=cut
+
+sub getauthtypes {
+# returns a reference to a hash of references to authtypes...
+       my %authtypes;
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->prepare("select * from auth_types order by authtypetext");
+       $sth->execute;
+       while (my $IT=$sth->fetchrow_hashref) {
+                       $authtypes{$IT->{'authtypecode'}}=$IT;
+       }
+       return (\%authtypes);
+}
+
+
+=head2 getitemtypeinfo
 
   $itemtype = &getitemtype($itemtype);