summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-09-10 11:20:24 +0200
committermkanat%bugzilla.org <>2006-09-10 11:20:24 +0200
commit1a4d88f3293090175276c9b81cfe6727483f7ae8 (patch)
treebb0c7ada3af86a2c6e863b5f558116add8c3ad4a /Bugzilla
parent38703b61ea57237fbca0becdb3e5dde0066627d0 (diff)
downloadbugzilla-1a4d88f3293090175276c9b81cfe6727483f7ae8.tar.gz
bugzilla-1a4d88f3293090175276c9b81cfe6727483f7ae8.tar.xz
Bug 351332: Move Group validation into Bugzilla::Bug from post_bug.cgi
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=justdave
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm46
1 files changed, 46 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 6e8079d27..46b247425 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -521,6 +521,52 @@ sub _check_estimated_time {
return $_[0]->_check_time($_[1], 'estimated_time');
}
+sub _check_groups {
+ my ($invocant, $product, $group_ids) = @_;
+
+ my $user = Bugzilla->user;
+
+ my %add_groups;
+ my $controls = $product->group_controls;
+
+ foreach my $id (@$group_ids) {
+ my $group = new Bugzilla::Group($id)
+ || ThrowUserError("invalid_group_ID");
+
+ # This can only happen if somebody hacked the enter_bug form.
+ ThrowCodeError("inactive_group", { name => $group->name })
+ unless $group->is_active;
+
+ my $membercontrol = $controls->{$id}
+ && $controls->{$id}->{membercontrol};
+ my $othercontrol = $controls->{$id}
+ && $controls->{$id}->{othercontrol};
+
+ my $permit = ($membercontrol && $user->in_group($group->name))
+ || $othercontrol;
+
+ $add_groups{$id} = 1 if $permit;
+ }
+
+ foreach my $id (keys %$controls) {
+ next unless $controls->{$id}->{isactive};
+ my $membercontrol = $controls->{$id}->{membercontrol} || 0;
+ my $othercontrol = $controls->{$id}->{othercontrol} || 0;
+
+ # Add groups required
+ if ($membercontrol == CONTROLMAPMANDATORY
+ || ($othercontrol == CONTROLMAPMANDATORY
+ && !$user->in_group_id($id)))
+ {
+ # User had no option, bug needs to be in this group.
+ $add_groups{$id} = 1;
+ }
+ }
+
+ my @add_groups = keys %add_groups;
+ return \@add_groups;
+}
+
sub _check_keywords {
my ($invocant, $keyword_string) = @_;
$keyword_string = trim($keyword_string);