From 42d23b11188853401a1e152b4a43ea4da18ec717 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 13 Jul 2005 05:02:10 +0000 Subject: Bug 294160: Step 1 (RO): Create libraries for Products, Components, Classifications, Milestones, and Versions - Patch by Tiago R. Mello r=mkanat a=myk --- Bugzilla/Group.pm | 72 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 14 deletions(-) (limited to 'Bugzilla/Group.pm') 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 -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 +=item C -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 + + 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 - Erik Stambaugh - Tiago R. Mello + 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 -- cgit v1.2.3-24-g4f1b