diff options
Diffstat (limited to 'post_bug.cgi')
-rwxr-xr-x | post_bug.cgi | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/post_bug.cgi b/post_bug.cgi index 6e1ecec81..006fd40ee 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -43,6 +43,8 @@ use Bugzilla::Keyword; use Bugzilla::Token; use Bugzilla::Flag; +use List::MoreUtils qw(uniq); + my $user = Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; @@ -60,16 +62,25 @@ unless ($cgi->param()) { exit; } +# BMO: Don't allow updating of bugs if disabled +if (Bugzilla->params->{disable_bug_updates}) { + ThrowErrorPage('bug/process/updates-disabled.html.tmpl', + 'Bug updates are currently disabled.'); +} + # Detect if the user already used the same form to submit a bug my $token = trim($cgi->param('token')); check_token_data($token, 'create_bug', 'index.cgi'); # do a match on the fields if applicable -Bugzilla::User::match_field ({ +# BMO: allow extensions to define custom user fields +my $user_match_fields = { 'cc' => { 'type' => 'multi' }, 'assigned_to' => { 'type' => 'single' }, 'qa_contact' => { 'type' => 'single' }, -}); +}; +Bugzilla::Hook::process('bug_user_match_fields', { fields => $user_match_fields }); +Bugzilla::User::match_field($user_match_fields); if (defined $cgi->param('maketemplate')) { $vars->{'url'} = $cgi->canonicalise_query('token'); @@ -122,7 +133,7 @@ push(@bug_fields, qw( version target_milestone status_whiteboard - + see_also estimated_time deadline )); @@ -144,6 +155,14 @@ foreach my $field (@multi_selects) { $bug_params{$field->name} = [$cgi->param($field->name)]; } +# BMO - add user_match_fields. it's important to source from input_params +# instead of $cgi->param to ensure we get the correct value. +foreach my $field (keys %$user_match_fields) { + next if exists $bug_params{$field}; + next unless $cgi->should_set($field); + $bug_params{$field} = Bugzilla->input_params->{$field} // []; +} + my $bug = Bugzilla::Bug->create(\%bug_params); # Get the bug ID back and delete the token used to create this bug. @@ -198,6 +217,7 @@ if ($data_fh || $attach_text) { if ($attachment) { # Set attachment flags. + Bugzilla::Hook::process('post_bug_attachment_flags', { bug => $bug }); my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi( $bug, $attachment, $vars, SKIP_REQUESTEE_ON_ERROR); $attachment->set_flags($flags, $new_flags); @@ -212,6 +232,11 @@ if ($data_fh || $attach_text) { } } +# Set bug_ignored from the hidden field +if (scalar $cgi->param('bug_ignored')) { + $bug->set_bug_ignored(1); +} + # Set bug flags. my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi($bug, undef, $vars, SKIP_REQUESTEE_ON_ERROR); @@ -230,12 +255,21 @@ my $bug_sent = Bugzilla::BugMail::Send($id, $recipients); $bug_sent->{type} = 'created'; $bug_sent->{id} = $id; my @all_mail_results = ($bug_sent); + foreach my $dep (@{$bug->dependson || []}, @{$bug->blocked || []}) { my $dep_sent = Bugzilla::BugMail::Send($dep, $recipients); $dep_sent->{type} = 'dep'; $dep_sent->{id} = $dep; push(@all_mail_results, $dep_sent); } + +# Sending emails for any referenced bugs. +foreach my $ref_bug_id (uniq @{ $bug->{see_also_changes} || [] }) { + my $ref_sent = Bugzilla::BugMail::Send($ref_bug_id, $recipients); + $ref_sent->{id} = $ref_bug_id; + push(@all_mail_results, $ref_sent); +} + $vars->{sentmail} = \@all_mail_results; $format = $template->get_format("bug/create/created", |