summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/Extension.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-04-28 06:41:44 +0200
committerByron Jones <glob@mozilla.com>2015-04-28 06:41:44 +0200
commit29e3eb8b03ba072fa4ce092b45fb98c2e2352744 (patch)
tree38c4ab19d0e5bf1a81c927fd713c417f0d31e908 /extensions/BMO/Extension.pm
parent283be21f66e638667bc2ec7720cab459ecf1f698 (diff)
downloadbugzilla-29e3eb8b03ba072fa4ce092b45fb98c2e2352744.tar.gz
bugzilla-29e3eb8b03ba072fa4ce092b45fb98c2e2352744.tar.xz
Bug 1153102: add hooks for bug bounty display and form
Diffstat (limited to 'extensions/BMO/Extension.pm')
-rw-r--r--extensions/BMO/Extension.pm23
1 files changed, 18 insertions, 5 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 717f347de..40a00a625 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -73,7 +73,8 @@ BEGIN {
*Bugzilla::Product::default_platform = \&_product_default_platform;
*Bugzilla::Product::default_op_sys = \&_product_default_op_sys;
*Bugzilla::check_default_product_security_group = \&_check_default_product_security_group;
- *Bugzilla::Attachment::is_bounty_attachment = \&_is_bounty_attachment;
+ *Bugzilla::Attachment::is_bounty_attachment = \&_attachment_is_bounty_attachment;
+ *Bugzilla::Attachment::bounty_details = \&_attachment_bounty_details;
}
sub template_before_process {
@@ -224,7 +225,7 @@ sub bounty_attachment {
my $input = Bugzilla->input_params;
my $dbh = Bugzilla->dbh;
my $bug = Bugzilla::Bug->check({ id => $input->{bug_id}, cache => 1 });
- my $attachment = first { $_ && _is_bounty_attachment($_) } @{$bug->attachments};
+ my $attachment = first { $_ && _attachment_is_bounty_attachment($_) } @{$bug->attachments};
$vars->{bug} = $bug;
if ($input->{submit}) {
@@ -261,12 +262,11 @@ sub bounty_attachment {
}
if ($attachment) {
- my $form = parse_bounty_attachment_description($attachment->description);
- $vars->{form} = $form;
+ $vars->{form} = $attachment->bounty_details;
}
}
-sub _is_bounty_attachment {
+sub _attachment_is_bounty_attachment {
my ($attachment) = @_;
return 0 unless $attachment->filename eq 'bugbounty.data';
@@ -275,6 +275,19 @@ sub _is_bounty_attachment {
return $attachment->description =~ /^(?:[^,]*,)+[^,]*$/;
}
+sub _attachment_bounty_details {
+ my ($attachment) = @_;
+ if (!exists $attachment->{bounty_details}) {
+ if ($attachment->is_bounty_attachment) {
+ $attachment->{bounty_details} = parse_bounty_attachment_description($attachment->description);
+ }
+ else {
+ $attachment->{bounty_details} = undef;
+ }
+ }
+ return $attachment->{bounty_details};
+}
+
sub format_bounty_attachment_description {
my ($form) = @_;
my @fields = (