Commit 46c78a8c authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 332521: Remove GroupIdToName() from globals.pl - Patch by Frédéric Buclin…

Bug 332521: Remove GroupIdToName() from globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
parent 0aeb1349
......@@ -374,12 +374,12 @@ sub validate {
# and can rerequest set flags.
next if (($status eq 'X' || $status eq '?')
&& (!$flag->{type}->{request_gid}
|| $user->in_group(&::GroupIdToName($flag->{type}->{request_gid}))));
|| $user->in_group_id($flag->{type}->{request_gid})));
# - User in the $grant_gid group can set/clear flags,
# including "+" and "-"
next if (!$flag->{type}->{grant_gid}
|| $user->in_group(&::GroupIdToName($flag->{type}->{grant_gid})));
|| $user->in_group_id($flag->{type}->{grant_gid}));
# - Any other flag modification is denied
ThrowUserError("flag_update_denied",
......
......@@ -431,12 +431,12 @@ sub validate {
# Make sure the user is authorized to modify flags, see bug 180879
# - User in the $grant_gid group can set flags, including "+" and "-"
next if (!$flag_type->{grant_gid}
|| $user->in_group(&::GroupIdToName($flag_type->{grant_gid})));
|| $user->in_group_id($flag_type->{grant_gid}));
# - User in the $request_gid group can request flags
next if ($status eq '?'
&& (!$flag_type->{request_gid}
|| $user->in_group(&::GroupIdToName($flag_type->{request_gid}))));
|| $user->in_group_id($flag_type->{request_gid})));
# - Any other flag modification is denied
ThrowUserError("flag_update_denied",
......
......@@ -660,11 +660,12 @@ if ($action eq 'updategroupcontrols') {
my $bugs = $dbh->selectall_arrayref($sth_Select, undef,
($groupid, $product->id));
my ($removed, $timestamp) =
$dbh->selectrow_array($sth_Select2, undef, $groupid);
foreach my $bug (@$bugs) {
my ($bugid, $mailiscurrent) = @$bug;
$sth_Delete->execute($bugid, $groupid);
my ($removed, $timestamp) =
$dbh->selectrow_array($sth_Select2, undef, $groupid);
LogActivityEntry($bugid, "bug_group", $removed, "",
$whoid, $timestamp);
......@@ -677,8 +678,7 @@ if ($action eq 'updategroupcontrols') {
}
$count++;
}
my %group = (name => GroupIdToName($groupid),
bug_count => $count);
my %group = (name => $removed, bug_count => $count);
push(@removed_na, \%group);
}
......@@ -703,11 +703,12 @@ if ($action eq 'updategroupcontrols') {
my $bugs = $dbh->selectall_arrayref($sth_Select, undef,
($groupid, $product->id));
my ($added, $timestamp) =
$dbh->selectrow_array($sth_Select2, undef, $groupid);
foreach my $bug (@$bugs) {
my ($bugid, $mailiscurrent) = @$bug;
$sth_Insert->execute($bugid, $groupid);
my ($added, $timestamp) =
$dbh->selectrow_array($sth_Select2, undef, $groupid);
LogActivityEntry($bugid, "bug_group", "", $added,
$whoid, $timestamp);
......@@ -720,8 +721,7 @@ if ($action eq 'updategroupcontrols') {
}
$count++;
}
my %group = (name => GroupIdToName($groupid),
bug_count => $count);
my %group = (name => $added, bug_count => $count);
push(@added_mandatory, \%group);
}
......
......@@ -306,15 +306,6 @@ sub get_legal_field_values {
return @$result_ref;
}
sub GroupIdToName {
my ($groupid) = (@_);
PushGlobalSQLState();
SendSQL("SELECT name FROM groups WHERE id = $groupid");
my $name = FetchOneColumn();
PopGlobalSQLState();
return $name;
}
############# Live code below here (that is, not subroutine defs) #############
use Bugzilla;
......
......@@ -1749,9 +1749,10 @@ foreach my $id (@idlist) {
VALUES (?, ?)});
foreach my $grouptoadd (@groupAdd, keys %groupsrequired) {
next if $groupsforbidden{$grouptoadd};
push(@groupAddNamesAll, GroupIdToName($grouptoadd));
my $group_obj = new Bugzilla::Group($grouptoadd);
push(@groupAddNamesAll, $group_obj->name);
if (!BugInGroupId($id, $grouptoadd)) {
push(@groupAddNames, GroupIdToName($grouptoadd));
push(@groupAddNames, $group_obj->name);
$sth->execute($id, $grouptoadd);
}
}
......@@ -1760,10 +1761,11 @@ foreach my $id (@idlist) {
$sth = $dbh->prepare(q{DELETE FROM bug_group_map
WHERE bug_id = ? AND group_id = ?});
foreach my $grouptodel (@groupDel, keys %groupsforbidden) {
push(@groupDelNamesAll, GroupIdToName($grouptodel));
my $group_obj = new Bugzilla::Group($grouptodel);
push(@groupDelNamesAll, $group_obj->name);
next if $groupsrequired{$grouptodel};
if (BugInGroupId($id, $grouptodel)) {
push(@groupDelNames, GroupIdToName($grouptodel));
push(@groupDelNames, $group_obj->name);
}
$sth->execute($id, $grouptodel);
}
......@@ -1985,10 +1987,12 @@ foreach my $id (@idlist) {
my $thisadd = grep( ($_ == $groupid), @groupstoadd);
my $thisdel = grep( ($_ == $groupid), @groupstoremove);
if ($thisadd) {
push(@DefGroupsAdded, GroupIdToName($groupid));
my $group_obj = new Bugzilla::Group($groupid);
push(@DefGroupsAdded, $group_obj->name);
$sth_insert->execute($id, $groupid);
} elsif ($thisdel) {
push(@DefGroupsRemoved, GroupIdToName($groupid));
my $group_obj = new Bugzilla::Group($groupid);
push(@DefGroupsRemoved, $group_obj->name);
$sth_delete->execute($id, $groupid);
}
}
......
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