Commit 558b05ca authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 345826: Ability to save column list in saved searches

Patch By Ronaldo Maia <romaia@async.com.br> r=LpSolit, a=LpSolit
parent 532eabde
...@@ -28,6 +28,8 @@ use lib qw(.); ...@@ -28,6 +28,8 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::CGI;
use Bugzilla::Search::Saved;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Keyword; use Bugzilla::Keyword;
...@@ -101,9 +103,13 @@ if (defined $cgi->param('rememberedquery')) { ...@@ -101,9 +103,13 @@ if (defined $cgi->param('rememberedquery')) {
my $urlbase = Bugzilla->params->{"urlbase"}; my $urlbase = Bugzilla->params->{"urlbase"};
if ($list) { if ($list) {
$cgi->send_cookie(-name => 'COLUMNLIST', # Only set the cookie if this is not a saved search.
-value => $list, # Saved searches have their own column list
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT'); if (!$cgi->param('save_columns_for_search')) {
$cgi->send_cookie(-name => 'COLUMNLIST',
-value => $list,
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
}
} }
else { else {
$cgi->remove_cookie('COLUMNLIST'); $cgi->remove_cookie('COLUMNLIST');
...@@ -118,7 +124,27 @@ if (defined $cgi->param('rememberedquery')) { ...@@ -118,7 +124,27 @@ if (defined $cgi->param('rememberedquery')) {
} }
$vars->{'message'} = "change_columns"; $vars->{'message'} = "change_columns";
$vars->{'redirect_url'} = "buglist.cgi?".$cgi->param('rememberedquery');
my $search;
if (defined $cgi->param('saved_search')) {
$search = new Bugzilla::Search::Saved($cgi->param('saved_search'));
}
if ($cgi->param('save_columns_for_search')
&& defined $search && $search->user->id == Bugzilla->user->id)
{
my $params = new Bugzilla::CGI($search->url);
$params->param('columnlist', join(",", @collist));
$search->set_url($params->query_string());
$search->update();
$vars->{'redirect_url'} = "buglist.cgi?".$cgi->param('rememberedquery');
}
else {
my $params = new Bugzilla::CGI($cgi->param('rememberedquery'));
$params->param('columnlist', join(",", @collist));
$vars->{'redirect_url'} = "buglist.cgi?".$params->query_string();
}
# If we're running on Microsoft IIS, using cgi->redirect discards # If we're running on Microsoft IIS, using cgi->redirect discards
# the Set-Cookie lines -- workaround is to use the old-fashioned # the Set-Cookie lines -- workaround is to use the old-fashioned
...@@ -149,6 +175,24 @@ $vars->{'splitheader'} = $cgi->cookie('SPLITHEADER') ? 1 : 0; ...@@ -149,6 +175,24 @@ $vars->{'splitheader'} = $cgi->cookie('SPLITHEADER') ? 1 : 0;
$vars->{'buffer'} = $cgi->query_string(); $vars->{'buffer'} = $cgi->query_string();
my $search;
if (defined $cgi->param('query_based_on')) {
my $searches = Bugzilla->user->queries;
my ($search) = grep($_->name eq $cgi->param('query_based_on'), @$searches);
# Only allow users to edit their own queries.
if ($search && $search->user->id == Bugzilla->user->id) {
$vars->{'saved_search'} = $search;
$vars->{'buffer'} = "cmdtype=runnamed&namedcmd=".$search->name;
my $params = new Bugzilla::CGI($search->url);
if ($params->param('columnlist')) {
my @collist = split(',', $params->param('columnlist'));
$vars->{'collist'} = \@collist if scalar (@collist);
}
}
}
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
print $cgi->header(); print $cgi->header();
$template->process("list/change-columns.html.tmpl", $vars) $template->process("list/change-columns.html.tmpl", $vars)
......
...@@ -63,6 +63,17 @@ ...@@ -63,6 +63,17 @@
</label> </label>
</p> </p>
[% IF saved_search %]
<p>
<input type="hidden" name="saved_search"
value="[% saved_search.id FILTER html%]" >
<input type="checkbox" id="save_columns_for_search" checked="checked"
name="save_columns_for_search" value="1">
<label for="save_columns_for_search">Save this column list only
for search '[% saved_search.name FILTER html %]'</label>
</p>
[% END %]
<p> <p>
<input type="submit" id="change" value="Change Columns"> <input type="submit" id="change" value="Change Columns">
</p> </p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment