summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
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/BMO
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/BMO')
-rw-r--r--extensions/BMO/Extension.pm53
-rw-r--r--extensions/BMO/lib/Data.pm38
-rw-r--r--extensions/BMO/lib/Reports.pm14
3 files changed, 66 insertions, 39 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) = @_;