зеркало из https://github.com/mozilla/pjs.git
Bug 179339 - Simplify and improve the stored query mechanism. Patch by gerv; r,a=myk.
This commit is contained in:
Родитель
f39bd1e34f
Коммит
272a8f04bc
|
@ -274,7 +274,7 @@ if ($::FORM{'cmdtype'} eq "dorem" && $::FORM{'remaction'} =~ /^run/) {
|
|||
if ($::FORM{'cmdtype'} eq "dorem") {
|
||||
if ($::FORM{'remaction'} eq "run") {
|
||||
$::buffer = LookupNamedQuery($::FORM{"namedcmd"});
|
||||
$vars->{'title'} = "Bug List: $::FORM{'namedcmd'}";
|
||||
$vars->{'searchname'} = $::FORM{'namedcmd'};
|
||||
$params = new Bugzilla::CGI($::buffer);
|
||||
$order = $params->param('order') || $order;
|
||||
}
|
||||
|
@ -284,17 +284,6 @@ if ($::FORM{'cmdtype'} eq "dorem") {
|
|||
$params = new Bugzilla::CGI($::buffer);
|
||||
$order = $params->param('order') || $order;
|
||||
}
|
||||
elsif ($::FORM{'remaction'} eq "load") {
|
||||
my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"});
|
||||
print $cgi->redirect(-location=>$url);
|
||||
# Generate and return the UI (HTML page) from the appropriate template.
|
||||
$vars->{'message'} = "buglist_load_named_query";
|
||||
$vars->{'namedcmd'} = $::FORM{'namedcmd'};
|
||||
$vars->{'url'} = $url;
|
||||
$template->process("global/message.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
exit;
|
||||
}
|
||||
elsif ($::FORM{'remaction'} eq "forget") {
|
||||
confirm_login();
|
||||
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
|
||||
|
@ -314,18 +303,18 @@ if ($::FORM{'cmdtype'} eq "dorem") {
|
|||
exit;
|
||||
}
|
||||
}
|
||||
elsif ($::FORM{'cmdtype'} eq "doit" && $::FORM{'remember'}) {
|
||||
if ($::FORM{'remember'} == 1 && $::FORM{'remtype'} eq "asdefault") {
|
||||
elsif ($::FORM{'cmdtype'} eq "doit") {
|
||||
if ($::FORM{'remtype'} eq "asdefault") {
|
||||
confirm_login();
|
||||
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
|
||||
my $qname = SqlQuote($::defaultqueryname);
|
||||
my $qbuffer = SqlQuote($::buffer);
|
||||
SendSQL("REPLACE INTO namedqueries (userid, name, query)
|
||||
VALUES ($userid, $qname, $qbuffer)");
|
||||
# Generate and return the UI (HTML page) from the appropriate template.
|
||||
|
||||
$vars->{'message'} = "buglist_new_default_query";
|
||||
}
|
||||
elsif ($::FORM{'remember'} == 1 && $::FORM{'remtype'} eq "asnamed") {
|
||||
elsif ($::FORM{'remtype'} eq "asnamed") {
|
||||
confirm_login();
|
||||
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
|
||||
|
||||
|
@ -334,10 +323,9 @@ elsif ($::FORM{'cmdtype'} eq "doit" && $::FORM{'remember'}) {
|
|||
$name !~ /[<>&]/ || ThrowUserError("illegal_query_name");
|
||||
my $qname = SqlQuote($name);
|
||||
|
||||
$::buffer =~ s/[\&\?]cmdtype=[a-z]+//;
|
||||
my $qbuffer = SqlQuote($::buffer);
|
||||
my $qbuffer = SqlQuote($::FORM{'newquery'});
|
||||
|
||||
my $tofooter = $::FORM{'tofooter'} ? 1 : 0;
|
||||
my $tofooter = 1;
|
||||
|
||||
$vars->{'message'} = "buglist_new_named_query";
|
||||
|
||||
|
@ -363,6 +351,11 @@ elsif ($::FORM{'cmdtype'} eq "doit" && $::FORM{'remember'}) {
|
|||
Bugzilla->user->flush_queries_cache();
|
||||
|
||||
$vars->{'queryname'} = $name;
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
$template->process("global/message.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,6 @@
|
|||
saveable => "1" },
|
||||
{ name => "email", description => "Email settings",
|
||||
saveable => "1" },
|
||||
{ name => "footer", description => "Page footer",
|
||||
saveable => "1" },
|
||||
{ name => "permissions", description => "Permissions",
|
||||
saveable => "0" } ] %]
|
||||
|
||||
|
|
|
@ -72,19 +72,17 @@
|
|||
[% END %]
|
||||
|
||||
|
||||
[%# *** Preset Queries *** %]
|
||||
[%# *** Saved Searches *** %]
|
||||
[% IF user.showmybugslink %]
|
||||
[% user_login = user.login FILTER url_quote %]
|
||||
<link rel="Preset Queries" title="My [% terms.Bugs %]"
|
||||
<link rel="Saved Searches" title="My [% terms.Bugs %]"
|
||||
href="[% Param('mybugstemplate').replace('%userid%', user_login) %]">
|
||||
[% END %]
|
||||
|
||||
[% FOREACH q = user.queries %]
|
||||
[% IF q.linkinfooter %]
|
||||
<link rel="Preset Queries"
|
||||
title="[% q.name FILTER html %]"
|
||||
href="buglist.cgi?cmdtype=runnamed&namedcmd=[% q.name FILTER url_quote %]">
|
||||
[% END %]
|
||||
<link rel="Saved Searches"
|
||||
title="[% q.name FILTER html %]"
|
||||
href="buglist.cgi?cmdtype=runnamed&namedcmd=[% q.name FILTER url_quote %]">
|
||||
[% END %]
|
||||
|
||||
[%# *** Bugzilla Administration Tools *** %]
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<td valign="middle" nowrap="nowrap">
|
||||
<a href="enter_bug.cgi">New</a> |
|
||||
<a href="query.cgi">Query</a> |
|
||||
<a href="query.cgi">Search</a> |
|
||||
|
||||
<input type="submit" value="Find"> [% terms.bug %] #
|
||||
<input name="id" size="6"> |
|
||||
|
@ -78,22 +78,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
[%# Preset queries %]
|
||||
|
||||
[% preset_queries = user.showmybugslink %]
|
||||
[% IF NOT preset_queries %]
|
||||
[% FOREACH q = user.queries %]
|
||||
[% IF q.linkinfooter %]
|
||||
[% preset_queries = 1 %]
|
||||
[% LAST %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[%# Saved searches %]
|
||||
|
||||
<tr>
|
||||
[% IF preset_queries %]
|
||||
[% IF user.showmybugslink OR user.queries.size %]
|
||||
<td>
|
||||
Preset Queries:
|
||||
Saved Searches:
|
||||
</td>
|
||||
[% END %]
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
|
||||
[% PROCESS global/variables.none.tmpl %]
|
||||
|
||||
[% DEFAULT title = "$terms.Bug List" %]
|
||||
[% title = "$terms.Bug List" %]
|
||||
[% IF searchname %]
|
||||
[% title = title _ ": " _ searchname FILTER html %]
|
||||
[% END %]
|
||||
|
||||
[% style_urls = [ "css/buglist.css" ] %]
|
||||
[% qorder = order FILTER url_quote IF order %]
|
||||
[% message = "buglist_sorted_by_relevance" IF sorted_by_relevance %]
|
||||
|
@ -132,33 +136,59 @@
|
|||
[%############################################################################%]
|
||||
|
||||
[% IF bugs.size > 0 %]
|
||||
<form method="post" action="long_list.cgi">
|
||||
<input type="hidden" name="buglist" value="[% buglist %]">
|
||||
<input type="submit" value="Long Format">
|
||||
|
||||
<a href="buglist.cgi?
|
||||
[% urlquerypart FILTER html %]&ctype=csv">CSV</a>
|
||||
<a href="colchange.cgi?
|
||||
[% urlquerypart FILTER html %]">Change Columns</a>
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<form method="post" action="long_list.cgi">
|
||||
<input type="hidden" name="buglist" value="[% buglist %]">
|
||||
<input type="submit" value="Long Format">
|
||||
</form>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td valign="top">
|
||||
<a href="buglist.cgi?
|
||||
[% urlquerypart FILTER html %]&ctype=csv">CSV</a> |
|
||||
<a href="colchange.cgi?
|
||||
[% urlquerypart FILTER html %]">Change Columns</a> |
|
||||
|
||||
[% IF bugs.size > 1 && caneditbugs && !dotweak %]
|
||||
<a href="buglist.cgi?[% urlquerypart FILTER html %]
|
||||
[%- "&order=$qorder" FILTER html IF order %]&tweak=1">Change Several
|
||||
[% terms.Bugs %] at Once</a>
|
||||
|
||||
[% END %]
|
||||
[% IF bugs.size > 1 && caneditbugs && !dotweak %]
|
||||
<a href="buglist.cgi?[% urlquerypart FILTER html %]
|
||||
[%- "&order=$qorder" FILTER html IF order %]&tweak=1"
|
||||
>Change Several [% terms.Bugs %] at Once</a>
|
||||
|
|
||||
[% END %]
|
||||
|
||||
[% IF bugowners %]
|
||||
<a href="mailto:[% bugowners FILTER html %]">Send
|
||||
Mail to [% terms.Bug %] Owners</a>
|
||||
|
||||
[% END %]
|
||||
|
||||
<a href="query.cgi?
|
||||
[% urlquerypart FILTER html %]">Edit this Query</a>
|
||||
|
||||
</form>
|
||||
[% IF bugowners %]
|
||||
<a href="mailto:
|
||||
[% bugowners FILTER html %]">Send Mail to [% terms.Bug %] Owners</a> |
|
||||
[% END %]
|
||||
|
||||
<a href="query.cgi?[% urlquerypart FILTER html %]">Edit Search</a>
|
||||
</td>
|
||||
[% IF searchname %]
|
||||
<td valign="top" nowrap="nowrap">
|
||||
|
|
||||
<a href="buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=
|
||||
[% searchname FILTER html %]">Forget Search '
|
||||
[% searchname FILTER html %]'</a>
|
||||
</td>
|
||||
[% ELSE %]
|
||||
<td> </td>
|
||||
<td>
|
||||
<form method="get" action="buglist.cgi">
|
||||
<input type="submit" value="Remember search"> as
|
||||
<input type="hidden" name="newquery"
|
||||
value="[% urlquerypart FILTER html %]">
|
||||
<input type="hidden" name="cmdtype" value="doit">
|
||||
<input type="hidden" name="remtype" value="asnamed">
|
||||
<input type="text" name="newqueryname" size="20">
|
||||
</form>
|
||||
</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
[% END %]
|
||||
|
||||
|
||||
|
|
|
@ -31,112 +31,7 @@
|
|||
"Assignee" => "Assignee",
|
||||
"Last Changed" => "Last Changed" } %]
|
||||
|
||||
<br>
|
||||
[% IF NOT user %]
|
||||
<input type="hidden" name="cmdtype" value="doit">
|
||||
[% ELSE %]
|
||||
<script type="text/javascript"> <!--
|
||||
function remCheckboxChanged() {
|
||||
if (document.queryform.remember.checked == true) {
|
||||
document.queryform.remtype[0].disabled = false;
|
||||
document.queryform.remtype[1].disabled = false;
|
||||
remTypeChanged();
|
||||
}
|
||||
else {
|
||||
document.queryform.remtype[0].disabled = true;
|
||||
document.queryform.remtype[1].disabled = true;
|
||||
document.queryform.newqueryname.disabled = true;
|
||||
document.queryform.tofooter.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function remTypeChanged() {
|
||||
if (document.queryform.remtype[0].checked == true) {
|
||||
document.queryform.newqueryname.disabled = false;
|
||||
document.queryform.tofooter.disabled = false;
|
||||
}
|
||||
else {
|
||||
document.queryform.newqueryname.disabled = true;
|
||||
document.queryform.tofooter.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function selectDoRem() {
|
||||
document.queryform.cmdtype[1].checked = true;
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
|
||||
<table>
|
||||
[% IF namedqueries.size > 0 %]
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" id="cmdtype-doit"
|
||||
name="cmdtype" value="doit" checked="checked">
|
||||
<label for="cmdtype-doit">Run this search</label>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
[% END %]
|
||||
<tr>
|
||||
<td valign="top">
|
||||
[% IF namedqueries.size > 0 %]
|
||||
|
||||
[% END %]
|
||||
<input type="checkbox" id="remember" name="remember" value="1"
|
||||
onclick="remCheckboxChanged()">
|
||||
[% IF namedqueries.size > 0 %]
|
||||
<label for="remember">and remember it</label>
|
||||
[% ELSE %]
|
||||
<label for="remember">Remember this search</label>
|
||||
<input type="hidden" id="cmdtype-doit"
|
||||
name="cmdtype" value="doit">
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" id="remtype-asnamed"
|
||||
name="remtype" value="asnamed" checked="checked"
|
||||
onclick="remTypeChanged()">
|
||||
<label for="remtype-asnamed">with this name:</label>
|
||||
<input type="text" name="newqueryname"><br>
|
||||
|
||||
<input type="checkbox" id="tofooter" name="tofooter" value="1">
|
||||
<label for="tofooter">and put it in my page footer</label><br>
|
||||
<input type="radio" id="remtype-asdefault"
|
||||
name="remtype" value="asdefault"
|
||||
onclick="remTypeChanged()">
|
||||
<label for="remtype-asdefault">
|
||||
as my default options for this page
|
||||
</label><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
[% IF namedqueries.size > 0 %]
|
||||
<input type="radio" id="cmdtype-dorem" name="cmdtype" value="dorem">
|
||||
<select name="remaction" onclick="selectDoRem()">
|
||||
<option value="run">Run</option>
|
||||
<option value="load">Load</option>
|
||||
<option value="forget">Forget</option>
|
||||
</select>
|
||||
<label for="cmdtype-dorem">my remembered search:</label>
|
||||
<select name="namedcmd" onclick="selectDoRem()">
|
||||
[% FOREACH query = namedqueries %]
|
||||
<option value="[% query FILTER html %]">
|
||||
[% query FILTER html %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
[% END %]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript"> <!--
|
||||
remCheckboxChanged();
|
||||
// -->
|
||||
</script>
|
||||
[% END %]
|
||||
<input type="hidden" name="cmdtype" value="doit">
|
||||
|
||||
<p>
|
||||
Sort results by:
|
||||
|
@ -147,14 +42,24 @@
|
|||
[% ordersdesc.$order FILTER html %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
|
||||
<input type="submit" value="[% button_name FILTER html %]">
|
||||
|
||||
[% IF userdefaultquery %]
|
||||
<p>
|
||||
<a href="query.cgi?nukedefaultquery=1">
|
||||
Set my default query back to the system default</a>.
|
||||
</p>
|
||||
[% END %]
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="[% button_name FILTER html %]">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
<input type="checkbox" id="remasdefault"
|
||||
name="remtype" value="asdefault">
|
||||
<label for="remasdefault">
|
||||
and remember these as my default search options
|
||||
</label>
|
||||
</p>
|
||||
|
||||
[% IF userdefaultquery %]
|
||||
<p>
|
||||
<a href="query.cgi?nukedefaultquery=1">
|
||||
Set my default query back to the system default</a>.
|
||||
</p>
|
||||
[% END %]
|
||||
|
|
|
@ -30,13 +30,6 @@ require "CGI.pl";
|
|||
|
||||
use RelationSet;
|
||||
|
||||
# Shut up misguided -w warnings about "used only once". "use vars" just
|
||||
# doesn't work for me.
|
||||
sub sillyness {
|
||||
my $zz;
|
||||
$zz = $::defaultqueryname;
|
||||
}
|
||||
|
||||
# Use global template variables.
|
||||
use vars qw($template $vars $userid);
|
||||
|
||||
|
@ -269,61 +262,6 @@ sub SaveEmail {
|
|||
}
|
||||
|
||||
|
||||
sub DoFooter {
|
||||
SendSQL("SELECT mybugslink FROM profiles " .
|
||||
"WHERE userid = $userid");
|
||||
$vars->{'mybugslink'} = FetchSQLData();
|
||||
|
||||
SendSQL("SELECT name, linkinfooter FROM namedqueries " .
|
||||
"WHERE userid = $userid");
|
||||
|
||||
my @queries;
|
||||
while (MoreSQLData()) {
|
||||
my ($name, $footer) = (FetchSQLData());
|
||||
next if ($name eq $::defaultqueryname);
|
||||
|
||||
push (@queries, { name => $name, footer => $footer });
|
||||
}
|
||||
|
||||
$vars->{'queries'} = \@queries;
|
||||
}
|
||||
|
||||
sub SaveFooter {
|
||||
my %old;
|
||||
SendSQL("SELECT name, linkinfooter FROM namedqueries " .
|
||||
"WHERE userid = $userid");
|
||||
while (MoreSQLData()) {
|
||||
my ($name, $footer) = (FetchSQLData());
|
||||
$old{$name} = $footer;
|
||||
}
|
||||
|
||||
for (my $c = 0; $c < $::FORM{'numqueries'}; $c++) {
|
||||
my $name = $::FORM{"name-$c"};
|
||||
if (exists $old{$name}) {
|
||||
my $new = $::FORM{"query-$c"};
|
||||
if ($new ne $old{$name}) {
|
||||
detaint_natural($new);
|
||||
SendSQL("UPDATE namedqueries SET linkinfooter = $new " .
|
||||
"WHERE userid = $userid " .
|
||||
"AND name = " . SqlQuote($name));
|
||||
}
|
||||
} else {
|
||||
ThrowUserError("missing_query", {queryname => $name});
|
||||
}
|
||||
}
|
||||
SendSQL("UPDATE profiles SET mybugslink = " .
|
||||
SqlQuote($::FORM{'mybugslink'}) . " WHERE userid = $userid");
|
||||
|
||||
# Make sure that cached queries in the user object are invalidated
|
||||
# so that the footer is correct
|
||||
my $user = Bugzilla->user;
|
||||
$user->flush_queries_cache();
|
||||
|
||||
# Also need to update showmybugslink
|
||||
$user->{showmybugslink} = $::FORM{'mybugslink'} ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
sub DoPermissions {
|
||||
my (@has_bits, @set_bits);
|
||||
|
||||
|
@ -385,11 +323,6 @@ SWITCH: for ($current_tab_name) {
|
|||
DoEmail();
|
||||
last SWITCH;
|
||||
};
|
||||
/^footer$/ && do {
|
||||
SaveFooter() if $::FORM{'dosave'};
|
||||
DoFooter();
|
||||
last SWITCH;
|
||||
};
|
||||
/^permissions$/ && do {
|
||||
DoPermissions();
|
||||
last SWITCH;
|
||||
|
@ -402,4 +335,3 @@ SWITCH: for ($current_tab_name) {
|
|||
print $cgi->header();
|
||||
$template->process("account/prefs/prefs.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче