summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Group.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-13 07:02:10 +0200
committerlpsolit%gmail.com <>2005-07-13 07:02:10 +0200
commit42d23b11188853401a1e152b4a43ea4da18ec717 (patch)
tree50bb8f3db07a960d382105ed9b8bbdfe8de947cf /Bugzilla/Group.pm
parent665e7425ee74b9cdf99baaf3f1758855959b9c18 (diff)
downloadbugzilla-42d23b11188853401a1e152b4a43ea4da18ec717.tar.gz
bugzilla-42d23b11188853401a1e152b4a43ea4da18ec717.tar.xz
Bug 294160: Step 1 (RO): Create libraries for Products, Components, Classifications, Milestones, and Versions - Patch by Tiago R. Mello <timello@async.com.br> r=mkanat a=myk
Diffstat (limited to 'Bugzilla/Group.pm')
-rw-r--r--Bugzilla/Group.pm72
1 files changed, 58 insertions, 14 deletions
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index 85e6de5b1..808860274 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -106,7 +106,7 @@ sub is_active { return $_[0]->{'isactive'}; }
##### Module Subroutines ###
################################
-sub ValidateGroupName {
+sub ValidateGroupName ($$) {
my ($name, @users) = (@_);
my $dbh = Bugzilla->dbh;
my $query = "SELECT id FROM groups " .
@@ -125,13 +125,34 @@ sub ValidateGroupName {
return $ret;
}
+sub get_group_controls_by_product ($) {
+ my ($product_id) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ my $query = qq{SELECT
+ $columns,
+ group_control_map.entry,
+ group_control_map.membercontrol,
+ group_control_map.othercontrol,
+ group_control_map.canedit
+ FROM groups
+ LEFT JOIN group_control_map
+ ON groups.id = group_control_map.group_id
+ WHERE group_control_map.product_id = ?
+ AND groups.isbuggroup != 0
+ ORDER BY groups.name};
+ my $groups = $dbh->selectall_hashref($query, 'id', undef,
+ ($product_id));
+ return $groups;
+}
+
1;
__END__
=head1 NAME
-Bugzilla::Group - Object for a Bugzilla group.
+Bugzilla::Group - Bugzilla group class.
=head1 SYNOPSIS
@@ -147,6 +168,10 @@ Bugzilla::Group - Object for a Bugzilla group.
my $user_reg_exp = $group->user_reg_exp;
my $is_active = $group->is_active;
+ my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
+
+ my $grops = Bugzilla::Group::get_group_controls_by_product(1);
+
=head1 DESCRIPTION
Group.pm represents a Bugzilla Group object.
@@ -157,8 +182,16 @@ Group.pm represents a Bugzilla Group object.
=item C<new($param)>
-The constructor is used to load an existing group by passing
-a group id or a hash with the group name.
+ Description: The constructor is used to load an existing group
+ by passing a group id or a hash with the group name.
+
+ Params: $param - If you pass an integer, the integer is the
+ group id from the database that we want to
+ read in. If you pass in a hash with 'name'
+ key, then the value of the name key is the
+ name of a product from the DB.
+
+ Returns: A Bugzilla::Group object.
=back
@@ -166,18 +199,29 @@ a group id or a hash with the group name.
=over
-=item C<ValidateGroupName($group_name, @users)>
+=item C<ValidateGroupName($name, @users)>
-ValidateGroupName checks to see if ANY of the users in the provided list
-of user objects can see the named group. It returns the group id if
-successful and undef otherwise.
+ Description: ValidateGroupName checks to see if ANY of the users
+ in the provided list of user objects can see the
+ named group.
-=back
+ Params: $name - String with the group name.
+ @users - An array with Bugzilla::User objects.
+
+ Returns: It returns the group id if successful
+ and undef otherwise.
+
+=item C<get_group_controls_by_product($product_id)>
+
+ Description: Returns all group controls of a specific product.
+ It is encouraged to use Bugzilla::Product object
+ instead of directly calling this routine.
-=head1 AUTHOR
-
- Joel Peshkin <bugreport@peshkin.net>
- Erik Stambaugh <erik@dasbistro.com>
- Tiago R. Mello <timello@async.com.br>
+ Params: $product_id - Integer with a Bugzilla product id.
+
+ Returns: A hash with group id as key and hash containing the
+ group data as value.
+
+=back
=cut