diff options
author | David Lawrence <dlawrence@mozilla.com> | 2011-10-24 23:01:42 +0200 |
---|---|---|
committer | David Lawrence <dlawrence@mozilla.com> | 2011-10-24 23:01:42 +0200 |
commit | b8a81e876126a327dccaf6a5694bbab295c5296a (patch) | |
tree | 9173644a66ccfc45608ec972f01831c3860d4991 /extensions/REMO/Extension.pm | |
parent | 3fa19c4c0f396ffe3a048ce6cbbd04c6e8bca6d0 (diff) | |
download | bugzilla-b8a81e876126a327dccaf6a5694bbab295c5296a.tar.gz bugzilla-b8a81e876126a327dccaf6a5694bbab295c5296a.tar.xz |
Bug 696272 - Amend form.reps.swag form results
r=glob
Diffstat (limited to 'extensions/REMO/Extension.pm')
-rw-r--r-- | extensions/REMO/Extension.pm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/extensions/REMO/Extension.pm b/extensions/REMO/Extension.pm index a0091281b..166cac4f5 100644 --- a/extensions/REMO/Extension.pm +++ b/extensions/REMO/Extension.pm @@ -181,4 +181,51 @@ sub _remo_form_payment { } } +sub post_bug_after_creation { + my ($self, $args) = @_; + my $vars = $args->{vars}; + my $bug = $vars->{bug}; + my $template = Bugzilla->template; + + if (Bugzilla->input_params->{format} eq 'remo-swag') { + # If the attachment cannot be successfully added to the bug, + # we notify the user, but we don't interrupt the bug creation process. + my $error_mode_cache = Bugzilla->error_mode; + Bugzilla->error_mode(ERROR_MODE_DIE); + + my $attachment; + eval { + my $xml; + $template->process("bug/create/create-remo-swag.xml.tmpl", {}, \$xml) + || ThrowTemplateError($template->error()); + + $attachment = Bugzilla::Attachment->create( + { bug => $bug, + creation_ts => $bug->creation_ts, + data => $xml, + description => 'Remo Swag Request (XML)', + filename => 'remo-swag.xml', + ispatch => 0, + isprivate => 0, + isurl => 0, + mimetype => 'text/xml', + store_in_file => 0, + }); + }; + + if ($attachment) { + # Insert comment for attachment + $bug->add_comment('', { isprivate => 0, + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id }); + $bug->update($bug->creation_ts); + } + else { + $vars->{'message'} = 'attachment_creation_failed'; + } + + Bugzilla->error_mode($error_mode_cache); + } +} + __PACKAGE__->NAME; |