Commit e0946fe7 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 329022: Remove group_name_to_id in favor of creating Group objects - Patch…

Bug 329022: Remove group_name_to_id in favor of creating Group objects - Patch by Rémi Zara <remi_zara@mac.com> r=LpSolit a=justdave
parent 577a3b35
...@@ -25,11 +25,6 @@ use strict; ...@@ -25,11 +25,6 @@ use strict;
package Bugzilla::Group; package Bugzilla::Group;
use base qw(Exporter);
@Bugzilla::Group::EXPORT = qw(
group_name_to_id
);
use Bugzilla::Config; use Bugzilla::Config;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Error; use Bugzilla::Error;
...@@ -145,14 +140,6 @@ sub get_all_groups { ...@@ -145,14 +140,6 @@ sub get_all_groups {
return @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; 1;
__END__ __END__
...@@ -177,7 +164,6 @@ Bugzilla::Group - Bugzilla group class. ...@@ -177,7 +164,6 @@ Bugzilla::Group - Bugzilla group class.
my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users); my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
my @groups = Bugzilla::Group::get_all_groups(); my @groups = Bugzilla::Group::get_all_groups();
my $group_id = group_name_to_id('admin');
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -227,18 +213,6 @@ Group.pm represents a Bugzilla Group object. ...@@ -227,18 +213,6 @@ Group.pm represents a Bugzilla Group object.
Returns: An array of group objects. 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 =back
=cut =cut
...@@ -294,7 +294,7 @@ if ($action eq 'new') { ...@@ -294,7 +294,7 @@ if ($action eq 'new') {
undef, ($name, $desc, $regexp, $isactive)); undef, ($name, $desc, $regexp, $isactive));
my $gid = $dbh->bz_last_key('groups', 'id'); my $gid = $dbh->bz_last_key('groups', 'id');
my $admin = group_name_to_id('admin'); my $admin = Bugzilla::Group->new({name => 'admin'})->id();
# Since we created a new group, give the "admin" group all privileges # Since we created a new group, give the "admin" group all privileges
# initially. # initially.
my $sth = $dbh->prepare('INSERT INTO group_group_map my $sth = $dbh->prepare('INSERT INTO group_group_map
......
...@@ -235,7 +235,7 @@ if ($action eq 'new') { ...@@ -235,7 +235,7 @@ if ($action eq 'new') {
if (Param("makeproductgroups")) { if (Param("makeproductgroups")) {
# Next we insert into the groups table # Next we insert into the groups table
my $productgroup = $product->name; my $productgroup = $product->name;
while (group_name_to_id($productgroup)) { while (new Bugzilla::Group({name => $productgroup})) {
$productgroup .= '_'; $productgroup .= '_';
} }
my $group_description = "Access to bugs in the " . my $group_description = "Access to bugs in the " .
...@@ -250,7 +250,7 @@ if ($action eq 'new') { ...@@ -250,7 +250,7 @@ if ($action eq 'new') {
# If we created a new group, give the "admin" group priviledges # If we created a new group, give the "admin" group priviledges
# initially. # initially.
my $admin = group_name_to_id('admin'); my $admin = Bugzilla::Group->new({name => 'admin'})->id();
my $sth = $dbh->prepare('INSERT INTO group_group_map my $sth = $dbh->prepare('INSERT INTO group_group_map
(member_id, grantor_id, grant_type) (member_id, grantor_id, grant_type)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment