summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-03-04 19:49:50 +0100
committerByron Jones <bjones@mozilla.com>2013-03-04 19:49:50 +0100
commit6919f41e51cacaa8f6b4ae7bcdbd010c8d6aefe5 (patch)
treeb03bd17dc6dd680197d1ef44d350543e82096490 /extensions
parent1143f1d0a5162c60e8bc893f0c9c6f2c5aa559d0 (diff)
downloadbugzilla-6919f41e51cacaa8f6b4ae7bcdbd010c8d6aefe5.tar.gz
bugzilla-6919f41e51cacaa8f6b4ae7bcdbd010c8d6aefe5.tar.xz
Bug 834119: add the ability to force users into using a custom bug format
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/Extension.pm53
-rw-r--r--extensions/BMO/lib/Data.pm38
-rw-r--r--extensions/BMO/lib/Reports.pm14
-rw-r--r--extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl10
-rw-r--r--extensions/GuidedBugEntry/web/js/guided.js15
5 files changed, 90 insertions, 40 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 554fb2ef2..08888c8ad 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -45,26 +45,8 @@ use Sys::Syslog qw(:DEFAULT setlogsock);
use Bugzilla::Extension::BMO::Constants;
use Bugzilla::Extension::BMO::FakeBug;
-use Bugzilla::Extension::BMO::Data qw($cf_visible_in_products
- $cf_flags
- $cf_project_flags
- $cf_disabled_flags
- %group_change_notification
- $blocking_trusted_setters
- $blocking_trusted_requesters
- $status_trusted_wanters
- $status_trusted_setters
- $other_setters
- %always_fileable_group
- %group_auto_cc
- %product_sec_groups);
-use Bugzilla::Extension::BMO::Reports qw(user_activity_report
- triage_reports
- group_admins_report
- email_queue_report
- release_tracking_report
- group_membership_report
- group_members_report);
+use Bugzilla::Extension::BMO::Data;
+use Bugzilla::Extension::BMO::Reports;
our $VERSION = '0.1';
@@ -1066,6 +1048,37 @@ sub buglist_columns {
};
}
+sub enter_bug_start {
+ my ($self, $args) = @_;
+ # if configured with create_bug_formats, force users into a custom bug
+ # format (can be overridden with a __standard__ format)
+ my $cgi = Bugzilla->cgi;
+ if ($cgi->param('format') && $cgi->param('format') eq '__standard__') {
+ $cgi->delete('format');
+ } elsif (my $format = forced_format($cgi->param('product'))) {
+ $cgi->param('format', $format);
+ }
+}
+
+sub forced_format {
+ # note: this is also called from the guided bug entry extension
+ my ($product) = @_;
+ return undef unless defined $product;
+
+ # check for a forced-format entry
+ my $forced = $create_bug_formats{blessed($product) ? $product->name : $product}
+ || return;
+
+ # should this user be included?
+ my $user = Bugzilla->user;
+ my $include = ref($forced->{include}) ? $forced->{include} : [ $forced->{include} ];
+ foreach my $inc (@$include) {
+ return $forced->{format} if $user->in_group($inc);
+ }
+
+ return undef;
+}
+
sub query_database {
my ($vars) = @_;
diff --git a/extensions/BMO/lib/Data.pm b/extensions/BMO/lib/Data.pm
index 6f28d8ad5..00f64e890 100644
--- a/extensions/BMO/lib/Data.pm
+++ b/extensions/BMO/lib/Data.pm
@@ -26,18 +26,19 @@ use strict;
use base qw(Exporter);
use Tie::IxHash;
-our @EXPORT_OK = qw($cf_visible_in_products
- $cf_flags $cf_project_flags
- $cf_disabled_flags
- %group_change_notification
- $blocking_trusted_setters
- $blocking_trusted_requesters
- $status_trusted_wanters
- $status_trusted_setters
- $other_setters
- %always_fileable_group
- %group_auto_cc
- %product_sec_groups);
+our @EXPORT = qw( $cf_visible_in_products
+ $cf_flags $cf_project_flags
+ $cf_disabled_flags
+ %group_change_notification
+ $blocking_trusted_setters
+ $blocking_trusted_requesters
+ $status_trusted_wanters
+ $status_trusted_setters
+ $other_setters
+ %always_fileable_group
+ %group_auto_cc
+ %product_sec_groups
+ %create_bug_formats );
# Which custom fields are visible in which products and components.
#
@@ -435,4 +436,17 @@ our %group_auto_cc = (
# Default security groups for products should always been fileable
map { $always_fileable_group{$_} = 1 } values %product_sec_groups;
+# Force create-bug template by product
+# Users in 'include' group will be fored into using the form.
+our %create_bug_formats = (
+ 'Mozilla Developer Network' => {
+ 'format' => 'mdn',
+ 'include' => 'everyone',
+ },
+ 'Legal' => {
+ 'format' => 'legal',
+ 'include' => 'everyone',
+ },
+);
+
1;
diff --git a/extensions/BMO/lib/Reports.pm b/extensions/BMO/lib/Reports.pm
index 4b8252d66..0f3a391d9 100644
--- a/extensions/BMO/lib/Reports.pm
+++ b/extensions/BMO/lib/Reports.pm
@@ -24,13 +24,13 @@ use List::MoreUtils qw(uniq);
use base qw(Exporter);
-our @EXPORT_OK = qw(user_activity_report
- triage_reports
- group_admins_report
- email_queue_report
- release_tracking_report
- group_membership_report
- group_members_report);
+our @EXPORT = qw( user_activity_report
+ triage_reports
+ group_admins_report
+ email_queue_report
+ release_tracking_report
+ group_membership_report
+ group_members_report );
sub user_activity_report {
my ($vars) = @_;
diff --git a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
index 231681085..268fe06f8 100644
--- a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
+++ b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
@@ -8,9 +8,17 @@
[%# this file allows us to pull in data defined in the BMO ext %]
+[% IF formats %]
+ [% FOREACH product = formats %]
+ if (!products['[% product.key FILTER js %]']) [% ~%]
+ products['[% product.key FILTER js %]'] = {};
+ products['[% product.key FILTER js %]'].format = '[% product.value FILTER js %]';
+ [% END %]
+[% END %]
+
[% IF products %]
[% FOREACH product = products %]
- if (!products['[% product.key FILTER js %]'])
+ if (!products['[% product.key FILTER js %]']) [% ~%]
products['[% product.key FILTER js %]'] = {};
products['[% product.key FILTER js %]'].secgroup = '[% product.value FILTER js %]';
[% END %]
diff --git a/extensions/GuidedBugEntry/web/js/guided.js b/extensions/GuidedBugEntry/web/js/guided.js
index 1883e4eb6..8eaf6b3b5 100644
--- a/extensions/GuidedBugEntry/web/js/guided.js
+++ b/extensions/GuidedBugEntry/web/js/guided.js
@@ -17,9 +17,11 @@ var guided = {
detectedOpSys: '',
currentUser: '',
openStates: [],
+ updateStep: true,
setStep: function(newStep, noSetHistory) {
// initialise new step
+ this.updateStep = true;
switch(newStep) {
case 'product':
product.onShow();
@@ -38,6 +40,9 @@ var guided = {
return;
}
+ if (!this.updateStep)
+ return;
+
// change visibility of _step div
if (this._currentStep)
Dom.addClass(this._currentStep + '_step', 'hidden');
@@ -586,6 +591,16 @@ var bugForm = {
},
onShow: function() {
+ // check for a forced format
+ var productName = product.getName();
+ if (products[productName] && products[productName].format) {
+ Dom.addClass('advanced', 'hidden');
+ document.location.href = 'enter_bug.cgi?format=' + encodeURIComponent(products[productName].format) +
+ '&product=' + encodeURIComponent(productName) +
+ '&short_desc=' + encodeURIComponent(dupes.getSummary());
+ guided.updateStep = false;
+ return;
+ }
Dom.removeClass('advanced', 'hidden');
// default the summary to the dupes query
Dom.get('short_desc').value = dupes.getSummary();