From 08892f4eecb96407245bb640d4c233da7557fe24 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 28 May 2004 08:26:57 +0000 Subject: [PATCH] adding authtype management (MARC authority types) --- C4/Koha.pm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 7faad9d0c2..b8cf506b72 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -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 + +
+ + "> + +
+ + +=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); -- 2.39.5