2008-12-15 15:53:33 +03:00
|
|
|
#!/usr/bin/perl -wT
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
|
|
|
# Gervase Markham <gerv@gerv.net>
|
|
|
|
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
2009-07-29 15:21:49 +04:00
|
|
|
# Pascal Held <paheld@gmail.com>
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use lib qw(. lib);
|
|
|
|
|
|
|
|
use Bugzilla;
|
|
|
|
use Bugzilla::Constants;
|
2009-05-19 18:26:10 +04:00
|
|
|
use Bugzilla::Util;
|
2008-12-15 15:53:33 +03:00
|
|
|
use Bugzilla::CGI;
|
2013-08-12 19:24:09 +04:00
|
|
|
use Bugzilla::Search;
|
2008-12-15 15:53:33 +03:00
|
|
|
use Bugzilla::Search::Saved;
|
|
|
|
use Bugzilla::Error;
|
|
|
|
use Bugzilla::User;
|
|
|
|
use Bugzilla::Keyword;
|
|
|
|
|
|
|
|
Bugzilla->login();
|
|
|
|
|
2014-10-08 14:16:31 +04:00
|
|
|
my $ARGS = Bugzilla->input_params;
|
2008-12-15 15:53:33 +03:00
|
|
|
my $template = Bugzilla->template;
|
|
|
|
my $vars = {};
|
|
|
|
|
2010-12-10 21:02:52 +03:00
|
|
|
my @masterlist =
|
2010-12-13 20:49:43 +03:00
|
|
|
map { $_->{id} }
|
|
|
|
sort { $a->{title} cmp $b->{title} }
|
2010-12-10 21:02:52 +03:00
|
|
|
grep { !$_->{nobuglist} }
|
|
|
|
values %{ Bugzilla::Search->COLUMNS };
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2014-11-10 15:13:18 +03:00
|
|
|
Bugzilla::Hook::process('colchange_columns', { columns => \@masterlist });
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2014-08-13 20:33:10 +04:00
|
|
|
$vars->{masterlist} = \@masterlist;
|
|
|
|
$vars->{COLUMNS} = Bugzilla::Search->COLUMNS;
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
my @collist;
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($ARGS->{rememberedquery})
|
|
|
|
{
|
2008-12-15 15:53:33 +03:00
|
|
|
my $splitheader = 0;
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($ARGS->{resetit})
|
|
|
|
{
|
2008-12-15 15:53:33 +03:00
|
|
|
@collist = DEFAULT_COLUMN_LIST;
|
2014-10-08 14:18:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($ARGS->{selected_columns})
|
|
|
|
{
|
2009-07-29 15:21:49 +04:00
|
|
|
my %legal_list = map { $_ => 1 } @masterlist;
|
2014-10-08 14:16:31 +04:00
|
|
|
@collist = grep { exists $legal_list{$_} } list $ARGS->{selected_columns};
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2014-10-08 14:18:55 +04:00
|
|
|
if (defined $ARGS->{splitheader})
|
|
|
|
{
|
2014-10-08 14:16:31 +04:00
|
|
|
$splitheader = $ARGS->{splitheader} ? 1 : 0;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
my $list = join(" ", @collist);
|
|
|
|
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($list)
|
|
|
|
{
|
2008-12-15 15:53:33 +03:00
|
|
|
# Only set the cookie if this is not a saved search.
|
|
|
|
# Saved searches have their own column list
|
2014-10-08 14:18:55 +04:00
|
|
|
if (!$ARGS->{save_columns_for_search})
|
|
|
|
{
|
|
|
|
Bugzilla->cgi->send_cookie(
|
|
|
|
-name => 'COLUMNLIST',
|
|
|
|
-value => $list,
|
|
|
|
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT',
|
|
|
|
);
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
}
|
2014-10-08 14:18:55 +04:00
|
|
|
else
|
|
|
|
{
|
2014-10-08 14:16:31 +04:00
|
|
|
Bugzilla->cgi->remove_cookie('COLUMNLIST');
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($splitheader)
|
|
|
|
{
|
|
|
|
Bugzilla->cgi->send_cookie(
|
|
|
|
-name => 'SPLITHEADER',
|
|
|
|
-value => $splitheader,
|
|
|
|
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT',
|
|
|
|
);
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2014-10-08 14:18:55 +04:00
|
|
|
else
|
|
|
|
{
|
2014-10-08 14:16:31 +04:00
|
|
|
Bugzilla->cgi->remove_cookie('SPLITHEADER');
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
|
2014-10-08 14:18:55 +04:00
|
|
|
$vars->{message} = "change_columns";
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
my $search;
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($ARGS->{saved_search})
|
|
|
|
{
|
2014-10-08 14:16:31 +04:00
|
|
|
$search = new Bugzilla::Search::Saved($ARGS->{saved_search});
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
|
2014-10-08 14:16:31 +04:00
|
|
|
if ($ARGS->{save_columns_for_search} && defined $search && $search->user->id == Bugzilla->user->id)
|
2008-12-15 15:53:33 +03:00
|
|
|
{
|
2014-07-24 18:12:49 +04:00
|
|
|
my $params = http_decode_query($search->query);
|
|
|
|
$params->{columnlist} = join(",", @collist);
|
2015-03-04 13:34:40 +03:00
|
|
|
$params->{$_} = $ARGS->{$_} for qw(period_from period_to period_who);
|
2014-07-24 18:12:49 +04:00
|
|
|
$search->set_query(http_build_query($params));
|
2008-12-15 15:53:33 +03:00
|
|
|
$search->update();
|
|
|
|
}
|
2009-07-29 15:21:49 +04:00
|
|
|
|
2014-10-08 14:16:31 +04:00
|
|
|
my $params = http_decode_query($ARGS->{rememberedquery});
|
2014-07-24 18:12:49 +04:00
|
|
|
$params->{columnlist} = join(",", @collist);
|
2015-03-04 13:34:40 +03:00
|
|
|
$params->{$_} = $ARGS->{$_} for qw(period_from period_to period_who);
|
2014-07-24 18:12:49 +04:00
|
|
|
$vars->{redirect_url} = "buglist.cgi?".http_build_query($params);
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2010-06-25 20:04:36 +04:00
|
|
|
# If we're running on Microsoft IIS, $cgi->redirect discards
|
|
|
|
# the Set-Cookie lines. In mod_perl, $cgi->redirect with cookies
|
|
|
|
# causes the page to be rendered as text/plain.
|
2014-10-08 14:18:55 +04:00
|
|
|
# Workaround is to use the old-fashioned redirection mechanism.
|
2010-06-25 20:04:36 +04:00
|
|
|
# See bug 214466 and bug 376044 for details.
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($ENV{MOD_PERL} || $ENV{SERVER_SOFTWARE} =~ /Microsoft-IIS|Sun ONE Web/)
|
2008-12-15 15:53:33 +03:00
|
|
|
{
|
2014-10-08 14:18:55 +04:00
|
|
|
Bugzilla->cgi->send_header(
|
|
|
|
-type => "text/html",
|
|
|
|
-refresh => "0; URL=".$vars->{redirect_url},
|
|
|
|
);
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2014-10-08 14:18:55 +04:00
|
|
|
else
|
|
|
|
{
|
2015-03-04 13:34:40 +03:00
|
|
|
print Bugzilla->cgi->redirect($vars->{redirect_url});
|
2010-12-09 16:39:15 +03:00
|
|
|
exit;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2010-12-09 16:39:15 +03:00
|
|
|
|
2008-12-15 15:53:33 +03:00
|
|
|
$template->process("global/message.html.tmpl", $vars)
|
2014-10-08 14:18:55 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2008-12-15 15:53:33 +03:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($ARGS->{columnlist})
|
|
|
|
{
|
|
|
|
@collist = split /[ ,]+/, $ARGS->{columnlist};
|
|
|
|
}
|
|
|
|
elsif (defined Bugzilla->cookies->{COLUMNLIST})
|
|
|
|
{
|
|
|
|
@collist = split / /, Bugzilla->cookies->{COLUMNLIST};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-15 15:53:33 +03:00
|
|
|
@collist = DEFAULT_COLUMN_LIST;
|
|
|
|
}
|
|
|
|
|
2010-12-09 16:39:15 +03:00
|
|
|
# Respect aliases
|
|
|
|
{
|
2010-12-10 01:25:32 +03:00
|
|
|
my $a = Bugzilla::Search->COLUMN_ALIASES;
|
2010-12-09 16:39:15 +03:00
|
|
|
$_ = $a->{$_} || $_ for @collist;
|
|
|
|
}
|
|
|
|
|
2014-10-08 14:18:55 +04:00
|
|
|
$vars->{collist} = \@collist;
|
|
|
|
$vars->{splitheader} = Bugzilla->cookies->{SPLITHEADER} ? 1 : 0;
|
|
|
|
$vars->{buffer} = http_build_query($ARGS);
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2015-03-04 13:34:40 +03:00
|
|
|
$vars->{$_} = $ARGS->{$_} for qw(period_from period_to period_who);
|
|
|
|
if (!$vars->{period_from} && !$vars->{period_to} && !$vars->{period_who})
|
|
|
|
{
|
|
|
|
$vars->{period_from} = $ARGS->{chfieldfrom};
|
|
|
|
$vars->{period_to} = $ARGS->{chfieldto};
|
|
|
|
$vars->{period_who} = $ARGS->{chfieldwho};
|
|
|
|
}
|
|
|
|
|
2008-12-15 15:53:33 +03:00
|
|
|
my $search;
|
2014-10-08 14:18:55 +04:00
|
|
|
if (defined $ARGS->{query_based_on})
|
|
|
|
{
|
2008-12-15 15:53:33 +03:00
|
|
|
my $searches = Bugzilla->user->queries;
|
2014-10-08 14:16:31 +04:00
|
|
|
my ($search) = grep($_->name eq $ARGS->{query_based_on}, @$searches);
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2014-10-08 14:18:55 +04:00
|
|
|
if ($search)
|
|
|
|
{
|
|
|
|
$vars->{saved_search} = $search;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate and return the UI (HTML page) from the appropriate template.
|
|
|
|
$template->process("list/change-columns.html.tmpl", $vars)
|
2014-10-08 14:18:55 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
exit;
|