From 9e865838666f08c5505c1028a346f871559dbd90 Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Wed, 2 Feb 2005 00:26:25 +0000 Subject: Bug 279748 : Move GetFieldDefs out of globals.pl (to Bugzilla::DB) Patch by Max Kanat-Alexander r=vladd a=justdave --- Bugzilla/DB.pm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Bugzilla/DB.pm') diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index dcd419915..b500d748b 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -183,6 +183,26 @@ sub server_version { return $cached_server_version; } +sub GetFieldDefs { + my $dbh = Bugzilla->dbh; + + my $extra = ""; + if (!&::UserInGroup(Param('timetrackinggroup'))) { + $extra = "WHERE name NOT IN ('estimated time', 'remaining_time', " . + "'work_time', 'percentage_complete', 'deadline')"; + } + + my @fields; + my $sth = $dbh->prepare("SELECT name, description + FROM fielddefs $extra + ORDER BY sortkey"); + $sth->execute(); + while (my $field_ref = $sth->fetchrow_hashref()) { + push(@fields, $field_ref); + } + return(@fields); +} + 1; __END__ @@ -193,9 +213,14 @@ Bugzilla::DB - Database access routines, using L =head1 SYNOPSIS + # Connection my $dbh = Bugzilla::DB->connect_main; my $shadow = Bugzilla::DB->connect_shadow; + # Schema Information + my @fields = GetFieldDefs(); + + # Deprecated SendSQL("SELECT COUNT(*) FROM bugs"); my $cnt = FetchOneColumn(); @@ -209,6 +234,9 @@ Access to the old SendSQL-based database routines are also provided by importing the C<:deprecated> tag. These routines should not be used in new code. +The only functions that should be used by modern, regular Bugzilla code +are the "Schema Information" functions. + =head1 CONNECTION A new database handle to the required database can be created using this @@ -228,6 +256,18 @@ no shadow database is configured. =back +=head1 SCHEMA INFORMATION + +Bugzilla::DB also contains routines to get schema information about the +database. + +=over 4 + +=item C + +Returns a list of all the "bug" fields in Bugzilla. The list contains +hashes, with a 'name' key and a 'description' key. + =head1 DEPRECATED ROUTINES Several database routines are deprecated. They should not be used in new code, -- cgit v1.2.3-24-g4f1b