diff options
author | Byron Jones <bjones@mozilla.com> | 2013-03-04 19:49:50 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-03-04 19:49:50 +0100 |
commit | 6919f41e51cacaa8f6b4ae7bcdbd010c8d6aefe5 (patch) | |
tree | b03bd17dc6dd680197d1ef44d350543e82096490 /extensions/BMO/Extension.pm | |
parent | 1143f1d0a5162c60e8bc893f0c9c6f2c5aa559d0 (diff) | |
download | bugzilla-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/Extension.pm')
-rw-r--r-- | extensions/BMO/Extension.pm | 53 |
1 files changed, 33 insertions, 20 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) = @_; |