summaryrefslogtreecommitdiffstats
path: root/email_in.pl
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-02-17 22:38:05 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2010-02-17 22:38:05 +0100
commit72c4efb6b8620e0e56ff6741971b952d468ce10d (patch)
treec4aa8adb2b83eec4bba29ef8aba8fd27390b4e44 /email_in.pl
parentd10c13e019acfb67df17e9360fda9e23c49059be (diff)
downloadbugzilla-72c4efb6b8620e0e56ff6741971b952d468ce10d.tar.gz
bugzilla-72c4efb6b8620e0e56ff6741971b952d468ce10d.tar.xz
Bug 494403: "Default" groups don't get set on bug creation using email_in.pl
r/a=mkanat
Diffstat (limited to 'email_in.pl')
-rwxr-xr-xemail_in.pl23
1 files changed, 22 insertions, 1 deletions
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' },