summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Constants.pm7
-rw-r--r--Bugzilla/DB/Schema.pm1
-rw-r--r--Bugzilla/User.pm5
-rwxr-xr-xbuglist.cgi49
-rwxr-xr-xchecksetup.pl7
-rw-r--r--skins/standard/global.css3
-rw-r--r--template/en/default/global/per-bug-queries.html.tmpl40
-rw-r--r--template/en/default/global/setting-descs.none.tmpl3
-rw-r--r--template/en/default/global/useful-links.html.tmpl4
-rw-r--r--template/en/default/global/user-error.html.tmpl4
10 files changed, 109 insertions, 14 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 078c988b6..795f0096b 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -65,6 +65,9 @@ use base qw(Exporter);
DEFAULT_COLUMN_LIST
DEFAULT_QUERY_NAME
+ QUERY_LIST
+ LIST_OF_BUGS
+
COMMENT_COLS
UNLOCK_ABORT
@@ -173,6 +176,10 @@ use constant DEFAULT_COLUMN_LIST => (
# for the default settings.
use constant DEFAULT_QUERY_NAME => '(Default query)';
+# The possible types for saved searches.
+use constant QUERY_LIST => 0;
+use constant LIST_OF_BUGS => 1;
+
# The column length for displayed (and wrapped) bug comments.
use constant COMMENT_COLS => 80;
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 8379f0b12..5ffb41216 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -665,6 +665,7 @@ use constant ABSTRACT_SCHEMA => {
name => {TYPE => 'varchar(64)', NOTNULL => 1},
linkinfooter => {TYPE => 'BOOLEAN', NOTNULL => 1},
query => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ query_type => {TYPE => 'BOOLEAN', NOTNULL => 1},
],
INDEXES => [
namedqueries_userid_idx => {FIELDS => [qw(userid name)],
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 7f3736c28..6beb16a8b 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -198,7 +198,7 @@ sub queries {
my $dbh = Bugzilla->dbh;
my $sth = $dbh->prepare(q{ SELECT
- DISTINCT name, query, linkinfooter,
+ DISTINCT name, query, linkinfooter, query_type,
CASE WHEN whine_queries.id IS NOT NULL
THEN 1 ELSE 0 END,
UPPER(name) AS uppername
@@ -221,7 +221,8 @@ sub queries {
name => $row->[0],
query => $row->[1],
linkinfooter => $row->[2],
- usedinwhine => $row->[3],
+ query_type => $row->[3],
+ usedinwhine => $row->[4],
});
}
$self->{queries} = \@queries;
diff --git a/buglist.cgi b/buglist.cgi
index 53f810c3c..cb49d2a31 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -39,6 +39,7 @@ use Bugzilla::Search;
use Bugzilla::Search::Quicksearch;
use Bugzilla::Constants;
use Bugzilla::User;
+use Bugzilla::Bug;
# Include the Bugzilla CGI and general utility library.
require "globals.pl";
@@ -207,6 +208,7 @@ sub LookupNamedQuery {
my $dbh = Bugzilla->dbh;
# $name is safe -- we only use it below in a SELECT placeholder and then
# in error messages (which are always HTML-filtered).
+ $name || ThrowUserError("query_name_missing");
trick_taint($name);
my $result = $dbh->selectrow_array("SELECT query FROM namedqueries"
. " WHERE userid = ? AND name = ?"
@@ -232,14 +234,17 @@ sub LookupNamedQuery {
# empty, or we will throw a UserError.
# link_in_footer (optional) - 1 if the Named Query should be
# displayed in the user's footer, 0 otherwise.
+# query_type (optional) - 1 if the Named Query contains a list of
+# bug IDs only, 0 otherwise (default).
#
# All parameters are validated before passing them into the database.
#
# Returns: A boolean true value if the query existed in the database
# before, and we updated it. A boolean false value otherwise.
sub InsertNamedQuery {
- my ($userid, $query_name, $query, $link_in_footer) = @_;
+ my ($userid, $query_name, $query, $link_in_footer, $query_type) = @_;
$link_in_footer ||= 0;
+ $query_type ||= QUERY_LIST;
$query_name = trim($query_name);
Bugzilla->login(LOGIN_REQUIRED);
my $dbh = Bugzilla->dbh;
@@ -268,15 +273,15 @@ sub InsertNamedQuery {
if ($result) {
$query_existed_before = 1;
$dbh->do("UPDATE namedqueries"
- . " SET query = ?, linkinfooter = ?"
+ . " SET query = ?, linkinfooter = ?, query_type = ?"
. " WHERE userid = ? AND name = ?"
- , undef, ($query, $link_in_footer, $userid, $query_name));
+ , undef, ($query, $link_in_footer, $query_type, $userid, $query_name));
} else {
$query_existed_before = 0;
$dbh->do("INSERT INTO namedqueries"
- . " (userid, name, query, linkinfooter)"
- . " VALUES (?, ?, ?, ?)"
- , undef, ($userid, $query_name, $query, $link_in_footer));
+ . " (userid, name, query, linkinfooter, query_type)"
+ . " VALUES (?, ?, ?, ?, ?)"
+ , undef, ($userid, $query_name, $query, $link_in_footer, $query_type));
}
$dbh->bz_unlock_tables();
@@ -436,11 +441,35 @@ elsif (($cgi->param('cmdtype') eq "doit") && defined $cgi->param('remtype')) {
Bugzilla->login(LOGIN_REQUIRED);
my $userid = Bugzilla->user->id;
my $query_name = $cgi->param('newqueryname');
-
+ my $new_query = $cgi->param('newquery');
+ my $query_type = QUERY_LIST;
+ # If add_bugids is true, we are adding individual bugs to a saved
+ # search. We get the existing list of bug IDs (if any) and append
+ # the new ones.
+ if ($cgi->param('add_bugids')) {
+ my %bug_ids;
+ foreach my $bug_id (split(/[\s,]+/, $cgi->param('bug_ids'))) {
+ next unless $bug_id;
+ ValidateBugID($bug_id);
+ $bug_ids{$bug_id} = 1;
+ }
+ ThrowUserError("no_bug_ids") unless scalar(keys %bug_ids);
+
+ if (!trim($query_name)) {
+ # No new query name has been given. We append new bug IDs
+ # to the existing list.
+ $query_name = $cgi->param('oldqueryname');
+ my $old_query = LookupNamedQuery($query_name);
+ foreach my $bug_id (split(/[\s,=]+/, $old_query)) {
+ $bug_ids{$bug_id} = 1 if detaint_natural($bug_id);
+ }
+ }
+ $new_query = "bug_id=" . join(',', sort {$a <=> $b} keys %bug_ids);
+ $query_type = LIST_OF_BUGS;
+ }
my $tofooter = 1;
- my $existed_before = InsertNamedQuery($userid, $query_name,
- scalar $cgi->param('newquery'),
- $tofooter);
+ my $existed_before = InsertNamedQuery($userid, $query_name, $new_query,
+ $tofooter, $query_type);
if ($existed_before) {
$vars->{'message'} = "buglist_updated_named_query";
}
diff --git a/checksetup.pl b/checksetup.pl
index e3c5a4af5..d04a07b7c 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -4038,6 +4038,10 @@ if ($dbh->bz_column_info("series", "public")) {
$dbh->bz_add_column('attachments', 'isurl',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0});
+# 2005-10-21 LpSolit@gmail.com - Bug 313020
+$dbh->bz_add_column('namedqueries', 'query_type',
+ {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0});
+
# If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment.
#
@@ -4180,6 +4184,9 @@ add_setting ("post_bug_submit_action", {"next_bug" => 1,
# 2005-06-29 wurblzap@gmail.com -- Bug 257767
add_setting ('csv_colsepchar', {',' => 1, ';' => 2 }, ',' );
+# 2005-10-21 LpSolit@gmail.com -- Bug 313020
+add_setting('per_bug_queries', {'on' => 1, 'off' => 2}, 'on');
+
###########################################################################
# Create Administrator --ADMIN--
###########################################################################
diff --git a/skins/standard/global.css b/skins/standard/global.css
index ea95e7460..7d6e0abba 100644
--- a/skins/standard/global.css
+++ b/skins/standard/global.css
@@ -210,7 +210,8 @@ body
#footer #links-actions,
#footer #links-edit,
- #footer #links-saved
+ #footer #links-saved,
+ #footer #links-special
{
display: table-row;
}
diff --git a/template/en/default/global/per-bug-queries.html.tmpl b/template/en/default/global/per-bug-queries.html.tmpl
new file mode 100644
index 000000000..537ed01e4
--- /dev/null
+++ b/template/en/default/global/per-bug-queries.html.tmpl
@@ -0,0 +1,40 @@
+[%# 1.0@bugzilla.org %]
+[%# 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.
+ #
+ # Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
+ #%]
+
+[% IF user.id && user.settings.per_bug_queries.value == "on" %]
+ <div id="links-special">
+ <div class="label">&nbsp;</div>
+ <div class="links">
+ <form action="buglist.cgi" method="get">
+ <input type="hidden" name="cmdtype" value="doit">
+ <input type="hidden" name="remtype" value="asnamed">
+ <input type="hidden" name="add_bugids" value="1">
+ <input type="submit" value="Add"> [% terms.bugs %]
+ <input type="text" name="bug_ids" size="8" maxlength="80"> to
+ <select name="oldqueryname">
+ [% FOREACH q = user.queries %]
+ [% IF q.query_type == constants.LIST_OF_BUGS %]
+ <option value="[% q.name FILTER html %]">
+ [% q.name FILTER html %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ or to the new saved search:
+ <input type="text" name="newqueryname" size="20" maxlength="64">
+ </form>
+ </div>
+ </div>
+[% END %]
diff --git a/template/en/default/global/setting-descs.none.tmpl b/template/en/default/global/setting-descs.none.tmpl
index 9957cf6a4..3ca7fe3f3 100644
--- a/template/en/default/global/setting-descs.none.tmpl
+++ b/template/en/default/global/setting-descs.none.tmpl
@@ -27,7 +27,8 @@
"newest_to_oldest_desc_first" => "Newest to Oldest, but keep Description at the top",
"off" => "Off",
"oldest_to_newest" => "Oldest to Newest",
- "on" => "On"
+ "on" => "On",
+ "per_bug_queries" => "Add individual $terms.bugs to saved searches",
"post_bug_submit_action" => "After changing $terms.abug",
"next_bug" => "Show next $terms.bug in my list",
"same_bug" => "Show the updated $terms.bug",
diff --git a/template/en/default/global/useful-links.html.tmpl b/template/en/default/global/useful-links.html.tmpl
index ef7f3d19f..b2e598163 100644
--- a/template/en/default/global/useful-links.html.tmpl
+++ b/template/en/default/global/useful-links.html.tmpl
@@ -134,6 +134,10 @@
</div>
</div>
+ [%# Individual bugs addition %]
+
+ [% PROCESS "global/per-bug-queries.html.tmpl" %]
+
[%# Sections of links to more things users can do on this installation. %]
[% Hook.process("end") %]
</div>
diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl
index b1c8e7c91..299cf2d2b 100644
--- a/template/en/default/global/user-error.html.tmpl
+++ b/template/en/default/global/user-error.html.tmpl
@@ -866,6 +866,10 @@
[% title = BLOCK %]No [% terms.Bugs %] Chosen[% END %]
You apparently didn't choose any [% terms.bugs %] to modify.
+ [% ELSIF error == "no_bug_ids" %]
+ [% title = BLOCK %]No [% terms.Bugs %] Chosen[% END %]
+ You didn't choose any [% terms.bugs %] to add to the saved search.
+
[% ELSIF error == "no_component_change_for_multiple_products" %]
[% title = "Action Not Permitted" %]
You cannot change the component for a list of [% terms.bugs %] covering more than