summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-11-25 06:08:29 +0100
committerByron Jones <glob@mozilla.com>2014-11-25 06:08:29 +0100
commit55d148d167630fce08f40e6fcf2ab9def0b9699d (patch)
treebe58dc3c44c5680c4574e3054b3be6ce9e5faebb /extensions/BMO
parent9bb992c0b0607328cc2356cb35b2d439fd7024af (diff)
downloadbugzilla-55d148d167630fce08f40e6fcf2ab9def0b9699d.tar.gz
bugzilla-55d148d167630fce08f40e6fcf2ab9def0b9699d.tar.xz
Bug 1103837: Bug Bounty Entry Form no longer edits bounty attachment description
Diffstat (limited to 'extensions/BMO')
-rw-r--r--extensions/BMO/Extension.pm5
-rw-r--r--extensions/BMO/template/en/default/hook/attachment/list-action.html.tmpl12
-rw-r--r--extensions/BMO/template/en/default/hook/bug/show-header-end.html.tmpl2
-rw-r--r--extensions/BMO/web/js/attachment_bounty_form.js18
4 files changed, 33 insertions, 4 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index cd712d7d6..700199f51 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -64,6 +64,7 @@ BEGIN {
*Bugzilla::Product::default_security_group_obj = \&_default_security_group_obj;
*Bugzilla::Product::group_always_settable = \&_group_always_settable;
*Bugzilla::check_default_product_security_group = \&_check_default_product_security_group;
+ *Bugzilla::Attachment::is_bounty_attachment = \&_is_bounty_attachment;
}
sub template_before_process {
@@ -206,7 +207,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 { $_ && _is_bounty_attachment($_) } @{$bug->attachments};
$vars->{bug} = $bug;
if ($input->{submit}) {
@@ -246,7 +247,7 @@ sub bounty_attachment {
}
}
-sub is_bounty_attachment {
+sub _is_bounty_attachment {
my ($attachment) = @_;
return 0 unless $attachment->filename eq 'bugbounty.data';
diff --git a/extensions/BMO/template/en/default/hook/attachment/list-action.html.tmpl b/extensions/BMO/template/en/default/hook/attachment/list-action.html.tmpl
new file mode 100644
index 000000000..9b2463f78
--- /dev/null
+++ b/extensions/BMO/template/en/default/hook/attachment/list-action.html.tmpl
@@ -0,0 +1,12 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% RETURN UNLESS user.in_group("bounty-team")
+ && attachment.is_bounty_attachment %]
+
+<span id="bounty_attachment"></span>
diff --git a/extensions/BMO/template/en/default/hook/bug/show-header-end.html.tmpl b/extensions/BMO/template/en/default/hook/bug/show-header-end.html.tmpl
index b7ce8675e..c9338aaf2 100644
--- a/extensions/BMO/template/en/default/hook/bug/show-header-end.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/bug/show-header-end.html.tmpl
@@ -21,7 +21,7 @@
"document.title = document.title.replace(/^" _ terms.Bug _ " /, '');"
%]
[% js_bug_id = bug.bug_id FILTER js %]
-[% IF user.is_insider %]
+[% IF user.in_group("bounty-team") %]
[% javascript = javascript _
"YAHOO.util.Event.onDOMReady(function () { " _
"add_bounty_attachment('$js_bug_id'); });"
diff --git a/extensions/BMO/web/js/attachment_bounty_form.js b/extensions/BMO/web/js/attachment_bounty_form.js
index cdec78276..59ffe8479 100644
--- a/extensions/BMO/web/js/attachment_bounty_form.js
+++ b/extensions/BMO/web/js/attachment_bounty_form.js
@@ -8,11 +8,27 @@
function add_bounty_attachment(bug_id) {
var nodes = YAHOO.util.Selector.query('#attachment_table tr.bz_attach_footer td');
if (nodes) {
+ var existing = document.getElementById('bounty_attachment');
var td = nodes[0];
var a = document.createElement('a');
a.href = 'page.cgi?id=attachment_bounty_form.html&bug_id=' + bug_id;
- a.appendChild(document.createTextNode('Add bounty tracking attachment'));
+ a.appendChild(document.createTextNode(existing
+ ? 'Edit bounty tracking attachment'
+ : 'Add bounty tracking attachment'));
td.appendChild(document.createElement('br'));
td.appendChild(a);
+
+ if (existing) {
+ var tr = existing.parentNode.parentNode;
+ if (tr.nodeName != 'TR')
+ return;
+ nodes = tr.getElementsByTagName('a');
+ for (var i = 0, il = nodes.length; i < il; i++) {
+ if (nodes[i].href.match(/attachment\.cgi\?id=\d+$/)) {
+ nodes[i].href = a.href;
+ return;
+ }
+ }
+ }
}
}