зеркало из https://github.com/mozilla/pjs.git
Bug 313020: Implement the ability to add individual bugs to saved searches - Patch by Fr�d�ric Buclin <LpSolit@gmail.com> r=joel a=justdave
This commit is contained in:
Родитель
0061b67a9a
Коммит
3a37a11e8b
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)],
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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--
|
||||
###########################################################################
|
||||
|
|
|
@ -210,7 +210,8 @@ body
|
|||
|
||||
#footer #links-actions,
|
||||
#footer #links-edit,
|
||||
#footer #links-saved
|
||||
#footer #links-saved,
|
||||
#footer #links-special
|
||||
{
|
||||
display: table-row;
|
||||
}
|
||||
|
|
|
@ -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"> </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 %]
|
|
@ -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",
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче