]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 306271: Group.pm needs a get_all_groups() routine - Patch by Frédéric Buclin...
authorlpsolit%gmail.com <>
Tue, 30 Aug 2005 23:39:05 +0000 (23:39 +0000)
committerlpsolit%gmail.com <>
Tue, 30 Aug 2005 23:39:05 +0000 (23:39 +0000)
Bugzilla/Group.pm
editgroups.cgi
template/en/default/admin/groups/list.html.tmpl

index 8f4c7885a462aa40f55db07ce3888a5ef48abcda..54fff489bca2b4bf1f859996a7751ad32502aca8 100644 (file)
@@ -145,6 +145,19 @@ sub get_group_controls_by_product {
     return $groups;
 }
 
+sub get_all_groups {
+    my $dbh = Bugzilla->dbh;
+
+    my $group_ids = $dbh->selectcol_arrayref('SELECT id FROM groups
+                                              ORDER BY isbuggroup, name');
+
+    my @groups;
+    foreach my $gid (@$group_ids) {
+        push @groups, new Bugzilla::Group($gid);
+    }
+    return @groups;
+}
+
 1;
 
 __END__
@@ -168,8 +181,8 @@ Bugzilla::Group - Bugzilla group class.
     my $is_active    = $group->is_active;
 
     my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
-
-    my $grops = Bugzilla::Group::get_group_controls_by_product(1);
+    my $groups = Bugzilla::Group::get_group_controls_by_product(1);
+    my @groups = Bugzilla::get_all_groups();
 
 =head1 DESCRIPTION
 
@@ -221,6 +234,15 @@ Group.pm represents a Bugzilla Group object.
  Returns:     A hash with group id as key and hash containing the
               group data as value.
 
+=item C<get_all_groups()>
+
+ Description: Returns all groups available, including both
+              system groups and bug groups.
+
+ Params:      none
+
+ Returns:     An array of group objects.
+
 =back
 
 =cut
index 62519fc54636335a91c274e3496f46b32556c59e..f032da7286b3ef2955dbd4b318dd7aad699de0d6 100755 (executable)
@@ -32,6 +32,7 @@ use lib ".";
 use Bugzilla;
 use Bugzilla::Constants;
 use Bugzilla::User;
+use Bugzilla::Group;
 require "globals.pl";
 
 my $cgi = Bugzilla->cgi;
@@ -146,33 +147,12 @@ sub CheckGroupRegexp {
 # If no action is specified, get a list of all groups available.
 
 unless ($action) {
-    my @groups;
-
-    my $group_list =
-      $dbh->selectall_arrayref('SELECT id, name, description,
-                                       userregexp, isactive, isbuggroup
-                                  FROM groups
-                                 ORDER BY isbuggroup, name');
-
-    foreach (@$group_list) {
-        my ($id, $name, $description, $regexp, $isactive, $isbuggroup) = @$_;
-        my $group = {};
-        $group->{'id'}          = $id;
-        $group->{'name'}        = $name;
-        $group->{'description'} = $description;
-        $group->{'regexp'}      = $regexp;
-        $group->{'isactive'}    = $isactive;
-        $group->{'isbuggroup'}  = $isbuggroup;
-
-        push(@groups, $group);
-    }
-
+    my @groups = Bugzilla::Group::get_all_groups();
     $vars->{'groups'} = \@groups;
     
     print $cgi->header();
     $template->process("admin/groups/list.html.tmpl", $vars)
       || ThrowTemplateError($template->error());
-
     exit;
 }
 
index 9e6520244d29f23f622c25cab32c6589bb299a6a..c183e4aff40cc329ddbd2e15716207316802d494 100644 (file)
@@ -27,7 +27,7 @@
   #   - id: number. The ID of the group.
   #   - name: string. The name of the group.
   #   - description: string. The description of the group.
-  #   - regexp: string. The user regexp for the given group.
+  #   - userregexp: string. The user regexp for the given group.
   #   - isactive: boolean int. Specifies if the group is active or not.
   #   - isbuggroup: boolean int. Specifies if it can be used for bugs.
   #%]
@@ -52,7 +52,7 @@
     <tr>
       <td>[% group.name FILTER html %]</td>
       <td>[% group.description FILTER html %]</td>
-      <td>[% group.regexp FILTER html %]&nbsp</td>
+      <td>[% group.userregexp FILTER html %]&nbsp</td>
 
       <td align="center">
         [% IF (group.isactive != 0) && (group.isbuggroup) %]