summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Group.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2006-03-02 06:33:01 +0100
committermkanat%kerio.com <>2006-03-02 06:33:01 +0100
commit9fcdc67a551a089ebd926a560580e77c58c8ae21 (patch)
tree182d6cdc1d1c5c50ee13baed0fd7b333d7ce6316 /Bugzilla/Group.pm
parent877a6c19c0974eb7e51856b7a2314dbee6079893 (diff)
downloadbugzilla-9fcdc67a551a089ebd926a560580e77c58c8ae21.tar.gz
bugzilla-9fcdc67a551a089ebd926a560580e77c58c8ae21.tar.xz
Bug 328435: Move GroupNameToId into Bugzilla/Group.pm and eliminate GroupExists
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=justdave
Diffstat (limited to 'Bugzilla/Group.pm')
-rw-r--r--Bugzilla/Group.pm28
1 files changed, 27 insertions, 1 deletions
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index 32c4696db..b561f0040 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -25,6 +25,11 @@ use strict;
package Bugzilla::Group;
+use base qw(Exporter);
+@Bugzilla::Group::EXPORT = qw(
+ group_name_to_id
+);
+
use Bugzilla::Config;
use Bugzilla::Util;
use Bugzilla::Error;
@@ -140,6 +145,14 @@ sub get_all_groups {
return @groups;
}
+sub group_name_to_id {
+ my ($name) = @_;
+ trick_taint($name);
+ my ($id) = Bugzilla->dbh->selectrow_array(
+ "SELECT id FROM groups WHERE name = ?", undef, $name);
+ return $id;
+}
+
1;
__END__
@@ -163,7 +176,8 @@ Bugzilla::Group - Bugzilla group class.
my $is_active = $group->is_active;
my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
- my @groups = Bugzilla::get_all_groups();
+ my @groups = Bugzilla::Group::get_all_groups();
+ my $group_id = group_name_to_id('admin');
=head1 DESCRIPTION
@@ -213,6 +227,18 @@ Group.pm represents a Bugzilla Group object.
Returns: An array of group objects.
+=item C<group_name_to_id($name)>
+
+ Description: Converts a group name to an id.
+ In general, instead of using this function, you should
+ create a Group object and get its name. This function
+ does not offer any real performance advantage.
+
+ Params: $name - The name of a group.
+
+ Returns: The numeric id of the group with that name,
+ or C<undef> if the group does not exist.
+
=back
=cut