]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 332521: Remove GroupIdToName() from globals.pl - Patch by Frédéric Buclin <LpSoli...
authorlpsolit%gmail.com <>
Mon, 8 May 2006 02:56:04 +0000 (02:56 +0000)
committerlpsolit%gmail.com <>
Mon, 8 May 2006 02:56:04 +0000 (02:56 +0000)
Bugzilla/Flag.pm
Bugzilla/FlagType.pm
editproducts.cgi
globals.pl
process_bug.cgi

index 97d8e8c7cc3aa060bc7014eea2f824e5bca512a9..9d55fcf3342bc700c962ec0ee5b7a6cc34a06614 100644 (file)
@@ -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",
index b18c4a2decc6ac4a8eaa3d60a06206a1abde4de9..31300637772a32bd70a884a6bbb4eda6d7ea9c06 100644 (file)
@@ -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",
index 9123f034f40ebc1a1f65e828aa67b5108c31d03b..942375688a17a787461ced9465b6de1a50195797 100755 (executable)
@@ -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);
     }
index 38791a93bbc3b7f236d1c29fb4e591fbc5491fdc..ac95974d2d94b3c62a4150946b770207d8a2640e 100644 (file)
@@ -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;
index 9e0bc42bc84d861dda2bb4ec0c6587a175f9d7ee..8dfa4018dcbf8533d562a560bef0293a38ec347e 100755 (executable)
@@ -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);
             }
         }