aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-17 03:26:23 -0700
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-17 03:26:23 -0700
commitc47b010b3b0c817e46bab0136b64edb1bdc2fc48 (patch)
tree395ac59321ae7c8bb98decf916a6c6e6b6122f49 /colchange.cgi
parentBug 545770: Make contrib/merge-users.pl figure out what columns to merge (diff)
downloadbugzilla-c47b010b3b0c817e46bab0136b64edb1bdc2fc48.tar.gz
bugzilla-c47b010b3b0c817e46bab0136b64edb1bdc2fc48.tar.bz2
bugzilla-c47b010b3b0c817e46bab0136b64edb1bdc2fc48.zip
Bug 545587: Make colchange.cgi use the database to determine buglist-able
columns, instead of having a fixed list. r=LpSolit, a=LpSolit
Diffstat (limited to 'colchange.cgi')
-rwxr-xr-xcolchange.cgi83
1 files changed, 39 insertions, 44 deletions
diff --git a/colchange.cgi b/colchange.cgi
index 15bdac599..a8429e2ed 100755
--- a/colchange.cgi
+++ b/colchange.cgi
@@ -24,7 +24,6 @@
# Pascal Held <paheld@gmail.com>
use strict;
-
use lib qw(. lib);
use Bugzilla;
@@ -34,7 +33,24 @@ use Bugzilla::CGI;
use Bugzilla::Search::Saved;
use Bugzilla::Error;
use Bugzilla::User;
-use Bugzilla::Keyword;
+
+use Storable qw(dclone);
+
+# Maps parameters that control columns to the names of columns.
+use constant COLUMN_PARAMS => {
+ 'useclassification' => ['classification'],
+ 'usebugaliases' => ['alias'],
+ 'usetargetmilestone' => ['target_milestone'],
+ 'useqacontact' => ['qa_contact', 'qa_contact_realname'],
+ 'usestatuswhiteboard' => ['status_whiteboard'],
+};
+
+# We only show these columns if an object of this type exists in the
+# database.
+use constant COLUMN_CLASSES => {
+ 'Bugzilla::Flag' => 'flagtypes.name',
+ 'Bugzilla::Keyword' => 'keywords',
+};
Bugzilla->login();
@@ -42,52 +58,31 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
-# The master list not only says what fields are possible, but what order
-# they get displayed in.
-my @masterlist = ("opendate", "changeddate", "bug_severity", "priority",
- "rep_platform", "assigned_to", "assigned_to_realname",
- "reporter", "reporter_realname", "bug_status",
- "resolution");
+my $columns = dclone(Bugzilla::Search::COLUMNS);
-if (Bugzilla->params->{"useclassification"}) {
- push(@masterlist, "classification");
-}
+# You can't manually select "relevance" as a column you want to see.
+delete $columns->{'relevance'};
-push(@masterlist, ("product", "component", "version", "op_sys"));
-
-if (Bugzilla->params->{"usebugaliases"}) {
- unshift(@masterlist, "alias");
-}
-if (Bugzilla->params->{"usetargetmilestone"}) {
- push(@masterlist, "target_milestone");
-}
-if (Bugzilla->params->{"useqacontact"}) {
- push(@masterlist, "qa_contact");
- push(@masterlist, "qa_contact_realname");
-}
-if (Bugzilla->params->{"usestatuswhiteboard"}) {
- push(@masterlist, "status_whiteboard");
-}
-if (Bugzilla::Keyword->any_exist) {
- push(@masterlist, "keywords");
-}
-if (Bugzilla->has_flags) {
- push(@masterlist, "flagtypes.name");
-}
-if (Bugzilla->user->is_timetracker) {
- push(@masterlist, ("estimated_time", "remaining_time", "actual_time",
- "percentage_complete", "deadline"));
+foreach my $param (keys %{ COLUMN_PARAMS() }) {
+ next if Bugzilla->params->{$param};
+ foreach my $column (@{ COLUMN_PARAMS->{$param} }) {
+ delete $columns->{$column};
+ }
}
-push(@masterlist, ("short_desc", "short_short_desc"));
-
-my @custom_fields = grep { $_->type != FIELD_TYPE_MULTI_SELECT }
- Bugzilla->active_custom_fields;
-push(@masterlist, map { $_->name } @custom_fields);
+foreach my $class (keys %{ COLUMN_CLASSES() }) {
+ eval("use $class; 1;") || die $@;
+ my $column = COLUMN_CLASSES->{$class};
+ delete $columns->{$column} if !$class->any_exist;
+}
-Bugzilla::Hook::process('colchange_columns', {'columns' => \@masterlist} );
+if (!Bugzilla->user->is_timetracker) {
+ foreach my $column (TIMETRACKING_FIELDS) {
+ delete $columns->{$column};
+ }
+}
-$vars->{'masterlist'} = \@masterlist;
+$vars->{'columns'} = $columns;
my @collist;
if (defined $cgi->param('rememberedquery')) {
@@ -96,8 +91,8 @@ if (defined $cgi->param('rememberedquery')) {
@collist = DEFAULT_COLUMN_LIST;
} else {
if (defined $cgi->param("selected_columns")) {
- my %legal_list = map { $_ => 1 } @masterlist;
- @collist = grep { exists $legal_list{$_} } $cgi->param("selected_columns");
+ @collist = grep { exists $columns->{$_} }
+ $cgi->param("selected_columns");
}
if (defined $cgi->param('splitheader')) {
$splitheader = $cgi->param('splitheader')? 1: 0;