From 72c4efb6b8620e0e56ff6741971b952d468ce10d Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Wed, 17 Feb 2010 22:38:05 +0100 Subject: Bug 494403: "Default" groups don't get set on bug creation using email_in.pl r/a=mkanat --- email_in.pl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'email_in.pl') diff --git a/email_in.pl b/email_in.pl index c7b11d8a7..7f2b2f6e4 100755 --- a/email_in.pl +++ b/email_in.pl @@ -47,7 +47,7 @@ use Bugzilla; use Bugzilla::Attachment; use Bugzilla::Bug; use Bugzilla::BugMail; -use Bugzilla::Constants qw(USAGE_MODE_EMAIL CMT_ATTACHMENT_CREATED); +use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Mailer; use Bugzilla::Token; @@ -145,6 +145,8 @@ sub post_bug { my ($fields) = @_; debug_print('Posting a new bug...'); + my $user = Bugzilla->user; + # Bugzilla::Bug->create throws a confusing CodeError if # the REQUIRED_CREATE_FIELDS are missing, but much more # sensible errors if the fields exist but are just undef. @@ -152,6 +154,25 @@ sub post_bug { $fields->{$field} = undef if !exists $fields->{$field}; } + # Restrict the bug to groups marked as Default. + # We let Bug->create throw an error if the product is + # not accessible, to throw the correct message. + my $product = new Bugzilla::Product({ name => $fields->{product} }); + if ($product) { + my @gids; + my $controls = $product->group_controls; + foreach my $gid (keys %$controls) { + if (($controls->{$gid}->{membercontrol} == CONTROLMAPDEFAULT + && $user->in_group_id($gid)) + || ($controls->{$gid}->{othercontrol} == CONTROLMAPDEFAULT + && !$user->in_group_id($gid))) + { + push(@gids, $gid); + } + } + $fields->{groups} = \@gids; + } + my ($retval, $non_conclusive_fields) = Bugzilla::User::match_field({ 'assigned_to' => { 'type' => 'single' }, -- cgit v1.2.3-24-g4f1b