2003-03-27 03:07:02 +03:00
|
|
|
#!/usr/bin/perl -wT
|
1998-09-16 01:49:26 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
1998-08-26 10:14:20 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# 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.
|
|
|
|
#
|
1998-08-26 10:14:20 +04:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1998-08-26 10:14:20 +04:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1998-08-26 10:14:20 +04:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
1999-12-03 02:21:42 +03:00
|
|
|
# Dan Mosedale <dmose@mozilla.org>
|
2001-04-17 06:26:16 +04:00
|
|
|
# Dave Miller <justdave@syndicomm.com>
|
2001-08-26 22:51:45 +04:00
|
|
|
# Christopher Aillon <christopher@aillon.com>
|
2002-04-13 01:02:00 +04:00
|
|
|
# Myk Melez <myk@mozilla.org>
|
2005-02-28 21:55:07 +03:00
|
|
|
# Jeff Hedlund <jeff.hedlund@matrixsi.com>
|
2006-02-08 01:25:23 +03:00
|
|
|
# Frédéric Buclin <LpSolit@gmail.com>
|
2005-10-24 23:21:05 +04:00
|
|
|
# Lance Larsh <lance.larsh@oracle.com>
|
2006-09-21 01:57:58 +04:00
|
|
|
# Akamai Technologies <bugzilla-dev@akamai.com>
|
1998-08-26 10:14:20 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
# Implementation notes for this file:
|
|
|
|
#
|
|
|
|
# 1) the 'id' form parameter is validated early on, and if it is not a valid
|
|
|
|
# bugid an error will be reported, so it is OK for later code to simply check
|
|
|
|
# for a defined form 'id' value, and it can assume a valid bugid.
|
|
|
|
#
|
|
|
|
# 2) If the 'id' form parameter is not defined (after the initial validation),
|
|
|
|
# then we are processing multiple bugs, and @idlist will contain the ids.
|
|
|
|
#
|
|
|
|
# 3) If we are processing just the one id, then it is stored in @idlist for
|
|
|
|
# later processing.
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
use strict;
|
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
use lib qw(.);
|
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
use Bugzilla;
|
2002-11-24 22:56:34 +03:00
|
|
|
use Bugzilla::Constants;
|
2004-03-18 06:57:05 +03:00
|
|
|
use Bugzilla::Bug;
|
2006-10-17 10:24:18 +04:00
|
|
|
use Bugzilla::BugMail;
|
2006-06-02 14:50:15 +04:00
|
|
|
use Bugzilla::Mailer;
|
2002-10-25 07:59:35 +04:00
|
|
|
use Bugzilla::User;
|
2005-01-16 16:02:35 +03:00
|
|
|
use Bugzilla::Util;
|
2006-06-21 04:44:48 +04:00
|
|
|
use Bugzilla::Error;
|
2005-07-22 00:04:27 +04:00
|
|
|
use Bugzilla::Field;
|
2006-03-03 02:50:17 +03:00
|
|
|
use Bugzilla::Product;
|
2006-05-29 21:24:54 +04:00
|
|
|
use Bugzilla::Component;
|
2006-03-09 03:09:00 +03:00
|
|
|
use Bugzilla::Keyword;
|
2002-09-28 22:42:54 +04:00
|
|
|
use Bugzilla::Flag;
|
|
|
|
|
2004-03-27 06:51:44 +03:00
|
|
|
my $user = Bugzilla->login(LOGIN_REQUIRED);
|
2006-07-06 10:12:05 +04:00
|
|
|
local our $whoid = $user->id;
|
2005-08-19 00:09:37 +04:00
|
|
|
my $grouplist = $user->groups_as_string;
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-02-18 00:57:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2005-10-25 03:11:56 +04:00
|
|
|
my $template = Bugzilla->template;
|
2006-07-06 10:12:05 +04:00
|
|
|
local our $vars = {};
|
2006-03-09 03:09:00 +03:00
|
|
|
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
|
2003-05-05 05:15:38 +04:00
|
|
|
|
2006-06-16 17:37:50 +04:00
|
|
|
my @editable_bug_fields = editable_bug_fields();
|
|
|
|
|
2000-05-09 02:00:38 +04:00
|
|
|
my $requiremilestone = 0;
|
2006-10-21 00:50:30 +04:00
|
|
|
local our $PrivilegesRequired = 0;
|
2000-05-09 02:00:38 +04:00
|
|
|
|
2006-03-02 00:47:58 +03:00
|
|
|
######################################################################
|
|
|
|
# Subroutines
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
sub BugInGroupId {
|
|
|
|
my ($bug_id, $group_id) = @_;
|
|
|
|
detaint_natural($bug_id);
|
|
|
|
detaint_natural($group_id);
|
|
|
|
my ($in_group) = Bugzilla->dbh->selectrow_array(
|
|
|
|
"SELECT CASE WHEN bug_id != 0 THEN 1 ELSE 0 END
|
|
|
|
FROM bug_group_map
|
|
|
|
WHERE bug_id = ? AND group_id = ?", undef, ($bug_id, $group_id));
|
|
|
|
return $in_group;
|
|
|
|
}
|
|
|
|
|
2006-05-19 01:40:54 +04:00
|
|
|
# This function checks if there are any default groups defined.
|
|
|
|
# If so, then groups may have to be changed when bugs move from
|
|
|
|
# one bug to another.
|
|
|
|
sub AnyDefaultGroups {
|
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
my $any_default =
|
|
|
|
$dbh->selectrow_array('SELECT 1
|
|
|
|
FROM group_control_map
|
|
|
|
INNER JOIN groups
|
|
|
|
ON groups.id = group_control_map.group_id
|
|
|
|
WHERE isactive != 0
|
|
|
|
AND (membercontrol = ? OR othercontrol = ?) ' .
|
|
|
|
$dbh->sql_limit(1),
|
|
|
|
undef, (CONTROLMAPDEFAULT, CONTROLMAPDEFAULT));
|
|
|
|
return $any_default;
|
|
|
|
}
|
|
|
|
|
2006-10-17 10:24:18 +04:00
|
|
|
# Used to send email when an update is done.
|
|
|
|
sub send_results {
|
|
|
|
my ($bug_id, $vars) = @_;
|
|
|
|
my $template = Bugzilla->template;
|
|
|
|
if (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
Bugzilla::BugMail::Send($bug_id, $vars->{'mailrecipients'});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$template->process("bug/process/results.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
$vars->{'header_done'} = 1;
|
|
|
|
}
|
|
|
|
|
2001-05-31 19:52:25 +04:00
|
|
|
######################################################################
|
|
|
|
# Begin Data/Security Validation
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# Create a list of IDs of all bugs being modified in this request.
|
|
|
|
# This list will either consist of a single bug number from the "id"
|
|
|
|
# form/URL field or a series of numbers from multiple form/URL fields
|
|
|
|
# named "id_x" where "x" is the bug number.
|
2002-01-20 04:44:52 +03:00
|
|
|
# For each bug being modified, make sure its ID is a valid bug number
|
|
|
|
# representing an existing bug that the user is authorized to access.
|
2001-05-31 19:52:25 +04:00
|
|
|
my @idlist;
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('id')) {
|
|
|
|
my $id = $cgi->param('id');
|
|
|
|
ValidateBugID($id);
|
|
|
|
|
|
|
|
# Store the validated, and detainted id back in the cgi data, as
|
|
|
|
# lots of later code will need it, and will obtain it from there
|
|
|
|
$cgi->param('id', $id);
|
|
|
|
push @idlist, $id;
|
2001-05-31 19:52:25 +04:00
|
|
|
} else {
|
2005-04-08 04:45:47 +04:00
|
|
|
foreach my $i ($cgi->param()) {
|
2001-06-03 02:02:02 +04:00
|
|
|
if ($i =~ /^id_([1-9][0-9]*)/) {
|
2002-01-20 04:44:52 +03:00
|
|
|
my $id = $1;
|
|
|
|
ValidateBugID($id);
|
|
|
|
push @idlist, $id;
|
2001-06-03 02:02:02 +04:00
|
|
|
}
|
2001-05-31 19:52:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-17 22:55:31 +04:00
|
|
|
# Make sure there are bugs to process.
|
2002-10-02 02:41:09 +04:00
|
|
|
scalar(@idlist) || ThrowUserError("no_bugs_chosen");
|
2001-09-17 22:55:31 +04:00
|
|
|
|
2007-03-08 02:54:01 +03:00
|
|
|
# Build a bug object using the first bug id, for validations.
|
|
|
|
my $bug = new Bugzilla::Bug($idlist[0]);
|
2006-07-02 00:01:52 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
# Make sure form param 'dontchange' is defined so it can be compared to easily.
|
|
|
|
$cgi->param('dontchange','') unless defined $cgi->param('dontchange');
|
2005-01-14 19:32:15 +03:00
|
|
|
|
2005-11-04 12:44:53 +03:00
|
|
|
# Make sure the 'knob' param is defined; else set it to 'none'.
|
|
|
|
$cgi->param('knob', 'none') unless defined $cgi->param('knob');
|
|
|
|
|
2004-08-03 10:23:25 +04:00
|
|
|
# Validate all timetracking fields
|
|
|
|
foreach my $field ("estimated_time", "work_time", "remaining_time") {
|
2007-03-08 02:54:01 +03:00
|
|
|
if (defined $cgi->param($field)
|
|
|
|
&& $cgi->param($field) ne $cgi->param('dontchange'))
|
|
|
|
{
|
|
|
|
$cgi->param($field, $bug->_check_time($cgi->param($field), $field));
|
2004-08-03 10:23:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-04 20:21:49 +04:00
|
|
|
if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
|
2005-04-08 04:45:47 +04:00
|
|
|
my $wk_time = $cgi->param('work_time');
|
|
|
|
if ($cgi->param('comment') =~ /^\s*$/ && $wk_time && $wk_time != 0) {
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError('comment_required');
|
2004-10-25 08:49:32 +04:00
|
|
|
}
|
2001-08-26 22:51:45 +04:00
|
|
|
}
|
|
|
|
|
2007-03-08 02:54:01 +03:00
|
|
|
$cgi->param('comment', $bug->_check_comment($cgi->param('comment')));
|
2002-03-11 10:33:03 +03:00
|
|
|
|
2002-07-04 03:07:14 +04:00
|
|
|
# If the bug(s) being modified have dependencies, validate them
|
|
|
|
# and rebuild the list with the validated values. This is important
|
|
|
|
# because there are situations where validation changes the value
|
|
|
|
# instead of throwing an error, f.e. when one or more of the values
|
|
|
|
# is a bug alias that gets converted to its corresponding bug ID
|
|
|
|
# during validation.
|
|
|
|
foreach my $field ("dependson", "blocked") {
|
2005-10-19 01:12:47 +04:00
|
|
|
if ($cgi->param('id')) {
|
|
|
|
my @old = @{$bug->$field};
|
|
|
|
my @new;
|
2005-04-08 04:45:47 +04:00
|
|
|
foreach my $id (split(/[\s,]+/, $cgi->param($field))) {
|
2002-07-04 03:07:14 +04:00
|
|
|
next unless $id;
|
2004-12-21 12:04:01 +03:00
|
|
|
ValidateBugID($id, $field);
|
2005-10-19 01:12:47 +04:00
|
|
|
push @new, $id;
|
2002-07-04 03:07:14 +04:00
|
|
|
}
|
2005-10-19 01:12:47 +04:00
|
|
|
$cgi->param($field, join(",", @new));
|
|
|
|
my ($added, $removed) = Bugzilla::Util::diff_arrays(\@old, \@new);
|
|
|
|
foreach my $id (@$added , @$removed) {
|
|
|
|
# ValidateBugID is called without $field here so that it will
|
|
|
|
# throw an error if any of the changed bugs are not visible.
|
|
|
|
ValidateBugID($id);
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"strict_isolation"}) {
|
2006-08-12 03:45:08 +04:00
|
|
|
my $deltabug = new Bugzilla::Bug($id);
|
2005-10-22 17:07:07 +04:00
|
|
|
if (!$user->can_edit_product($deltabug->{'product_id'})) {
|
|
|
|
$vars->{'field'} = $field;
|
|
|
|
ThrowUserError("illegal_change_deps", $vars);
|
|
|
|
}
|
|
|
|
}
|
2005-10-19 01:12:47 +04:00
|
|
|
}
|
2006-07-02 00:01:52 +04:00
|
|
|
if ((@$added || @$removed)
|
|
|
|
&& !$bug->check_can_change_field($field, 0, 1, \$PrivilegesRequired))
|
|
|
|
{
|
2005-11-20 02:47:26 +03:00
|
|
|
$vars->{'privs'} = $PrivilegesRequired;
|
|
|
|
$vars->{'field'} = $field;
|
|
|
|
ThrowUserError("illegal_change", $vars);
|
|
|
|
}
|
2005-10-19 01:12:47 +04:00
|
|
|
} else {
|
|
|
|
# Bugzilla does not support mass-change of dependencies so they
|
|
|
|
# are not validated. To prevent a URL-hacking risk, the dependencies
|
|
|
|
# are deleted for mass-changes.
|
|
|
|
$cgi->delete($field);
|
2002-07-04 03:07:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-25 08:49:32 +04:00
|
|
|
# do a match on the fields if applicable
|
|
|
|
|
2006-08-24 19:56:39 +04:00
|
|
|
# The order of these function calls is important, as Flag::validate
|
|
|
|
# assumes User::match_field has ensured that the values
|
2004-10-25 08:49:32 +04:00
|
|
|
# in the requestee fields are legitimate user email addresses.
|
2005-04-08 03:37:56 +04:00
|
|
|
&Bugzilla::User::match_field($cgi, {
|
2004-10-25 08:49:32 +04:00
|
|
|
'qa_contact' => { 'type' => 'single' },
|
|
|
|
'newcc' => { 'type' => 'multi' },
|
|
|
|
'masscc' => { 'type' => 'multi' },
|
|
|
|
'assigned_to' => { 'type' => 'single' },
|
2005-08-20 21:02:41 +04:00
|
|
|
'^requestee(_type)?-(\d+)$' => { 'type' => 'multi' },
|
2004-10-25 08:49:32 +04:00
|
|
|
});
|
2005-07-08 09:29:15 +04:00
|
|
|
|
|
|
|
# Validate flags in all cases. validate() should not detect any
|
|
|
|
# reference to flags if $cgi->param('id') is undefined.
|
|
|
|
Bugzilla::Flag::validate($cgi, $cgi->param('id'));
|
2004-10-25 08:49:32 +04:00
|
|
|
|
2001-05-31 19:52:25 +04:00
|
|
|
######################################################################
|
|
|
|
# End Data/Security Validation
|
|
|
|
######################################################################
|
|
|
|
|
2006-10-17 10:24:18 +04:00
|
|
|
print $cgi->header() unless Bugzilla->usage_mode == USAGE_MODE_EMAIL;
|
2002-10-10 23:02:36 +04:00
|
|
|
$vars->{'title_tag'} = "bug_processed";
|
2002-09-23 00:28:25 +04:00
|
|
|
|
|
|
|
# Set the title if we can see a mid-air coming. This test may have false
|
|
|
|
# negatives, but never false positives, and should catch the majority of cases.
|
|
|
|
# It only works at all in the single bug case.
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('id')) {
|
2006-04-07 02:41:41 +04:00
|
|
|
my $delta_ts = $dbh->selectrow_array(
|
|
|
|
q{SELECT delta_ts FROM bugs WHERE bug_id = ?},
|
|
|
|
undef, $cgi->param('id'));
|
2002-09-23 00:28:25 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('delta_ts') && $cgi->param('delta_ts') ne $delta_ts)
|
2002-09-23 00:28:25 +04:00
|
|
|
{
|
2002-10-10 23:02:36 +04:00
|
|
|
$vars->{'title_tag'} = "mid_air";
|
2007-03-11 14:50:59 +03:00
|
|
|
ThrowCodeError('undefined_field', {field => 'longdesclength'})
|
|
|
|
if !defined $cgi->param('longdesclength');
|
2002-09-23 00:28:25 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2006-06-19 20:41:17 +04:00
|
|
|
# Set up the vars for navigational <link> elements
|
2005-07-11 02:37:15 +04:00
|
|
|
my @bug_list;
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($cgi->cookie("BUGLIST") && defined $cgi->param('id')) {
|
2005-07-11 02:37:15 +04:00
|
|
|
@bug_list = split(/:/, $cgi->cookie("BUGLIST"));
|
2002-11-28 13:49:58 +03:00
|
|
|
$vars->{'bug_list'} = \@bug_list;
|
|
|
|
}
|
|
|
|
|
2001-12-16 03:05:54 +03:00
|
|
|
# This function checks if there is a comment required for a specific
|
|
|
|
# function and tests, if the comment was given.
|
2002-09-22 21:15:13 +04:00
|
|
|
# If comments are required for functions is defined by params.
|
2001-12-16 03:05:54 +03:00
|
|
|
#
|
2005-08-13 16:27:04 +04:00
|
|
|
sub CheckonComment {
|
2001-12-16 03:05:54 +03:00
|
|
|
my ($function) = (@_);
|
2006-07-06 10:12:05 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2001-12-16 03:05:54 +03:00
|
|
|
|
|
|
|
# Param is 1 if comment should be added !
|
2006-07-04 01:26:22 +04:00
|
|
|
my $ret = Bugzilla->params->{ "commenton" . $function };
|
2001-12-16 03:05:54 +03:00
|
|
|
|
|
|
|
# Allow without comment in case of undefined Params.
|
|
|
|
$ret = 0 unless ( defined( $ret ));
|
|
|
|
|
|
|
|
if( $ret ) {
|
2005-04-08 04:45:47 +04:00
|
|
|
if (!defined $cgi->param('comment')
|
|
|
|
|| $cgi->param('comment') =~ /^\s*$/) {
|
2001-12-16 03:05:54 +03:00
|
|
|
# No comment - sorry, action not allowed !
|
2002-08-16 02:57:21 +04:00
|
|
|
ThrowUserError("comment_required");
|
2001-12-16 03:05:54 +03:00
|
|
|
} else {
|
|
|
|
$ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( ! $ret ); # Return val has to be inverted
|
|
|
|
}
|
|
|
|
|
2001-08-11 05:18:24 +04:00
|
|
|
# Figure out whether or not the user is trying to change the product
|
|
|
|
# (either the "product" variable is not set to "don't change" or the
|
|
|
|
# user is changing a single bug and has changed the bug's product),
|
|
|
|
# and make the user verify the version, component, target milestone,
|
|
|
|
# and bug groups if so.
|
2005-04-08 04:45:47 +04:00
|
|
|
my $oldproduct = '';
|
|
|
|
if (defined $cgi->param('id')) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$oldproduct = $dbh->selectrow_array(
|
|
|
|
q{SELECT name FROM products INNER JOIN bugs
|
|
|
|
ON products.id = bugs.product_id WHERE bug_id = ?},
|
|
|
|
undef, $cgi->param('id'));
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
2005-04-08 04:45:47 +04:00
|
|
|
|
2007-01-06 22:39:20 +03:00
|
|
|
# At this point, the product must be defined, even if set to "dontchange".
|
|
|
|
defined($cgi->param('product'))
|
|
|
|
|| ThrowCodeError('undefined_field', { field => 'product' });
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if (((defined $cgi->param('id') && $cgi->param('product') ne $oldproduct)
|
|
|
|
|| (!$cgi->param('id')
|
|
|
|
&& $cgi->param('product') ne $cgi->param('dontchange')))
|
2001-12-16 03:05:54 +03:00
|
|
|
&& CheckonComment( "reassignbycomponent" ))
|
|
|
|
{
|
2002-11-18 07:27:34 +03:00
|
|
|
# Check to make sure they actually have the right to change the product
|
2006-07-02 00:01:52 +04:00
|
|
|
if (!$bug->check_can_change_field('product', $oldproduct, $cgi->param('product'),
|
|
|
|
\$PrivilegesRequired))
|
|
|
|
{
|
2005-04-08 04:45:47 +04:00
|
|
|
$vars->{'oldvalue'} = $oldproduct;
|
|
|
|
$vars->{'newvalue'} = $cgi->param('product');
|
2002-11-18 07:27:34 +03:00
|
|
|
$vars->{'field'} = 'product';
|
2005-01-21 02:22:10 +03:00
|
|
|
$vars->{'privs'} = $PrivilegesRequired;
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("illegal_change", $vars);
|
2002-11-18 07:27:34 +03:00
|
|
|
}
|
2005-05-12 06:07:10 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
my $prod = $cgi->param('product');
|
2006-03-03 02:50:17 +03:00
|
|
|
my $prod_obj = new Bugzilla::Product({name => $prod});
|
2005-05-12 06:07:10 +04:00
|
|
|
trick_taint($prod);
|
|
|
|
|
|
|
|
# If at least one bug does not belong to the product we are
|
|
|
|
# moving to, we have to check whether or not the user is
|
|
|
|
# allowed to enter bugs into that product.
|
|
|
|
# Note that this check must be done early to avoid the leakage
|
|
|
|
# of component, version and target milestone names.
|
|
|
|
my $check_can_enter =
|
|
|
|
$dbh->selectrow_array("SELECT 1 FROM bugs
|
|
|
|
INNER JOIN products
|
|
|
|
ON bugs.product_id = products.id
|
|
|
|
WHERE products.name != ?
|
|
|
|
AND bugs.bug_id IN
|
|
|
|
(" . join(',', @idlist) . ") " .
|
|
|
|
$dbh->sql_limit(1),
|
|
|
|
undef, $prod);
|
|
|
|
|
2005-10-12 06:08:57 +04:00
|
|
|
if ($check_can_enter) { $user->can_enter_product($prod, 1) }
|
1999-12-03 02:21:42 +03:00
|
|
|
|
|
|
|
# note that when this script is called from buglist.cgi (rather
|
|
|
|
# than show_bug.cgi), it's possible that the product will be changed
|
|
|
|
# but that the version and/or component will be set to
|
|
|
|
# "--dont_change--" but still happen to be correct. in this case,
|
|
|
|
# the if statement will incorrectly trigger anyway. this is a
|
|
|
|
# pretty weird case, and not terribly unreasonable behavior, but
|
|
|
|
# worthy of a comment, perhaps.
|
|
|
|
#
|
2006-03-03 02:50:17 +03:00
|
|
|
my @version_names = map($_->name, @{$prod_obj->versions});
|
2006-04-02 23:07:14 +04:00
|
|
|
my @component_names = map($_->name, @{$prod_obj->components});
|
2007-01-06 22:39:20 +03:00
|
|
|
my $vok = 0;
|
|
|
|
if (defined $cgi->param('version')) {
|
|
|
|
$vok = lsearch(\@version_names, $cgi->param('version')) >= 0;
|
|
|
|
}
|
|
|
|
my $cok = 0;
|
|
|
|
if (defined $cgi->param('component')) {
|
|
|
|
$cok = lsearch(\@component_names, $cgi->param('component')) >= 0;
|
|
|
|
}
|
2000-03-21 19:47:06 +03:00
|
|
|
|
|
|
|
my $mok = 1; # so it won't affect the 'if' statement if milestones aren't used
|
2006-04-02 23:07:14 +04:00
|
|
|
my @milestone_names = ();
|
2006-07-04 01:26:22 +04:00
|
|
|
if ( Bugzilla->params->{"usetargetmilestone"} ) {
|
2006-04-02 23:07:14 +04:00
|
|
|
@milestone_names = map($_->name, @{$prod_obj->milestones});
|
2007-01-06 22:39:20 +03:00
|
|
|
$mok = 0;
|
|
|
|
if (defined $cgi->param('target_milestone')) {
|
|
|
|
$mok = lsearch(\@milestone_names, $cgi->param('target_milestone')) >= 0;
|
|
|
|
}
|
2000-03-21 19:47:06 +03:00
|
|
|
}
|
|
|
|
|
2006-11-05 03:27:10 +03:00
|
|
|
# We cannot be sure if the component is the same by only checking $cok; the
|
|
|
|
# current component name could exist in the new product. So always display
|
|
|
|
# the form and use the confirm_product_change param to check if that was
|
|
|
|
# shown. Also show the verification form if the product-specific fields
|
|
|
|
# somehow still need to be verified, or if we need to verify whether or not
|
|
|
|
# to add the bugs to their new product's group.
|
|
|
|
if (!$vok || !$cok || !$mok || !defined $cgi->param('confirm_product_change')
|
|
|
|
|| (AnyDefaultGroups() && !defined $cgi->param('addtonewgroup'))) {
|
2006-10-17 10:24:18 +04:00
|
|
|
|
|
|
|
if (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
if (!$vok) {
|
|
|
|
ThrowUserError('version_not_valid', {
|
|
|
|
version => $cgi->param('version'),
|
|
|
|
product => $cgi->param('product')});
|
|
|
|
}
|
|
|
|
if (!$cok) {
|
|
|
|
ThrowUserError('component_not_valid', {
|
|
|
|
product => $cgi->param('product'),
|
|
|
|
name => $cgi->param('component')});
|
|
|
|
}
|
|
|
|
if (!$mok) {
|
|
|
|
ThrowUserError('milestone_not_valid', {
|
|
|
|
product => $cgi->param('product'),
|
|
|
|
milestone => $cgi->param('target_milestone')});
|
|
|
|
}
|
|
|
|
}
|
2002-04-13 01:02:00 +04:00
|
|
|
|
2006-11-05 03:27:10 +03:00
|
|
|
if (!$vok || !$cok || !$mok
|
|
|
|
|| !defined $cgi->param('confirm_product_change'))
|
|
|
|
{
|
2002-04-13 01:02:00 +04:00
|
|
|
$vars->{'verify_fields'} = 1;
|
2002-06-25 14:07:59 +04:00
|
|
|
my %defaults;
|
|
|
|
# We set the defaults to these fields to the old value,
|
2006-07-06 16:06:43 +04:00
|
|
|
# if it's a valid option, otherwise we use the default where
|
2005-11-25 22:48:04 +03:00
|
|
|
# that's appropriate
|
2006-03-03 02:50:17 +03:00
|
|
|
$vars->{'versions'} = \@version_names;
|
2004-12-09 13:49:53 +03:00
|
|
|
if ($vok) {
|
2005-04-08 04:45:47 +04:00
|
|
|
$defaults{'version'} = $cgi->param('version');
|
2002-06-25 14:07:59 +04:00
|
|
|
}
|
2007-01-06 22:39:20 +03:00
|
|
|
elsif (scalar(@version_names) == 1) {
|
|
|
|
$defaults{'version'} = $version_names[0];
|
|
|
|
}
|
|
|
|
|
2006-04-02 23:07:14 +04:00
|
|
|
$vars->{'components'} = \@component_names;
|
2004-12-09 13:49:53 +03:00
|
|
|
if ($cok) {
|
2005-04-08 04:45:47 +04:00
|
|
|
$defaults{'component'} = $cgi->param('component');
|
2002-06-25 14:07:59 +04:00
|
|
|
}
|
2007-01-06 22:39:20 +03:00
|
|
|
elsif (scalar(@component_names) == 1) {
|
|
|
|
$defaults{'component'} = $component_names[0];
|
|
|
|
}
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"usetargetmilestone"}) {
|
2002-04-13 01:02:00 +04:00
|
|
|
$vars->{'use_target_milestone'} = 1;
|
2006-04-02 23:07:14 +04:00
|
|
|
$vars->{'milestones'} = \@milestone_names;
|
2004-12-09 13:49:53 +03:00
|
|
|
if ($mok) {
|
2005-04-08 04:45:47 +04:00
|
|
|
$defaults{'target_milestone'} = $cgi->param('target_milestone');
|
2002-06-25 14:07:59 +04:00
|
|
|
} else {
|
2006-04-07 02:41:41 +04:00
|
|
|
$defaults{'target_milestone'} = $dbh->selectrow_array(
|
|
|
|
q{SELECT defaultmilestone FROM products
|
|
|
|
WHERE name = ?}, undef, $prod);
|
2002-06-25 14:07:59 +04:00
|
|
|
}
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
2002-04-13 01:02:00 +04:00
|
|
|
else {
|
|
|
|
$vars->{'use_target_milestone'} = 0;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2002-06-25 14:07:59 +04:00
|
|
|
$vars->{'defaults'} = \%defaults;
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
2002-04-13 01:02:00 +04:00
|
|
|
else {
|
2004-12-09 13:49:53 +03:00
|
|
|
$vars->{'verify_fields'} = 0;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2002-04-13 01:02:00 +04:00
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
$vars->{'verify_bug_group'} = (AnyDefaultGroups()
|
2005-04-08 04:45:47 +04:00
|
|
|
&& !defined $cgi->param('addtonewgroup'));
|
2002-04-13 01:02:00 +04:00
|
|
|
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("bug/process/verify-new-product.html.tmpl", $vars)
|
2002-04-13 01:02:00 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
1998-09-16 01:49:26 +04:00
|
|
|
exit;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-06 22:39:20 +03:00
|
|
|
# At this point, the component must be defined, even if set to "dontchange".
|
|
|
|
defined($cgi->param('component'))
|
|
|
|
|| ThrowCodeError('undefined_field', { field => 'component' });
|
|
|
|
|
2001-08-26 22:51:45 +04:00
|
|
|
# Confirm that the reporter of the current bug can access the bug we are duping to.
|
|
|
|
sub DuplicateUserConfirm {
|
2006-07-06 10:12:05 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
my $template = Bugzilla->template;
|
|
|
|
|
2001-10-23 19:44:53 +04:00
|
|
|
# if we've already been through here, then exit
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('confirm_add_duplicate')) {
|
2001-10-23 19:44:53 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
# Remember that we validated both these ids earlier, so we know
|
|
|
|
# they are both valid bug ids
|
|
|
|
my $dupe = $cgi->param('id');
|
|
|
|
my $original = $cgi->param('dup_id');
|
2001-08-26 22:51:45 +04:00
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
my $reporter = $dbh->selectrow_array(
|
|
|
|
q{SELECT reporter FROM bugs WHERE bug_id = ?}, undef, $dupe);
|
2004-08-04 20:17:10 +04:00
|
|
|
my $rep_user = Bugzilla::User->new($reporter);
|
2001-08-26 22:51:45 +04:00
|
|
|
|
2004-08-04 20:17:10 +04:00
|
|
|
if ($rep_user->can_see_bug($original)) {
|
2005-04-08 04:45:47 +04:00
|
|
|
$cgi->param('confirm_add_duplicate', '1');
|
2001-08-26 22:51:45 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-10-17 10:24:18 +04:00
|
|
|
elsif (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
# The email interface defaults to the safe alternative, which is
|
|
|
|
# not CC'ing the user.
|
|
|
|
$cgi->param('confirm_add_duplicate', 0);
|
|
|
|
return;
|
|
|
|
}
|
2001-10-23 19:44:53 +04:00
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
$vars->{'cclist_accessible'} = $dbh->selectrow_array(
|
|
|
|
q{SELECT cclist_accessible FROM bugs WHERE bug_id = ?},
|
|
|
|
undef, $original);
|
2000-02-17 08:15:23 +03:00
|
|
|
|
2001-08-26 22:51:45 +04:00
|
|
|
# Once in this part of the subroutine, the user has not been auto-validated
|
|
|
|
# and the duper has not chosen whether or not to add to CC list, so let's
|
|
|
|
# ask the duper what he/she wants to do.
|
2000-02-17 08:15:23 +03:00
|
|
|
|
2002-04-13 01:02:00 +04:00
|
|
|
$vars->{'original_bug_id'} = $original;
|
|
|
|
$vars->{'duplicate_bug_id'} = $dupe;
|
|
|
|
|
|
|
|
# Confirm whether or not to add the reporter to the cc: list
|
|
|
|
# of the original bug (the one this bug is being duped against).
|
2003-05-05 05:15:38 +04:00
|
|
|
print Bugzilla->cgi->header();
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("bug/process/confirm-duplicate.html.tmpl", $vars)
|
2002-04-13 01:02:00 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2001-08-26 22:51:45 +04:00
|
|
|
exit;
|
2004-12-21 12:04:01 +03:00
|
|
|
}
|
2000-02-17 08:15:23 +03:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('id')) {
|
1999-12-03 02:21:42 +03:00
|
|
|
# since this means that we were called from show_bug.cgi, now is a good
|
|
|
|
# time to do a whole bunch of error checking that can't easily happen when
|
|
|
|
# we've been called from buglist.cgi, because buglist.cgi only tweaks
|
|
|
|
# values that have been changed instead of submitting all the new values.
|
|
|
|
# (XXX those error checks need to happen too, but implementing them
|
|
|
|
# is more work in the current architecture of this script...)
|
2004-12-09 13:49:53 +03:00
|
|
|
|
2007-03-08 02:54:01 +03:00
|
|
|
my $prod = $bug->_check_product($cgi->param('product'));
|
|
|
|
$cgi->param('product', $prod->name);
|
|
|
|
|
|
|
|
my $comp = $bug->_check_component($prod,
|
|
|
|
scalar $cgi->param('component'));
|
|
|
|
$cgi->param('component', $comp->name);
|
|
|
|
|
|
|
|
$cgi->param('version', $bug->_check_version($prod,
|
|
|
|
scalar $cgi->param('version')));
|
|
|
|
$cgi->param('target_milestone', $bug->_check_target_milestone($prod,
|
|
|
|
scalar $cgi->param('target_milestone')));
|
|
|
|
$cgi->param('rep_platform',
|
|
|
|
$bug->_check_rep_platform($cgi->param('rep_platform')));
|
|
|
|
$cgi->param('op_sys',
|
|
|
|
$bug->_check_op_sys($cgi->param('op_sys')));
|
|
|
|
$cgi->param('priority',
|
|
|
|
$bug->_check_priority($cgi->param('priority')));
|
|
|
|
$cgi->param('bug_severity',
|
|
|
|
$bug->_check_bug_severity($cgi->param('bug_severity')));
|
|
|
|
$cgi->param('bug_file_loc',
|
|
|
|
$bug->_check_bug_file_loc($cgi->param('bug_file_loc')));
|
|
|
|
$cgi->param('short_desc',
|
|
|
|
$bug->_check_short_desc($cgi->param('short_desc')));
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2005-08-21 21:36:51 +04:00
|
|
|
my $action = trim($cgi->param('action') || '');
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if ($action eq Bugzilla->params->{'move-button-text'}) {
|
|
|
|
Bugzilla->params->{'move-enabled'} || ThrowUserError("move_bugs_disabled");
|
2005-08-21 21:36:51 +04:00
|
|
|
|
2005-09-09 03:40:10 +04:00
|
|
|
$user->is_mover || ThrowUserError("auth_failure", {action => 'move',
|
|
|
|
object => 'bugs'});
|
2005-08-21 21:36:51 +04:00
|
|
|
|
|
|
|
$dbh->bz_lock_tables('bugs WRITE', 'bugs_activity WRITE', 'duplicates WRITE',
|
|
|
|
'longdescs WRITE', 'profiles READ', 'groups READ',
|
|
|
|
'bug_group_map READ', 'group_group_map READ',
|
|
|
|
'user_group_map READ', 'classifications READ',
|
|
|
|
'products READ', 'components READ', 'votes READ',
|
2007-03-10 17:46:07 +03:00
|
|
|
'cc READ', 'fielddefs READ', 'bug_status READ',
|
|
|
|
'resolution READ');
|
2005-08-21 21:36:51 +04:00
|
|
|
|
|
|
|
my @bugs;
|
|
|
|
# First update all moved bugs.
|
|
|
|
foreach my $id (@idlist) {
|
2006-08-12 03:45:08 +04:00
|
|
|
my $bug = new Bugzilla::Bug($id);
|
2005-08-21 21:36:51 +04:00
|
|
|
push(@bugs, $bug);
|
2007-03-10 17:46:07 +03:00
|
|
|
$bug->add_comment(scalar $cgi->param('comment'),
|
|
|
|
{ type => CMT_MOVED_TO, extra_data => $user->login });
|
|
|
|
$bug->set_status('RESOLVED');
|
|
|
|
$bug->set_resolution('MOVED');
|
2007-03-09 08:17:55 +03:00
|
|
|
}
|
2005-08-21 21:36:51 +04:00
|
|
|
|
2007-03-10 17:46:07 +03:00
|
|
|
$_->update() foreach @bugs;
|
2005-08-21 21:36:51 +04:00
|
|
|
$dbh->bz_unlock_tables();
|
|
|
|
|
|
|
|
# Now send emails.
|
|
|
|
foreach my $id (@idlist) {
|
2005-09-09 03:40:10 +04:00
|
|
|
$vars->{'mailrecipients'} = { 'changer' => $user->login };
|
2005-08-21 21:36:51 +04:00
|
|
|
$vars->{'id'} = $id;
|
|
|
|
$vars->{'type'} = "move";
|
2006-10-17 10:24:18 +04:00
|
|
|
send_results($id, $vars);
|
2005-08-21 21:36:51 +04:00
|
|
|
}
|
|
|
|
# Prepare and send all data about these bugs to the new database
|
2006-07-04 01:26:22 +04:00
|
|
|
my $to = Bugzilla->params->{'move-to-address'};
|
2005-08-21 21:36:51 +04:00
|
|
|
$to =~ s/@/\@/;
|
2006-07-04 01:26:22 +04:00
|
|
|
my $from = Bugzilla->params->{'moved-from-address'};
|
2005-08-21 21:36:51 +04:00
|
|
|
$from =~ s/@/\@/;
|
|
|
|
my $msg = "To: $to\n";
|
|
|
|
$msg .= "From: Bugzilla <" . $from . ">\n";
|
|
|
|
$msg .= "Subject: Moving bug(s) " . join(', ', @idlist) . "\n\n";
|
|
|
|
|
2006-02-21 16:08:24 +03:00
|
|
|
my @fieldlist = (Bugzilla::Bug->fields, 'group', 'long_desc',
|
2005-11-07 23:41:12 +03:00
|
|
|
'attachment', 'attachmentdata');
|
2005-08-21 21:36:51 +04:00
|
|
|
my %displayfields;
|
|
|
|
foreach (@fieldlist) {
|
|
|
|
$displayfields{$_} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->process("bug/show.xml.tmpl", { bugs => \@bugs,
|
|
|
|
displayfields => \%displayfields,
|
|
|
|
}, \$msg)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
|
|
|
$msg .= "\n";
|
2006-06-02 14:50:15 +04:00
|
|
|
MessageToMTA($msg);
|
2005-08-21 21:36:51 +04:00
|
|
|
|
|
|
|
# End the response page.
|
2006-10-17 10:24:18 +04:00
|
|
|
unless (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
$template->process("bug/navigate.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
$template->process("global/footer.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
2005-08-21 21:36:51 +04:00
|
|
|
exit;
|
2000-07-14 03:12:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query = "UPDATE bugs SET";
|
1998-09-16 01:49:26 +04:00
|
|
|
$::comma = "";
|
2006-07-06 10:12:05 +04:00
|
|
|
local our @values;
|
1998-09-16 01:49:26 +04:00
|
|
|
umask(0);
|
|
|
|
|
2005-02-28 21:55:07 +03:00
|
|
|
sub _remove_remaining_time {
|
2006-07-06 10:12:05 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2006-09-04 20:21:49 +04:00
|
|
|
if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
|
2005-04-08 04:45:47 +04:00
|
|
|
if ( defined $cgi->param('remaining_time')
|
|
|
|
&& $cgi->param('remaining_time') > 0 )
|
2005-02-28 21:55:07 +03:00
|
|
|
{
|
2005-04-08 04:45:47 +04:00
|
|
|
$cgi->param('remaining_time', 0);
|
2005-02-28 21:55:07 +03:00
|
|
|
$vars->{'message'} = "remaining_time_zeroed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DoComma();
|
|
|
|
$::query .= "remaining_time = 0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
sub DoComma {
|
|
|
|
$::query .= "$::comma\n ";
|
|
|
|
$::comma = ",";
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
sub DoConfirm {
|
2006-07-06 10:12:05 +04:00
|
|
|
my $bug = shift;
|
|
|
|
if ($bug->check_can_change_field("canconfirm", 0, 1,
|
|
|
|
\$PrivilegesRequired))
|
|
|
|
{
|
2000-02-17 08:15:23 +03:00
|
|
|
DoComma();
|
|
|
|
$::query .= "everconfirmed = 1";
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-27 05:44:34 +04:00
|
|
|
# Changing this so that it will process groups from checkboxes instead of
|
|
|
|
# select lists. This means that instead of looking for the bit-X values in
|
|
|
|
# the form, we need to loop through all the bug groups this user has access
|
|
|
|
# to, and for each one, see if it's selected.
|
2001-11-03 08:49:23 +03:00
|
|
|
# If the form element isn't present, or the user isn't in the group, leave
|
|
|
|
# it as-is
|
2002-11-24 22:56:34 +03:00
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
my @groupAdd = ();
|
|
|
|
my @groupDel = ();
|
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
my $groups = $dbh->selectall_arrayref(
|
|
|
|
qq{SELECT groups.id, isactive FROM groups
|
|
|
|
WHERE id IN($grouplist) AND isbuggroup = 1});
|
|
|
|
foreach my $group (@$groups) {
|
|
|
|
my ($b, $isactive) = @$group;
|
2002-09-22 21:15:13 +04:00
|
|
|
# The multiple change page may not show all groups a bug is in
|
|
|
|
# (eg product groups when listing more than one product)
|
|
|
|
# Only consider groups which were present on the form. We can't do this
|
|
|
|
# for single bug changes because non-checked checkboxes aren't present.
|
2006-07-06 16:06:43 +04:00
|
|
|
# All the checkboxes should be shown in that case, though, so it isn't
|
2002-09-22 21:15:13 +04:00
|
|
|
# an issue there
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('id') || defined $cgi->param("bit-$b")) {
|
|
|
|
if (!$cgi->param("bit-$b")) {
|
2002-09-22 21:15:13 +04:00
|
|
|
push(@groupDel, $b);
|
2005-04-08 04:45:47 +04:00
|
|
|
} elsif ($cgi->param("bit-$b") == 1 && $isactive) {
|
2002-09-22 21:15:13 +04:00
|
|
|
push(@groupAdd, $b);
|
2001-11-03 08:49:23 +03:00
|
|
|
}
|
|
|
|
}
|
1999-03-11 19:30:54 +03:00
|
|
|
}
|
|
|
|
|
2004-12-09 13:49:53 +03:00
|
|
|
foreach my $field ("rep_platform", "priority", "bug_severity",
|
|
|
|
"bug_file_loc", "short_desc", "version", "op_sys",
|
1999-01-28 00:17:10 +03:00
|
|
|
"target_milestone", "status_whiteboard") {
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param($field)) {
|
|
|
|
if (!$cgi->param('dontchange')
|
|
|
|
|| $cgi->param($field) ne $cgi->param('dontchange')) {
|
1998-09-16 01:49:26 +04:00
|
|
|
DoComma();
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "$field = ?";
|
|
|
|
my $value = trim($cgi->param($field));
|
|
|
|
trick_taint($value);
|
|
|
|
push(@values, $value);
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-21 16:08:24 +03:00
|
|
|
# Add custom fields data to the query that will update the database.
|
2006-09-09 03:11:41 +04:00
|
|
|
foreach my $field (Bugzilla->get_fields({custom => 1, obsolete => 0})) {
|
|
|
|
my $fname = $field->name;
|
|
|
|
if (defined $cgi->param($fname)
|
2006-02-21 16:08:24 +03:00
|
|
|
&& (!$cgi->param('dontchange')
|
2006-09-09 03:11:41 +04:00
|
|
|
|| $cgi->param($fname) ne $cgi->param('dontchange')))
|
2006-02-21 16:08:24 +03:00
|
|
|
{
|
|
|
|
DoComma();
|
2006-09-09 03:11:41 +04:00
|
|
|
$::query .= "$fname = ?";
|
|
|
|
my $value = $cgi->param($fname);
|
|
|
|
check_field($fname, $value) if ($field->type == FIELD_TYPE_SINGLE_SELECT);
|
2006-04-07 02:41:41 +04:00
|
|
|
trick_taint($value);
|
|
|
|
push(@values, $value);
|
2006-02-21 16:08:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-29 21:24:54 +04:00
|
|
|
my $product;
|
2007-01-05 02:34:42 +03:00
|
|
|
my $prod_changed = 0;
|
2005-11-20 02:47:26 +03:00
|
|
|
my @newprod_ids;
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($cgi->param('product') ne $cgi->param('dontchange')) {
|
2006-05-29 21:24:54 +04:00
|
|
|
$product = Bugzilla::Product::check_product(scalar $cgi->param('product'));
|
|
|
|
|
2002-08-12 09:43:05 +04:00
|
|
|
DoComma();
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "product_id = ?";
|
2006-05-29 21:24:54 +04:00
|
|
|
push(@values, $product->id);
|
|
|
|
@newprod_ids = ($product->id);
|
2007-01-05 02:34:42 +03:00
|
|
|
# If the bug remains in the same product, leave $prod_changed set to 0.
|
|
|
|
# Even with 'strict_isolation' turned on, we ignore users who already
|
|
|
|
# play a role for the bug; else you would never be able to edit it.
|
|
|
|
# If you want to move the bug to another product, then you first have to
|
|
|
|
# remove these users from the bug.
|
|
|
|
unless (defined $cgi->param('id') && $bug->product_id == $product->id) {
|
|
|
|
$prod_changed = 1;
|
|
|
|
}
|
2002-08-12 09:43:05 +04:00
|
|
|
} else {
|
2005-11-20 02:47:26 +03:00
|
|
|
@newprod_ids = @{$dbh->selectcol_arrayref("SELECT DISTINCT product_id
|
|
|
|
FROM bugs
|
|
|
|
WHERE bug_id IN (" .
|
|
|
|
join(',', @idlist) .
|
|
|
|
")")};
|
|
|
|
if (scalar(@newprod_ids) == 1) {
|
2006-06-07 02:55:29 +04:00
|
|
|
$product = new Bugzilla::Product($newprod_ids[0]);
|
2005-11-20 02:47:26 +03:00
|
|
|
}
|
2002-08-12 09:43:05 +04:00
|
|
|
}
|
|
|
|
|
2006-05-29 21:24:54 +04:00
|
|
|
my $component;
|
2007-04-13 18:53:25 +04:00
|
|
|
my (%cc_add, %cc_remove);
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($cgi->param('component') ne $cgi->param('dontchange')) {
|
2005-11-20 02:47:26 +03:00
|
|
|
if (scalar(@newprod_ids) > 1) {
|
2002-09-13 02:51:50 +04:00
|
|
|
ThrowUserError("no_component_change_for_multiple_products");
|
2002-08-12 09:43:05 +04:00
|
|
|
}
|
2006-05-29 21:24:54 +04:00
|
|
|
$component =
|
|
|
|
Bugzilla::Component::check_component($product, scalar $cgi->param('component'));
|
|
|
|
|
|
|
|
# This parameter is required later when checking fields the user can change.
|
|
|
|
$cgi->param('component_id', $component->id);
|
2002-08-12 09:43:05 +04:00
|
|
|
DoComma();
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "component_id = ?";
|
2006-05-29 21:24:54 +04:00
|
|
|
push(@values, $component->id);
|
2007-04-13 18:53:25 +04:00
|
|
|
|
|
|
|
# Add in the default CC list for the component if we are moving bugs.
|
|
|
|
if (!$cgi->param('id') || $component->id != $bug->component_id) {
|
|
|
|
foreach my $cc (@{$component->initial_cc}) {
|
|
|
|
# NewCC must be defined or the code below won't insert
|
|
|
|
# any CCs.
|
|
|
|
$cgi->param('newcc') || $cgi->param('newcc', "");
|
|
|
|
$cc_add{$cc->id} = $cc->login;
|
|
|
|
}
|
|
|
|
}
|
2002-08-12 09:43:05 +04:00
|
|
|
}
|
|
|
|
|
2002-07-04 03:07:14 +04:00
|
|
|
# If this installation uses bug aliases, and the user is changing the alias,
|
|
|
|
# add this change to the query.
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"usebugaliases"} && defined $cgi->param('alias')) {
|
2005-04-08 04:45:47 +04:00
|
|
|
my $alias = trim($cgi->param('alias'));
|
2002-07-04 03:07:14 +04:00
|
|
|
|
|
|
|
# Since aliases are unique (like bug numbers), they can only be changed
|
|
|
|
# for one bug at a time, so ignore the alias change unless only a single
|
|
|
|
# bug is being changed.
|
|
|
|
if (scalar(@idlist) == 1) {
|
|
|
|
# Add the alias change to the query. If the field contains the blank
|
|
|
|
# value, make the field be NULL to indicate that the bug has no alias.
|
|
|
|
# Otherwise, if the field contains a value, update the record
|
|
|
|
# with that value.
|
|
|
|
DoComma();
|
2005-05-03 22:44:54 +04:00
|
|
|
if ($alias ne "") {
|
|
|
|
ValidateBugAlias($alias, $idlist[0]);
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "alias = ?";
|
|
|
|
push(@values, $alias);
|
2002-10-26 05:57:09 +04:00
|
|
|
} else {
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "alias = NULL";
|
2002-10-26 05:57:09 +04:00
|
|
|
}
|
2002-07-04 03:07:14 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-20 22:18:37 +03:00
|
|
|
|
2001-08-17 15:15:04 +04:00
|
|
|
# If the user is submitting changes from show_bug.cgi for a single bug,
|
|
|
|
# and that bug is restricted to a group, process the checkboxes that
|
2002-02-13 06:05:15 +03:00
|
|
|
# allowed the user to set whether or not the reporter
|
2001-08-17 15:15:04 +04:00
|
|
|
# and cc list can see the bug even if they are not members of all groups
|
|
|
|
# to which the bug is restricted.
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('id')) {
|
2006-04-07 02:41:41 +04:00
|
|
|
my ($havegroup) = $dbh->selectrow_array(
|
|
|
|
q{SELECT group_id FROM bug_group_map WHERE bug_id = ?},
|
|
|
|
undef, $cgi->param('id'));
|
2002-09-22 21:15:13 +04:00
|
|
|
if ( $havegroup ) {
|
2001-08-13 04:46:20 +04:00
|
|
|
DoComma();
|
2005-04-08 04:45:47 +04:00
|
|
|
$cgi->param('reporter_accessible',
|
|
|
|
$cgi->param('reporter_accessible') ? '1' : '0');
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "reporter_accessible = ?";
|
|
|
|
push(@values, $cgi->param('reporter_accessible'));
|
2001-08-13 04:46:20 +04:00
|
|
|
|
|
|
|
DoComma();
|
2005-04-08 04:45:47 +04:00
|
|
|
$cgi->param('cclist_accessible',
|
|
|
|
$cgi->param('cclist_accessible') ? '1' : '0');
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "cclist_accessible = ?";
|
|
|
|
push(@values, $cgi->param('cclist_accessible'));
|
2001-08-13 04:46:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if ( defined $cgi->param('id') &&
|
|
|
|
(Bugzilla->params->{"insidergroup"}
|
2006-09-04 20:21:49 +04:00
|
|
|
&& Bugzilla->user->in_group(Bugzilla->params->{"insidergroup"})) )
|
2006-07-04 01:26:22 +04:00
|
|
|
{
|
2005-04-08 04:45:47 +04:00
|
|
|
|
2005-11-13 21:16:33 +03:00
|
|
|
my $sth = $dbh->prepare('UPDATE longdescs SET isprivate = ?
|
|
|
|
WHERE bug_id = ? AND bug_when = ?');
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
foreach my $field ($cgi->param()) {
|
2002-08-20 01:17:28 +04:00
|
|
|
if ($field =~ /when-([0-9]+)/) {
|
|
|
|
my $sequence = $1;
|
2005-04-08 04:45:47 +04:00
|
|
|
my $private = $cgi->param("isprivate-$sequence") ? 1 : 0 ;
|
|
|
|
if ($private != $cgi->param("oisprivate-$sequence")) {
|
|
|
|
my $field_data = $cgi->param("$field");
|
2005-11-13 21:16:33 +03:00
|
|
|
# Make sure a valid date is given.
|
|
|
|
$field_data = format_time($field_data, '%Y-%m-%d %T');
|
|
|
|
$sth->execute($private, $cgi->param('id'), $field_data);
|
2002-08-20 01:17:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2001-08-13 04:46:20 +04:00
|
|
|
|
2001-08-18 00:18:33 +04:00
|
|
|
# We need to check the addresses involved in a CC change before we touch any bugs.
|
|
|
|
# What we'll do here is formulate the CC data into two hashes of ID's involved
|
|
|
|
# in this CC change. Then those hashes can be used later on for the actual change.
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('newcc')
|
|
|
|
|| defined $cgi->param('addselfcc')
|
|
|
|
|| defined $cgi->param('removecc')
|
|
|
|
|| defined $cgi->param('masscc')) {
|
2001-08-18 00:18:33 +04:00
|
|
|
# If masscc is defined, then we came from buglist and need to either add or
|
|
|
|
# remove cc's... otherwise, we came from bugform and may need to do both.
|
|
|
|
my ($cc_add, $cc_remove) = "";
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('masscc')) {
|
|
|
|
if ($cgi->param('ccaction') eq 'add') {
|
|
|
|
$cc_add = join(' ',$cgi->param('masscc'));
|
|
|
|
} elsif ($cgi->param('ccaction') eq 'remove') {
|
|
|
|
$cc_remove = join(' ',$cgi->param('masscc'));
|
2001-08-18 00:18:33 +04:00
|
|
|
}
|
|
|
|
} else {
|
2005-04-08 04:45:47 +04:00
|
|
|
$cc_add = join(' ',$cgi->param('newcc'));
|
2001-08-18 00:18:33 +04:00
|
|
|
# We came from bug_form which uses a select box to determine what cc's
|
|
|
|
# need to be removed...
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('removecc') && $cgi->param('cc')) {
|
|
|
|
$cc_remove = join (",", $cgi->param('cc'));
|
2001-08-18 00:18:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($cc_add) {
|
2003-10-17 06:07:55 +04:00
|
|
|
$cc_add =~ s/[\s,]+/ /g; # Change all delimiters to a single space
|
|
|
|
foreach my $person ( split(" ", $cc_add) ) {
|
2006-05-08 00:13:49 +04:00
|
|
|
my $pid = login_to_id($person, THROW_ERROR);
|
2001-08-18 00:18:33 +04:00
|
|
|
$cc_add{$pid} = $person;
|
|
|
|
}
|
|
|
|
}
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($cgi->param('addselfcc')) {
|
2005-01-24 08:26:56 +03:00
|
|
|
$cc_add{$whoid} = $user->login;
|
|
|
|
}
|
2001-08-18 00:18:33 +04:00
|
|
|
if ($cc_remove) {
|
2003-10-17 06:07:55 +04:00
|
|
|
$cc_remove =~ s/[\s,]+/ /g; # Change all delimiters to a single space
|
|
|
|
foreach my $person ( split(" ", $cc_remove) ) {
|
2006-05-08 00:13:49 +04:00
|
|
|
my $pid = login_to_id($person, THROW_ERROR);
|
2001-08-18 00:18:33 +04:00
|
|
|
$cc_remove{$pid} = $person;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-21 02:22:10 +03:00
|
|
|
# Store the new assignee and QA contact IDs (if any). This is the
|
|
|
|
# only way to keep these informations when bugs are reassigned by
|
2005-04-08 04:45:47 +04:00
|
|
|
# component as $cgi->param('assigned_to') and $cgi->param('qa_contact')
|
2005-01-21 02:22:10 +03:00
|
|
|
# are not the right fields to look at.
|
2005-11-20 02:47:26 +03:00
|
|
|
# If the assignee or qacontact is changed, the new one is checked when
|
|
|
|
# changed information is validated. If not, then the unchanged assignee
|
|
|
|
# or qacontact may have to be validated later.
|
2005-01-21 02:22:10 +03:00
|
|
|
|
|
|
|
my $assignee;
|
|
|
|
my $qacontact;
|
2005-11-20 02:47:26 +03:00
|
|
|
my $qacontact_checked = 0;
|
|
|
|
my $assignee_checked = 0;
|
|
|
|
|
|
|
|
my %usercache = ();
|
2005-01-21 02:22:10 +03:00
|
|
|
|
2007-04-13 18:53:25 +04:00
|
|
|
if (defined $cgi->param('assigned_to')
|
|
|
|
&& !$cgi->param('set_default_assignee')
|
|
|
|
&& trim($cgi->param('assigned_to')) ne $cgi->param('dontchange'))
|
2005-01-21 02:22:10 +03:00
|
|
|
{
|
2007-04-13 18:53:25 +04:00
|
|
|
my $name = trim($cgi->param('assigned_to'));
|
|
|
|
if ($name ne "") {
|
|
|
|
$assignee = login_to_id($name, THROW_ERROR);
|
|
|
|
if (Bugzilla->params->{"strict_isolation"}) {
|
|
|
|
$usercache{$assignee} ||= Bugzilla::User->new($assignee);
|
|
|
|
my $assign_user = $usercache{$assignee};
|
|
|
|
foreach my $product_id (@newprod_ids) {
|
|
|
|
if (!$assign_user->can_edit_product($product_id)) {
|
|
|
|
my $product_name = Bugzilla::Product->new($product_id)->name;
|
|
|
|
ThrowUserError('invalid_user_group',
|
|
|
|
{'users' => $assign_user->login,
|
|
|
|
'product' => $product_name,
|
|
|
|
'bug_id' => (scalar(@idlist) > 1)
|
|
|
|
? undef : $idlist[0]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ThrowUserError("reassign_to_empty");
|
|
|
|
}
|
|
|
|
DoComma();
|
|
|
|
$::query .= "assigned_to = ?";
|
|
|
|
push(@values, $assignee);
|
|
|
|
$assignee_checked = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (defined $cgi->param('qa_contact') && !$cgi->param('set_default_qa_contact')) {
|
2005-04-08 04:45:47 +04:00
|
|
|
my $name = trim($cgi->param('qa_contact'));
|
2005-01-21 02:22:10 +03:00
|
|
|
# The QA contact cannot be deleted from show_bug.cgi for a single bug!
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($name ne $cgi->param('dontchange')) {
|
2006-05-08 00:13:49 +04:00
|
|
|
$qacontact = login_to_id($name, THROW_ERROR) if ($name ne "");
|
2007-01-05 02:34:42 +03:00
|
|
|
if ($qacontact && Bugzilla->params->{"strict_isolation"}
|
|
|
|
&& !(defined $cgi->param('id') && $bug->qa_contact
|
|
|
|
&& $qacontact == $bug->qa_contact->id))
|
|
|
|
{
|
2005-11-20 02:47:26 +03:00
|
|
|
$usercache{$qacontact} ||= Bugzilla::User->new($qacontact);
|
|
|
|
my $qa_user = $usercache{$qacontact};
|
|
|
|
foreach my $product_id (@newprod_ids) {
|
|
|
|
if (!$qa_user->can_edit_product($product_id)) {
|
2006-06-18 03:12:36 +04:00
|
|
|
my $product_name = Bugzilla::Product->new($product_id)->name;
|
2005-11-20 02:47:26 +03:00
|
|
|
ThrowUserError('invalid_user_group',
|
|
|
|
{'users' => $qa_user->login,
|
|
|
|
'product' => $product_name,
|
|
|
|
'bug_id' => (scalar(@idlist) > 1)
|
|
|
|
? undef : $idlist[0]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2005-10-18 01:19:09 +04:00
|
|
|
}
|
2005-11-20 02:47:26 +03:00
|
|
|
$qacontact_checked = 1;
|
2005-01-21 02:22:10 +03:00
|
|
|
DoComma();
|
2005-03-15 08:20:48 +03:00
|
|
|
if($qacontact) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "qa_contact = ?";
|
|
|
|
push(@values, $qacontact);
|
2005-03-15 08:20:48 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$::query .= "qa_contact = NULL";
|
|
|
|
}
|
2005-01-21 02:22:10 +03:00
|
|
|
}
|
|
|
|
}
|
2001-08-18 00:18:33 +04:00
|
|
|
|
2007-04-13 18:53:25 +04:00
|
|
|
if ($cgi->param('set_default_assignee') || $cgi->param('set_default_qa_contact')) {
|
|
|
|
CheckonComment('reassignbycomponent');
|
|
|
|
}
|
|
|
|
|
|
|
|
my $duplicate; # It will store the ID of the bug we are pointing to, if any.
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
SWITCH: for ($cgi->param('knob')) {
|
1998-09-16 01:49:26 +04:00
|
|
|
/^none$/ && do {
|
|
|
|
last SWITCH;
|
|
|
|
};
|
2000-02-17 08:15:23 +03:00
|
|
|
/^confirm$/ && CheckonComment( "confirm" ) && do {
|
2006-07-06 10:12:05 +04:00
|
|
|
DoConfirm($bug);
|
2000-02-17 08:15:23 +03:00
|
|
|
last SWITCH;
|
|
|
|
};
|
1999-12-16 19:37:57 +03:00
|
|
|
/^accept$/ && CheckonComment( "accept" ) && do {
|
2006-07-06 10:12:05 +04:00
|
|
|
DoConfirm($bug);
|
2007-04-11 01:30:34 +04:00
|
|
|
if (Bugzilla->params->{"usetargetmilestone"}
|
2006-07-04 01:26:22 +04:00
|
|
|
&& Bugzilla->params->{"musthavemilestoneonaccept"})
|
|
|
|
{
|
2005-02-23 19:53:24 +03:00
|
|
|
$requiremilestone = 1;
|
2000-05-09 02:00:38 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
2000-02-17 08:15:23 +03:00
|
|
|
/^clearresolution$/ && CheckonComment( "clearresolution" ) && do {
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
2006-03-28 02:25:47 +04:00
|
|
|
/^(resolve|change_resolution)$/ && CheckonComment( "resolve" ) && do {
|
2006-07-06 16:06:43 +04:00
|
|
|
# Check here, because it's the only place we require the resolution
|
2006-02-28 15:52:32 +03:00
|
|
|
check_field('resolution', scalar $cgi->param('resolution'),
|
2006-06-20 00:15:18 +04:00
|
|
|
Bugzilla::Bug->settable_resolutions);
|
2005-01-21 02:22:10 +03:00
|
|
|
|
2004-03-18 08:55:41 +03:00
|
|
|
# don't resolve as fixed while still unresolved blocking bugs
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"noresolveonopenblockers"}
|
2005-04-08 04:45:47 +04:00
|
|
|
&& $cgi->param('resolution') eq 'FIXED')
|
2005-01-21 02:22:10 +03:00
|
|
|
{
|
2005-02-01 20:43:26 +03:00
|
|
|
my @dependencies = Bugzilla::Bug::CountOpenDependencies(@idlist);
|
2005-01-21 02:22:10 +03:00
|
|
|
if (scalar @dependencies > 0) {
|
|
|
|
ThrowUserError("still_unresolved_bugs",
|
2004-03-18 08:55:41 +03:00
|
|
|
{ dependencies => \@dependencies,
|
|
|
|
dependency_count => scalar @dependencies });
|
2005-01-21 02:22:10 +03:00
|
|
|
}
|
2004-03-18 08:55:41 +03:00
|
|
|
}
|
2005-02-28 21:55:07 +03:00
|
|
|
|
2006-03-28 02:25:47 +04:00
|
|
|
if ($cgi->param('knob') eq 'resolve') {
|
|
|
|
# RESOLVED bugs should have no time remaining;
|
|
|
|
# more time can be added for the VERIFY step, if needed.
|
|
|
|
_remove_remaining_time();
|
|
|
|
}
|
2007-03-10 15:20:01 +03:00
|
|
|
else {
|
|
|
|
# You cannot use change_resolution if there is at least
|
|
|
|
# one open bug.
|
|
|
|
my $open_states = join(',', map {$dbh->quote($_)} BUG_STATE_OPEN);
|
|
|
|
my $idlist = join(',', @idlist);
|
|
|
|
my $is_open =
|
|
|
|
$dbh->selectrow_array("SELECT 1 FROM bugs WHERE bug_id IN ($idlist)
|
|
|
|
AND bug_status IN ($open_states)");
|
|
|
|
|
|
|
|
ThrowUserError('resolution_not_allowed') if $is_open;
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
1999-12-16 19:37:57 +03:00
|
|
|
/^reopen$/ && CheckonComment( "reopen" ) && do {
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
1999-12-16 19:37:57 +03:00
|
|
|
/^verify$/ && CheckonComment( "verify" ) && do {
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
1999-12-16 19:37:57 +03:00
|
|
|
/^close$/ && CheckonComment( "close" ) && do {
|
2005-02-28 21:55:07 +03:00
|
|
|
# CLOSED bugs should have no time remaining.
|
|
|
|
_remove_remaining_time();
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
1999-12-16 19:37:57 +03:00
|
|
|
/^duplicate$/ && CheckonComment( "duplicate" ) && do {
|
2005-08-31 04:43:21 +04:00
|
|
|
# You cannot mark bugs as duplicates when changing
|
|
|
|
# several bugs at once.
|
|
|
|
unless (defined $cgi->param('id')) {
|
|
|
|
ThrowUserError('dupe_not_allowed');
|
|
|
|
}
|
|
|
|
|
2004-12-21 12:04:01 +03:00
|
|
|
# Make sure we can change the original bug (issue A on bug 96085)
|
2006-02-28 15:52:32 +03:00
|
|
|
defined($cgi->param('dup_id'))
|
|
|
|
|| ThrowCodeError('undefined_field', { field => 'dup_id' });
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
$duplicate = $cgi->param('dup_id');
|
|
|
|
ValidateBugID($duplicate, 'dup_id');
|
|
|
|
$cgi->param('dup_id', $duplicate);
|
2004-12-21 12:04:01 +03:00
|
|
|
|
2005-08-31 04:43:21 +04:00
|
|
|
# Make sure a loop isn't created when marking this bug
|
|
|
|
# as duplicate.
|
|
|
|
my %dupes;
|
2006-03-28 02:25:47 +04:00
|
|
|
my $dupe_of = $duplicate;
|
2005-08-31 04:43:21 +04:00
|
|
|
my $sth = $dbh->prepare('SELECT dupe_of FROM duplicates
|
|
|
|
WHERE dupe = ?');
|
|
|
|
|
|
|
|
while ($dupe_of) {
|
|
|
|
if ($dupe_of == $cgi->param('id')) {
|
|
|
|
ThrowUserError('dupe_loop_detected', { bug_id => $cgi->param('id'),
|
|
|
|
dupe_of => $duplicate });
|
|
|
|
}
|
|
|
|
# If $dupes{$dupe_of} is already set to 1, then a loop
|
|
|
|
# already exists which does not involve this bug.
|
|
|
|
# As the user is not responsible for this loop, do not
|
|
|
|
# prevent him from marking this bug as a duplicate.
|
|
|
|
last if exists $dupes{"$dupe_of"};
|
|
|
|
$dupes{"$dupe_of"} = 1;
|
|
|
|
$sth->execute($dupe_of);
|
|
|
|
$dupe_of = $sth->fetchrow_array;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Also, let's see if the reporter has authorization to see
|
|
|
|
# the bug to which we are duping. If not we need to prompt.
|
|
|
|
DuplicateUserConfirm();
|
|
|
|
|
2005-02-28 21:55:07 +03:00
|
|
|
# DUPLICATE bugs should have no time remaining.
|
|
|
|
_remove_remaining_time();
|
1998-09-16 01:49:26 +04:00
|
|
|
last SWITCH;
|
|
|
|
};
|
2003-09-14 10:05:23 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
ThrowCodeError("unknown_action", { action => $cgi->param('knob') });
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2000-01-07 00:16:15 +03:00
|
|
|
my @keywordlist;
|
|
|
|
my %keywordseen;
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('keywords')) {
|
|
|
|
foreach my $keyword (split(/[\s,]+/, $cgi->param('keywords'))) {
|
2000-01-19 22:32:05 +03:00
|
|
|
if ($keyword eq '') {
|
|
|
|
next;
|
|
|
|
}
|
2006-03-09 03:09:00 +03:00
|
|
|
my $keyword_obj = new Bugzilla::Keyword({name => $keyword});
|
|
|
|
if (!$keyword_obj) {
|
2003-04-02 16:35:07 +04:00
|
|
|
ThrowUserError("unknown_keyword",
|
|
|
|
{ keyword => $keyword });
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
2006-03-09 03:09:00 +03:00
|
|
|
if (!$keywordseen{$keyword_obj->id}) {
|
|
|
|
push(@keywordlist, $keyword_obj->id);
|
|
|
|
$keywordseen{$keyword_obj->id} = 1;
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
my $keywordaction = $cgi->param('keywordaction') || "makeexact";
|
2004-10-25 11:19:05 +04:00
|
|
|
if (!grep($keywordaction eq $_, qw(add delete makeexact))) {
|
|
|
|
$keywordaction = "makeexact";
|
|
|
|
}
|
2000-01-13 19:19:19 +03:00
|
|
|
|
2002-01-06 17:36:00 +03:00
|
|
|
if ($::comma eq ""
|
2002-10-12 21:00:33 +04:00
|
|
|
&& (! @groupAdd) && (! @groupDel)
|
2006-03-09 03:09:00 +03:00
|
|
|
&& (!Bugzilla::Keyword::keyword_count()
|
|
|
|
|| (0 == @keywordlist && $keywordaction ne "makeexact"))
|
2005-04-08 04:45:47 +04:00
|
|
|
&& defined $cgi->param('masscc') && ! $cgi->param('masscc')
|
2002-01-06 17:36:00 +03:00
|
|
|
) {
|
2005-04-08 04:45:47 +04:00
|
|
|
if (!defined $cgi->param('comment') || $cgi->param('comment') =~ /^\s*$/) {
|
2002-08-16 02:57:21 +04:00
|
|
|
ThrowUserError("bugs_not_changed");
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-28 21:55:07 +03:00
|
|
|
# Process data for Time Tracking fields
|
2006-09-04 20:21:49 +04:00
|
|
|
if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
|
2005-02-28 21:55:07 +03:00
|
|
|
foreach my $field ("estimated_time", "remaining_time") {
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param($field)) {
|
|
|
|
my $er_time = trim($cgi->param($field));
|
|
|
|
if ($er_time ne $cgi->param('dontchange')) {
|
2005-02-28 21:55:07 +03:00
|
|
|
DoComma();
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "$field = ?";
|
|
|
|
trick_taint($er_time);
|
|
|
|
push(@values, $er_time);
|
2005-02-28 21:55:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('deadline')) {
|
2005-02-28 21:55:07 +03:00
|
|
|
DoComma();
|
2005-04-08 04:45:47 +04:00
|
|
|
if ($cgi->param('deadline')) {
|
2005-08-15 21:43:38 +04:00
|
|
|
validate_date($cgi->param('deadline'))
|
|
|
|
|| ThrowUserError('illegal_date', {date => $cgi->param('deadline'),
|
|
|
|
format => 'YYYY-MM-DD'});
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "deadline = ?";
|
|
|
|
my $deadline = $cgi->param('deadline');
|
|
|
|
trick_taint($deadline);
|
|
|
|
push(@values, $deadline);
|
2005-02-28 21:55:07 +03:00
|
|
|
} else {
|
2006-04-07 02:41:41 +04:00
|
|
|
$::query .= "deadline = NULL";
|
2005-02-28 21:55:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
my $basequery = $::query;
|
1999-05-27 18:13:41 +04:00
|
|
|
|
2006-07-06 10:12:05 +04:00
|
|
|
local our $delta_ts;
|
1998-09-16 01:49:26 +04:00
|
|
|
sub SnapShotBug {
|
|
|
|
my ($id) = (@_);
|
2006-07-06 10:12:05 +04:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2006-04-07 02:41:41 +04:00
|
|
|
my @row = $dbh->selectrow_array(q{SELECT delta_ts, } .
|
2006-07-06 10:12:05 +04:00
|
|
|
join(',', editable_bug_fields()).q{ FROM bugs WHERE bug_id = ?},
|
2006-04-07 02:41:41 +04:00
|
|
|
undef, $id);
|
1999-05-25 23:22:31 +04:00
|
|
|
$delta_ts = shift @row;
|
1999-05-27 18:13:41 +04:00
|
|
|
|
1999-05-25 23:22:31 +04:00
|
|
|
return @row;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-27 18:13:41 +04:00
|
|
|
sub SnapShotDeps {
|
2006-11-27 20:48:56 +03:00
|
|
|
my ($bug_id, $target, $me) = (@_);
|
|
|
|
my $list = Bugzilla::Bug::EmitDependList($me, $target, $bug_id);
|
2006-04-07 02:41:41 +04:00
|
|
|
return join(',', @$list);
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
my $timestamp;
|
|
|
|
|
2006-07-06 10:12:05 +04:00
|
|
|
local our $bug_changed;
|
1999-05-27 18:13:41 +04:00
|
|
|
sub LogDependencyActivity {
|
2005-02-08 19:51:03 +03:00
|
|
|
my ($i, $oldstr, $target, $me, $timestamp) = (@_);
|
2006-07-06 10:12:05 +04:00
|
|
|
my $dbh = Bugzilla->dbh;
|
1999-05-27 18:13:41 +04:00
|
|
|
my $newstr = SnapShotDeps($i, $target, $me);
|
|
|
|
if ($oldstr ne $newstr) {
|
2001-07-20 19:18:30 +04:00
|
|
|
# Figure out what's really different...
|
2005-01-16 16:02:35 +03:00
|
|
|
my ($removed, $added) = diff_strings($oldstr, $newstr);
|
2002-10-17 08:31:56 +04:00
|
|
|
LogActivityEntry($i,$target,$removed,$added,$whoid,$timestamp);
|
2001-12-11 05:38:18 +03:00
|
|
|
# update timestamp on target bug so midairs will be triggered
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{UPDATE bugs SET delta_ts = ? WHERE bug_id = ?},
|
|
|
|
undef, $timestamp, $i);
|
2002-10-17 08:31:56 +04:00
|
|
|
$bug_changed = 1;
|
1999-05-27 18:13:41 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"strict_isolation"}) {
|
2005-11-20 02:47:26 +03:00
|
|
|
my @blocked_cc = ();
|
|
|
|
foreach my $pid (keys %cc_add) {
|
|
|
|
$usercache{$pid} ||= Bugzilla::User->new($pid);
|
|
|
|
my $cc_user = $usercache{$pid};
|
|
|
|
foreach my $product_id (@newprod_ids) {
|
|
|
|
if (!$cc_user->can_edit_product($product_id)) {
|
|
|
|
push (@blocked_cc, $cc_user->login);
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (scalar(@blocked_cc)) {
|
|
|
|
ThrowUserError("invalid_user_group",
|
|
|
|
{'users' => \@blocked_cc,
|
|
|
|
'bug_id' => (scalar(@idlist) > 1) ? undef : $idlist[0]});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if ($prod_changed && Bugzilla->params->{"strict_isolation"}) {
|
2005-11-20 02:47:26 +03:00
|
|
|
my $sth_cc = $dbh->prepare("SELECT who
|
|
|
|
FROM cc
|
|
|
|
WHERE bug_id = ?");
|
|
|
|
my $sth_bug = $dbh->prepare("SELECT assigned_to, qa_contact
|
|
|
|
FROM bugs
|
|
|
|
WHERE bug_id = ?");
|
2006-05-29 21:24:54 +04:00
|
|
|
|
2005-11-20 02:47:26 +03:00
|
|
|
foreach my $id (@idlist) {
|
|
|
|
$sth_cc->execute($id);
|
|
|
|
my @blocked_cc = ();
|
|
|
|
while (my ($pid) = $sth_cc->fetchrow_array) {
|
2006-11-14 22:02:01 +03:00
|
|
|
# Ignore deleted accounts. They will never get notification.
|
|
|
|
$usercache{$pid} ||= Bugzilla::User->new($pid) || next;
|
2005-11-20 02:47:26 +03:00
|
|
|
my $cc_user = $usercache{$pid};
|
2006-05-29 21:24:54 +04:00
|
|
|
if (!$cc_user->can_edit_product($product->id)) {
|
2005-11-20 02:47:26 +03:00
|
|
|
push (@blocked_cc, $cc_user->login);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (scalar(@blocked_cc)) {
|
|
|
|
ThrowUserError('invalid_user_group',
|
|
|
|
{'users' => \@blocked_cc,
|
|
|
|
'bug_id' => $id,
|
2006-05-29 21:24:54 +04:00
|
|
|
'product' => $product->name});
|
2005-11-20 02:47:26 +03:00
|
|
|
}
|
|
|
|
$sth_bug->execute($id);
|
|
|
|
my ($assignee, $qacontact) = $sth_bug->fetchrow_array;
|
|
|
|
if (!$assignee_checked) {
|
2006-11-14 22:02:01 +03:00
|
|
|
$usercache{$assignee} ||= Bugzilla::User->new($assignee) || next;
|
2005-11-20 02:47:26 +03:00
|
|
|
my $assign_user = $usercache{$assignee};
|
2006-05-29 21:24:54 +04:00
|
|
|
if (!$assign_user->can_edit_product($product->id)) {
|
2005-11-20 02:47:26 +03:00
|
|
|
ThrowUserError('invalid_user_group',
|
|
|
|
{'users' => $assign_user->login,
|
|
|
|
'bug_id' => $id,
|
2006-05-29 21:24:54 +04:00
|
|
|
'product' => $product->name});
|
2005-11-20 02:47:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$qacontact_checked && $qacontact) {
|
2006-11-14 22:02:01 +03:00
|
|
|
$usercache{$qacontact} ||= Bugzilla::User->new($qacontact) || next;
|
2005-11-20 02:47:26 +03:00
|
|
|
my $qa_user = $usercache{$qacontact};
|
2006-05-29 21:24:54 +04:00
|
|
|
if (!$qa_user->can_edit_product($product->id)) {
|
2005-11-20 02:47:26 +03:00
|
|
|
ThrowUserError('invalid_user_group',
|
|
|
|
{'users' => $qa_user->login,
|
|
|
|
'bug_id' => $id,
|
2006-05-29 21:24:54 +04:00
|
|
|
'product' => $product->name});
|
2005-11-20 02:47:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
# This loop iterates once for each bug to be processed (i.e. all the
|
|
|
|
# bugs selected when this script is called with multiple bugs selected
|
|
|
|
# from buglist.cgi, or just the one bug when called from
|
1999-12-03 02:21:42 +03:00
|
|
|
# show_bug.cgi).
|
|
|
|
#
|
1998-09-16 01:49:26 +04:00
|
|
|
foreach my $id (@idlist) {
|
2005-10-26 20:41:59 +04:00
|
|
|
my $query = $basequery;
|
2006-04-17 21:39:43 +04:00
|
|
|
my @bug_values = @values;
|
2007-04-11 01:30:34 +04:00
|
|
|
# XXX We really have to get rid of $::comma.
|
|
|
|
my $comma = $::comma;
|
2006-08-12 03:45:08 +04:00
|
|
|
my $old_bug_obj = new Bugzilla::Bug($id);
|
2005-10-26 20:41:59 +04:00
|
|
|
|
2007-04-11 01:30:34 +04:00
|
|
|
my $status;
|
|
|
|
my $resolution = $old_bug_obj->resolution;
|
|
|
|
# These are the only actions where we care about the resolution field.
|
|
|
|
if ($cgi->param('knob') =~ /^(?:resolve|change_resolution)$/) {
|
|
|
|
$resolution = $cgi->param('resolution');
|
|
|
|
}
|
|
|
|
($status, $resolution) =
|
|
|
|
$old_bug_obj->get_new_status_and_resolution(scalar $cgi->param('knob'), $resolution);
|
|
|
|
|
|
|
|
if ($status ne $old_bug_obj->bug_status) {
|
|
|
|
$query .= "$comma bug_status = ?";
|
|
|
|
push(@bug_values, $status);
|
|
|
|
$comma = ',';
|
|
|
|
}
|
|
|
|
if ($resolution ne $old_bug_obj->resolution) {
|
|
|
|
$query .= "$comma resolution = ?";
|
|
|
|
push(@bug_values, $resolution);
|
|
|
|
$comma = ',';
|
|
|
|
}
|
|
|
|
|
2007-04-13 18:53:25 +04:00
|
|
|
# We have to check whether the bug is moved to another product
|
|
|
|
# and/or component before reassigning. If $component is defined,
|
|
|
|
# use it; else use the product/component the bug is already in.
|
|
|
|
if ($cgi->param('set_default_assignee')) {
|
2006-05-29 21:24:54 +04:00
|
|
|
my $new_comp_id = $component ? $component->id : $old_bug_obj->{'component_id'};
|
2005-10-26 20:41:59 +04:00
|
|
|
$assignee = $dbh->selectrow_array('SELECT initialowner
|
|
|
|
FROM components
|
|
|
|
WHERE components.id = ?',
|
|
|
|
undef, $new_comp_id);
|
2007-04-11 01:30:34 +04:00
|
|
|
$query .= "$comma assigned_to = ?";
|
2006-04-17 21:39:43 +04:00
|
|
|
push(@bug_values, $assignee);
|
2007-04-11 01:30:34 +04:00
|
|
|
$comma = ',';
|
2007-04-13 18:53:25 +04:00
|
|
|
}
|
2006-09-21 01:57:58 +04:00
|
|
|
|
2007-04-13 18:53:25 +04:00
|
|
|
if (Bugzilla->params->{'useqacontact'} && $cgi->param('set_default_qa_contact')) {
|
|
|
|
my $new_comp_id = $component ? $component->id : $old_bug_obj->{'component_id'};
|
|
|
|
$qacontact = $dbh->selectrow_array('SELECT initialqacontact
|
|
|
|
FROM components
|
|
|
|
WHERE components.id = ?',
|
|
|
|
undef, $new_comp_id);
|
|
|
|
if ($qacontact) {
|
|
|
|
$query .= "$comma qa_contact = ?";
|
|
|
|
push(@bug_values, $qacontact);
|
2006-09-21 01:57:58 +04:00
|
|
|
}
|
2007-04-13 18:53:25 +04:00
|
|
|
else {
|
|
|
|
$query .= "$comma qa_contact = NULL";
|
|
|
|
}
|
|
|
|
$comma = ',';
|
2005-10-26 20:41:59 +04:00
|
|
|
}
|
|
|
|
|
1999-05-27 18:13:41 +04:00
|
|
|
my %dependencychanged;
|
2001-11-08 06:38:12 +03:00
|
|
|
$bug_changed = 0;
|
2000-02-18 00:41:39 +03:00
|
|
|
my $write = "WRITE"; # Might want to make a param to control
|
|
|
|
# whether we do LOW_PRIORITY ...
|
2006-03-31 14:27:26 +04:00
|
|
|
$dbh->bz_lock_tables("bugs $write", "bugs_activity $write", "cc $write",
|
2005-08-30 20:04:39 +04:00
|
|
|
"profiles READ", "dependencies $write", "votes $write",
|
2006-04-02 23:07:14 +04:00
|
|
|
"products READ", "components READ", "milestones READ",
|
2006-03-31 14:27:26 +04:00
|
|
|
"keywords $write", "longdescs $write", "fielddefs READ",
|
2005-02-18 00:57:27 +03:00
|
|
|
"bug_group_map $write", "flags $write", "duplicates $write",
|
2005-08-30 20:04:39 +04:00
|
|
|
"user_group_map READ", "group_group_map READ", "flagtypes READ",
|
2005-02-18 00:57:27 +03:00
|
|
|
"flaginclusions AS i READ", "flagexclusions AS e READ",
|
|
|
|
"keyworddefs READ", "groups READ", "attachments READ",
|
|
|
|
"group_control_map AS oldcontrolmap READ",
|
|
|
|
"group_control_map AS newcontrolmap READ",
|
2006-05-29 21:24:54 +04:00
|
|
|
"group_control_map READ", "email_setting READ", "classifications READ");
|
2005-01-21 02:22:10 +03:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
# It may sound crazy to set %formhash for each bug as $cgi->param()
|
2005-01-21 02:22:10 +03:00
|
|
|
# will not change, but %formhash is modified below and we prefer
|
|
|
|
# to set it again.
|
2000-02-17 08:15:23 +03:00
|
|
|
my $i = 0;
|
2005-01-21 02:22:10 +03:00
|
|
|
my @oldvalues = SnapShotBug($id);
|
|
|
|
my %oldhash;
|
|
|
|
my %formhash;
|
2006-06-16 17:37:50 +04:00
|
|
|
foreach my $col (@editable_bug_fields) {
|
2002-07-11 15:46:08 +04:00
|
|
|
# Consider NULL db entries to be equivalent to the empty string
|
2005-05-11 00:30:13 +04:00
|
|
|
$oldvalues[$i] = defined($oldvalues[$i]) ? $oldvalues[$i] : '';
|
|
|
|
# Convert the deadline taken from the DB into the YYYY-MM-DD format
|
|
|
|
# for consistency with the deadline provided by the user, if any.
|
2006-07-02 00:01:52 +04:00
|
|
|
# Else Bug::check_can_change_field() would see them as different
|
|
|
|
# in all cases.
|
2005-05-11 00:30:13 +04:00
|
|
|
if ($col eq 'deadline') {
|
|
|
|
$oldvalues[$i] = format_time($oldvalues[$i], "%Y-%m-%d");
|
|
|
|
}
|
2000-05-09 02:00:38 +04:00
|
|
|
$oldhash{$col} = $oldvalues[$i];
|
2005-04-08 04:45:47 +04:00
|
|
|
$formhash{$col} = $cgi->param($col) if defined $cgi->param($col);
|
2005-01-21 02:22:10 +03:00
|
|
|
$i++;
|
|
|
|
}
|
2007-04-13 18:53:25 +04:00
|
|
|
# The status and resolution are defined by the workflow.
|
|
|
|
$formhash{'bug_status'} = $status;
|
|
|
|
$formhash{'resolution'} = $resolution;
|
|
|
|
|
|
|
|
# We need to convert $newhash{'assigned_to'} and $newhash{'qa_contact'}
|
|
|
|
# email addresses into their corresponding IDs;
|
2006-07-04 01:26:22 +04:00
|
|
|
$formhash{'qa_contact'} = $qacontact if Bugzilla->params->{'useqacontact'};
|
2007-04-13 18:53:25 +04:00
|
|
|
$formhash{'assigned_to'} = $assignee;
|
|
|
|
|
2006-07-02 00:01:52 +04:00
|
|
|
# This hash is required by Bug::check_can_change_field().
|
2007-04-13 18:53:25 +04:00
|
|
|
my $cgi_hash = {'dontchange' => scalar $cgi->param('dontchange')};
|
2006-06-16 17:37:50 +04:00
|
|
|
foreach my $col (@editable_bug_fields) {
|
2005-01-21 02:22:10 +03:00
|
|
|
if (exists $formhash{$col}
|
2006-07-02 00:01:52 +04:00
|
|
|
&& !$old_bug_obj->check_can_change_field($col, $oldhash{$col}, $formhash{$col},
|
|
|
|
\$PrivilegesRequired, $cgi_hash))
|
2005-01-21 02:22:10 +03:00
|
|
|
{
|
|
|
|
my $vars;
|
|
|
|
if ($col eq 'component_id') {
|
|
|
|
# Display the component name
|
2006-05-29 21:24:54 +04:00
|
|
|
$vars->{'oldvalue'} = $old_bug_obj->component;
|
2005-04-08 04:45:47 +04:00
|
|
|
$vars->{'newvalue'} = $cgi->param('component');
|
2005-01-21 02:22:10 +03:00
|
|
|
$vars->{'field'} = 'component';
|
|
|
|
} elsif ($col eq 'assigned_to' || $col eq 'qa_contact') {
|
|
|
|
# Display the assignee or QA contact email address
|
2006-06-19 21:30:24 +04:00
|
|
|
$vars->{'oldvalue'} = user_id_to_login($oldhash{$col});
|
|
|
|
$vars->{'newvalue'} = user_id_to_login($formhash{$col});
|
2005-01-21 02:22:10 +03:00
|
|
|
$vars->{'field'} = $col;
|
|
|
|
} else {
|
|
|
|
$vars->{'oldvalue'} = $oldhash{$col};
|
|
|
|
$vars->{'newvalue'} = $formhash{$col};
|
|
|
|
$vars->{'field'} = $col;
|
2002-09-19 03:23:55 +04:00
|
|
|
}
|
2005-01-21 02:22:10 +03:00
|
|
|
$vars->{'privs'} = $PrivilegesRequired;
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("illegal_change", $vars);
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
}
|
2005-10-18 01:19:09 +04:00
|
|
|
|
2004-10-25 11:19:05 +04:00
|
|
|
# When editing multiple bugs, users can specify a list of keywords to delete
|
|
|
|
# from bugs. If the list matches the current set of keywords on those bugs,
|
2006-07-02 00:01:52 +04:00
|
|
|
# Bug::check_can_change_field will fail to check permissions because it thinks
|
|
|
|
# the list hasn't changed. To fix that, we have to call Bug::check_can_change_field
|
2004-10-25 11:19:05 +04:00
|
|
|
# again with old!=new if the keyword action is "delete" and old=new.
|
|
|
|
if ($keywordaction eq "delete"
|
2005-04-08 04:45:47 +04:00
|
|
|
&& defined $cgi->param('keywords')
|
2004-10-25 11:19:05 +04:00
|
|
|
&& length(@keywordlist) > 0
|
2005-04-08 04:45:47 +04:00
|
|
|
&& $cgi->param('keywords') eq $oldhash{keywords}
|
2006-07-02 00:01:52 +04:00
|
|
|
&& !$old_bug_obj->check_can_change_field("keywords", "old is not", "equal to new",
|
|
|
|
\$PrivilegesRequired))
|
2004-10-25 11:19:05 +04:00
|
|
|
{
|
|
|
|
$vars->{'oldvalue'} = $oldhash{keywords};
|
|
|
|
$vars->{'newvalue'} = "no keywords";
|
|
|
|
$vars->{'field'} = "keywords";
|
2005-01-21 02:22:10 +03:00
|
|
|
$vars->{'privs'} = $PrivilegesRequired;
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("illegal_change", $vars);
|
2004-10-25 11:19:05 +04:00
|
|
|
}
|
|
|
|
|
2006-06-18 03:12:36 +04:00
|
|
|
$oldhash{'product'} = $old_bug_obj->product;
|
2005-10-18 01:19:09 +04:00
|
|
|
if (!Bugzilla->user->can_edit_product($oldhash{'product_id'})) {
|
2003-04-02 16:35:07 +04:00
|
|
|
ThrowUserError("product_edit_denied",
|
2005-03-05 03:18:48 +03:00
|
|
|
{ product => $oldhash{'product'} });
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
|
2000-05-09 02:00:38 +04:00
|
|
|
if ($requiremilestone) {
|
2005-02-23 19:53:24 +03:00
|
|
|
# musthavemilestoneonaccept applies only if at least two
|
|
|
|
# target milestones are defined for the current product.
|
2006-04-02 23:07:14 +04:00
|
|
|
my $prod_obj = new Bugzilla::Product({'name' => $oldhash{'product'}});
|
|
|
|
my $nb_milestones = scalar(@{$prod_obj->milestones});
|
2005-02-23 19:53:24 +03:00
|
|
|
if ($nb_milestones > 1) {
|
|
|
|
my $value = $cgi->param('target_milestone');
|
|
|
|
if (!defined $value || $value eq $cgi->param('dontchange')) {
|
|
|
|
$value = $oldhash{'target_milestone'};
|
|
|
|
}
|
|
|
|
my $defaultmilestone =
|
|
|
|
$dbh->selectrow_array("SELECT defaultmilestone
|
|
|
|
FROM products WHERE id = ?",
|
|
|
|
undef, $oldhash{'product_id'});
|
|
|
|
# if musthavemilestoneonaccept == 1, then the target
|
|
|
|
# milestone must be different from the default one.
|
|
|
|
if ($value eq $defaultmilestone) {
|
2005-03-05 03:18:48 +03:00
|
|
|
ThrowUserError("milestone_required", { bug_id => $id });
|
2005-02-23 19:53:24 +03:00
|
|
|
}
|
2000-05-09 02:00:38 +04:00
|
|
|
}
|
|
|
|
}
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('delta_ts') && $cgi->param('delta_ts') ne $delta_ts)
|
|
|
|
{
|
2005-08-13 16:35:12 +04:00
|
|
|
($vars->{'operations'}) =
|
|
|
|
Bugzilla::Bug::GetBugActivity($id, $cgi->param('delta_ts'));
|
2002-04-13 01:02:00 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
$vars->{'start_at'} = $cgi->param('longdesclength');
|
2005-04-09 04:37:52 +04:00
|
|
|
|
|
|
|
# Always sort midair collision comments oldest to newest,
|
|
|
|
# regardless of the user's personal preference.
|
|
|
|
$vars->{'comments'} = Bugzilla::Bug::GetComments($id, "oldest_to_newest");
|
2002-05-29 11:21:44 +04:00
|
|
|
|
2005-04-08 04:45:47 +04:00
|
|
|
$cgi->param('delta_ts', $delta_ts);
|
2002-04-13 01:02:00 +04:00
|
|
|
|
|
|
|
$vars->{'bug_id'} = $id;
|
|
|
|
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables(UNLOCK_ABORT);
|
2002-04-13 01:02:00 +04:00
|
|
|
|
|
|
|
# Warn the user about the mid-air collision and ask them what to do.
|
2002-04-24 11:24:50 +04:00
|
|
|
$template->process("bug/process/midair.html.tmpl", $vars)
|
2002-04-13 01:02:00 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
1999-05-25 23:22:31 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-07-07 18:17:18 +04:00
|
|
|
# Gather the dependency list, and make sure there are no circular refs
|
2005-08-13 16:35:12 +04:00
|
|
|
my %deps = Bugzilla::Bug::ValidateDependencies(scalar($cgi->param('dependson')),
|
|
|
|
scalar($cgi->param('blocked')),
|
2005-07-07 18:17:18 +04:00
|
|
|
$id);
|
1999-05-25 23:22:31 +04:00
|
|
|
|
2004-07-29 06:59:11 +04:00
|
|
|
#
|
|
|
|
# Start updating the relevant database entries
|
|
|
|
#
|
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
$timestamp = $dbh->selectrow_array(q{SELECT NOW()});
|
2002-10-13 08:26:24 +04:00
|
|
|
|
2004-07-29 06:59:11 +04:00
|
|
|
my $work_time;
|
2006-09-04 20:21:49 +04:00
|
|
|
if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
|
2005-04-08 04:45:47 +04:00
|
|
|
$work_time = $cgi->param('work_time');
|
2004-07-29 06:59:11 +04:00
|
|
|
if ($work_time) {
|
2007-03-09 08:17:55 +03:00
|
|
|
# add_comment (called below) can in theory raise an error,
|
2004-07-29 06:59:11 +04:00
|
|
|
# but because we've already validated work_time here it's
|
|
|
|
# safe to log the entry before adding the comment.
|
2005-04-08 04:45:47 +04:00
|
|
|
LogActivityEntry($id, "work_time", "", $work_time,
|
2004-07-29 06:59:11 +04:00
|
|
|
$whoid, $timestamp);
|
2002-10-13 08:26:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-20 21:24:56 +03:00
|
|
|
if ($cgi->param('comment') || $work_time || $duplicate) {
|
|
|
|
my $type = $duplicate ? CMT_DUPE_OF : CMT_NORMAL;
|
|
|
|
|
2007-03-09 08:17:55 +03:00
|
|
|
$old_bug_obj->add_comment(scalar($cgi->param('comment')),
|
|
|
|
{ isprivate => scalar($cgi->param('commentprivacy')),
|
|
|
|
work_time => $work_time, type => $type,
|
|
|
|
extra_data => $duplicate});
|
|
|
|
# XXX When update() is used for other things than comments,
|
|
|
|
# this should probably be moved.
|
|
|
|
$old_bug_obj->update($timestamp);
|
2004-07-29 06:59:11 +04:00
|
|
|
$bug_changed = 1;
|
|
|
|
}
|
|
|
|
|
2006-03-09 03:09:00 +03:00
|
|
|
if (Bugzilla::Keyword::keyword_count()
|
|
|
|
&& defined $cgi->param('keywords'))
|
|
|
|
{
|
2000-01-07 00:16:15 +03:00
|
|
|
# There are three kinds of "keywordsaction": makeexact, add, delete.
|
|
|
|
# For makeexact, we delete everything, and then add our things.
|
|
|
|
# For add, we delete things we're adding (to make sure we don't
|
|
|
|
# end up having them twice), and then we add them.
|
|
|
|
# For delete, we just delete things on the list.
|
2000-01-17 14:38:41 +03:00
|
|
|
my $changed = 0;
|
2000-01-07 00:16:15 +03:00
|
|
|
if ($keywordaction eq "makeexact") {
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{DELETE FROM keywords WHERE bug_id = ?},
|
|
|
|
undef, $id);
|
2000-01-17 14:38:41 +03:00
|
|
|
$changed = 1;
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
2006-04-07 02:41:41 +04:00
|
|
|
my $sth_delete = $dbh->prepare(q{DELETE FROM keywords
|
|
|
|
WHERE bug_id = ?
|
|
|
|
AND keywordid = ?});
|
|
|
|
my $sth_insert =
|
|
|
|
$dbh->prepare(q{INSERT INTO keywords (bug_id, keywordid)
|
|
|
|
VALUES (?, ?)});
|
2000-01-07 00:16:15 +03:00
|
|
|
foreach my $keyword (@keywordlist) {
|
|
|
|
if ($keywordaction ne "makeexact") {
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_delete->execute($id, $keyword);
|
2000-01-17 14:38:41 +03:00
|
|
|
$changed = 1;
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
|
|
|
if ($keywordaction ne "delete") {
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_insert->execute($id, $keyword);
|
2000-01-17 14:38:41 +03:00
|
|
|
$changed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($changed) {
|
2006-04-07 02:41:41 +04:00
|
|
|
my $list = $dbh->selectcol_arrayref(
|
|
|
|
q{SELECT keyworddefs.name
|
|
|
|
FROM keyworddefs
|
|
|
|
INNER JOIN keywords
|
|
|
|
ON keyworddefs.id = keywords.keywordid
|
|
|
|
WHERE keywords.bug_id = ?
|
|
|
|
ORDER BY keyworddefs.name},
|
|
|
|
undef, $id);
|
2005-06-21 00:22:36 +04:00
|
|
|
$dbh->do("UPDATE bugs SET keywords = ? WHERE bug_id = ?",
|
2006-04-07 02:41:41 +04:00
|
|
|
undef, join(', ', @$list), $id);
|
2000-01-07 00:16:15 +03:00
|
|
|
}
|
|
|
|
}
|
2006-04-07 02:41:41 +04:00
|
|
|
$query .= " WHERE bug_id = ?";
|
2006-04-17 21:39:43 +04:00
|
|
|
push(@bug_values, $id);
|
2007-04-11 01:30:34 +04:00
|
|
|
|
|
|
|
if ($comma ne '') {
|
2006-04-17 21:39:43 +04:00
|
|
|
$dbh->do($query, undef, @bug_values);
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2002-11-24 22:56:34 +03:00
|
|
|
|
2006-03-28 02:25:47 +04:00
|
|
|
# Check for duplicates if the bug is [re]open or its resolution is changed.
|
|
|
|
if ($resolution ne 'DUPLICATE') {
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{DELETE FROM duplicates WHERE dupe = ?}, undef, $id);
|
2002-10-31 17:45:19 +03:00
|
|
|
}
|
2006-03-28 02:25:47 +04:00
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
my %groupsrequired = ();
|
|
|
|
my %groupsforbidden = ();
|
2006-04-07 02:41:41 +04:00
|
|
|
my $group_controls =
|
|
|
|
$dbh->selectall_arrayref(q{SELECT id, membercontrol
|
|
|
|
FROM groups
|
|
|
|
LEFT JOIN group_control_map
|
|
|
|
ON id = group_id
|
|
|
|
AND product_id = ?
|
|
|
|
WHERE isactive != 0},
|
2006-06-18 03:12:36 +04:00
|
|
|
undef, $oldhash{'product_id'});
|
2006-04-07 02:41:41 +04:00
|
|
|
foreach my $group_control (@$group_controls) {
|
|
|
|
my ($group, $control) = @$group_control;
|
2002-11-24 22:56:34 +03:00
|
|
|
$control ||= 0;
|
2006-07-04 01:20:41 +04:00
|
|
|
unless ($control > CONTROLMAPNA) {
|
2002-11-24 22:56:34 +03:00
|
|
|
$groupsforbidden{$group} = 1;
|
|
|
|
}
|
2006-07-04 01:20:41 +04:00
|
|
|
if ($control == CONTROLMAPMANDATORY) {
|
2002-11-24 22:56:34 +03:00
|
|
|
$groupsrequired{$group} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-22 21:15:13 +04:00
|
|
|
my @groupAddNames = ();
|
2002-11-24 22:56:34 +03:00
|
|
|
my @groupAddNamesAll = ();
|
2006-04-07 02:41:41 +04:00
|
|
|
my $sth = $dbh->prepare(q{INSERT INTO bug_group_map (bug_id, group_id)
|
|
|
|
VALUES (?, ?)});
|
2002-11-24 22:56:34 +03:00
|
|
|
foreach my $grouptoadd (@groupAdd, keys %groupsrequired) {
|
|
|
|
next if $groupsforbidden{$grouptoadd};
|
2006-05-07 23:56:05 +04:00
|
|
|
my $group_obj = new Bugzilla::Group($grouptoadd);
|
|
|
|
push(@groupAddNamesAll, $group_obj->name);
|
2002-09-22 21:15:13 +04:00
|
|
|
if (!BugInGroupId($id, $grouptoadd)) {
|
2006-05-07 23:56:05 +04:00
|
|
|
push(@groupAddNames, $group_obj->name);
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth->execute($id, $grouptoadd);
|
2002-09-22 21:15:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
my @groupDelNames = ();
|
2002-11-24 22:56:34 +03:00
|
|
|
my @groupDelNamesAll = ();
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth = $dbh->prepare(q{DELETE FROM bug_group_map
|
|
|
|
WHERE bug_id = ? AND group_id = ?});
|
2002-11-24 22:56:34 +03:00
|
|
|
foreach my $grouptodel (@groupDel, keys %groupsforbidden) {
|
2006-05-07 23:56:05 +04:00
|
|
|
my $group_obj = new Bugzilla::Group($grouptodel);
|
|
|
|
push(@groupDelNamesAll, $group_obj->name);
|
2002-11-24 22:56:34 +03:00
|
|
|
next if $groupsrequired{$grouptodel};
|
2002-09-22 21:15:13 +04:00
|
|
|
if (BugInGroupId($id, $grouptodel)) {
|
2006-05-07 23:56:05 +04:00
|
|
|
push(@groupDelNames, $group_obj->name);
|
2002-09-22 21:15:13 +04:00
|
|
|
}
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth->execute($id, $grouptodel);
|
2002-09-22 21:15:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
my $groupDelNames = join(',', @groupDelNames);
|
|
|
|
my $groupAddNames = join(',', @groupAddNames);
|
|
|
|
|
2003-10-07 09:59:30 +04:00
|
|
|
if ($groupDelNames ne $groupAddNames) {
|
|
|
|
LogActivityEntry($id, "bug_group", $groupDelNames, $groupAddNames,
|
|
|
|
$whoid, $timestamp);
|
|
|
|
$bug_changed = 1;
|
|
|
|
}
|
2003-02-10 01:04:25 +03:00
|
|
|
|
|
|
|
my @ccRemoved = ();
|
2005-04-08 04:45:47 +04:00
|
|
|
if (defined $cgi->param('newcc')
|
|
|
|
|| defined $cgi->param('addselfcc')
|
|
|
|
|| defined $cgi->param('removecc')
|
|
|
|
|| defined $cgi->param('masscc')) {
|
2001-07-20 19:18:30 +04:00
|
|
|
# Get the current CC list for this bug
|
|
|
|
my %oncc;
|
2006-04-07 02:41:41 +04:00
|
|
|
my $cc_list = $dbh->selectcol_arrayref(
|
|
|
|
q{SELECT who FROM cc WHERE bug_id = ?}, undef, $id);
|
|
|
|
foreach my $who (@$cc_list) {
|
|
|
|
$oncc{$who} = 1;
|
2001-07-20 19:18:30 +04:00
|
|
|
}
|
|
|
|
|
2005-11-20 02:47:26 +03:00
|
|
|
my (@added, @removed) = ();
|
2006-04-07 02:41:41 +04:00
|
|
|
|
|
|
|
my $sth_insert = $dbh->prepare(q{INSERT INTO cc (bug_id, who)
|
|
|
|
VALUES (?, ?)});
|
2001-08-18 00:18:33 +04:00
|
|
|
foreach my $pid (keys %cc_add) {
|
|
|
|
# If this person isn't already on the cc list, add them
|
|
|
|
if (! $oncc{$pid}) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_insert->execute($id, $pid);
|
2001-08-18 00:18:33 +04:00
|
|
|
push (@added, $cc_add{$pid});
|
|
|
|
$oncc{$pid} = 1;
|
2001-07-20 19:18:30 +04:00
|
|
|
}
|
|
|
|
}
|
2006-04-07 02:41:41 +04:00
|
|
|
my $sth_delete = $dbh->prepare(q{DELETE FROM cc
|
|
|
|
WHERE bug_id = ? AND who = ?});
|
2001-08-18 00:18:33 +04:00
|
|
|
foreach my $pid (keys %cc_remove) {
|
|
|
|
# If the person is on the cc list, remove them
|
|
|
|
if ($oncc{$pid}) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_delete->execute($id, $pid);
|
2001-08-18 00:18:33 +04:00
|
|
|
push (@removed, $cc_remove{$pid});
|
|
|
|
$oncc{$pid} = 0;
|
2001-07-20 19:18:30 +04:00
|
|
|
}
|
|
|
|
}
|
2001-08-18 00:18:33 +04:00
|
|
|
|
2001-07-20 19:18:30 +04:00
|
|
|
# If any changes were found, record it in the activity log
|
|
|
|
if (scalar(@removed) || scalar(@added)) {
|
2001-08-27 02:58:34 +04:00
|
|
|
my $removed = join(", ", @removed);
|
|
|
|
my $added = join(", ", @added);
|
2002-10-17 08:31:56 +04:00
|
|
|
LogActivityEntry($id,"cc",$removed,$added,$whoid,$timestamp);
|
|
|
|
$bug_changed = 1;
|
2001-07-20 19:18:30 +04:00
|
|
|
}
|
2003-02-10 01:04:25 +03:00
|
|
|
@ccRemoved = @removed;
|
2000-03-29 01:31:24 +04:00
|
|
|
}
|
1999-05-27 18:13:41 +04:00
|
|
|
|
2003-02-10 09:26:39 +03:00
|
|
|
# We need to send mail for dependson/blocked bugs if the dependencies
|
2002-11-08 11:04:58 +03:00
|
|
|
# change or the status or resolution change. This var keeps track of that.
|
|
|
|
my $check_dep_bugs = 0;
|
|
|
|
|
2005-03-18 11:29:47 +03:00
|
|
|
foreach my $pair ("blocked/dependson", "dependson/blocked") {
|
|
|
|
my ($me, $target) = split("/", $pair);
|
|
|
|
|
|
|
|
my @oldlist = @{$dbh->selectcol_arrayref("SELECT $target FROM dependencies
|
|
|
|
WHERE $me = ? ORDER BY $target",
|
|
|
|
undef, $id)};
|
2006-08-18 21:32:11 +04:00
|
|
|
|
|
|
|
# Only bugs depending on the current one should get notification.
|
|
|
|
# Bugs blocking the current one never get notification, unless they
|
|
|
|
# are added or removed from the dependency list. This case is treated
|
|
|
|
# below.
|
|
|
|
@dependencychanged{@oldlist} = 1 if ($me eq 'dependson');
|
2005-03-18 11:29:47 +03:00
|
|
|
|
2005-07-07 18:17:18 +04:00
|
|
|
if (defined $cgi->param($target)) {
|
1999-05-27 18:13:41 +04:00
|
|
|
my %snapshot;
|
|
|
|
my @newlist = sort {$a <=> $b} @{$deps{$target}};
|
|
|
|
|
|
|
|
while (0 < @oldlist || 0 < @newlist) {
|
|
|
|
if (@oldlist == 0 || (@newlist > 0 &&
|
|
|
|
$oldlist[0] > $newlist[0])) {
|
|
|
|
$snapshot{$newlist[0]} = SnapShotDeps($newlist[0], $me,
|
|
|
|
$target);
|
|
|
|
shift @newlist;
|
|
|
|
} elsif (@newlist == 0 || (@oldlist > 0 &&
|
|
|
|
$newlist[0] > $oldlist[0])) {
|
|
|
|
$snapshot{$oldlist[0]} = SnapShotDeps($oldlist[0], $me,
|
|
|
|
$target);
|
|
|
|
shift @oldlist;
|
|
|
|
} else {
|
|
|
|
if ($oldlist[0] != $newlist[0]) {
|
2006-06-03 23:48:57 +04:00
|
|
|
ThrowCodeError('list_comparison_error');
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
|
|
|
shift @oldlist;
|
|
|
|
shift @newlist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my @keys = keys(%snapshot);
|
|
|
|
if (@keys) {
|
|
|
|
my $oldsnap = SnapShotDeps($id, $target, $me);
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(qq{DELETE FROM dependencies WHERE $me = ?},
|
|
|
|
undef, $id);
|
|
|
|
my $sth =
|
|
|
|
$dbh->prepare(qq{INSERT INTO dependencies ($me, $target)
|
|
|
|
VALUES (?, ?)});
|
1999-05-27 18:13:41 +04:00
|
|
|
foreach my $i (@{$deps{$target}}) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth->execute($id, $i);
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
|
|
|
foreach my $k (@keys) {
|
2005-02-08 19:51:03 +03:00
|
|
|
LogDependencyActivity($k, $snapshot{$k}, $me, $target, $timestamp);
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
2005-02-08 19:51:03 +03:00
|
|
|
LogDependencyActivity($id, $oldsnap, $target, $me, $timestamp);
|
2002-11-08 11:04:58 +03:00
|
|
|
$check_dep_bugs = 1;
|
2006-08-18 21:32:11 +04:00
|
|
|
# All bugs added or removed from the dependency list
|
|
|
|
# must be notified.
|
|
|
|
@dependencychanged{@keys} = 1;
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-11 05:18:24 +04:00
|
|
|
# When a bug changes products and the old or new product is associated
|
|
|
|
# with a bug group, it may be necessary to remove the bug from the old
|
|
|
|
# group or add it to the new one. There are a very specific series of
|
|
|
|
# conditions under which these activities take place, more information
|
|
|
|
# about which can be found in comments within the conditionals below.
|
2002-11-24 22:56:34 +03:00
|
|
|
# Check if the user has changed the product to which the bug belongs;
|
2005-04-10 03:18:18 +04:00
|
|
|
if ($cgi->param('product') ne $cgi->param('dontchange')
|
2006-06-18 03:12:36 +04:00
|
|
|
&& $cgi->param('product') ne $oldhash{'product'})
|
|
|
|
{
|
2002-11-24 22:56:34 +03:00
|
|
|
# Depending on the "addtonewgroup" variable, groups with
|
|
|
|
# defaults will change.
|
|
|
|
#
|
|
|
|
# For each group, determine
|
|
|
|
# - The group id and if it is active
|
|
|
|
# - The control map value for the old product and this group
|
|
|
|
# - The control map value for the new product and this group
|
|
|
|
# - Is the user in this group?
|
|
|
|
# - Is the bug in this group?
|
2006-04-07 02:41:41 +04:00
|
|
|
my $groups = $dbh->selectall_arrayref(
|
|
|
|
qq{SELECT DISTINCT groups.id, isactive,
|
|
|
|
oldcontrolmap.membercontrol,
|
|
|
|
newcontrolmap.membercontrol,
|
|
|
|
CASE WHEN groups.id IN ($grouplist) THEN 1 ELSE 0 END,
|
|
|
|
CASE WHEN bug_group_map.group_id IS NOT NULL
|
|
|
|
THEN 1 ELSE 0 END
|
|
|
|
FROM groups
|
|
|
|
LEFT JOIN group_control_map AS oldcontrolmap
|
|
|
|
ON oldcontrolmap.group_id = groups.id
|
|
|
|
AND oldcontrolmap.product_id = ?
|
|
|
|
LEFT JOIN group_control_map AS newcontrolmap
|
|
|
|
ON newcontrolmap.group_id = groups.id
|
|
|
|
AND newcontrolmap.product_id = ?
|
|
|
|
LEFT JOIN bug_group_map
|
|
|
|
ON bug_group_map.group_id = groups.id
|
|
|
|
AND bug_group_map.bug_id = ?},
|
2006-06-18 03:12:36 +04:00
|
|
|
undef, $oldhash{'product_id'}, $product->id, $id);
|
2002-11-24 22:56:34 +03:00
|
|
|
my @groupstoremove = ();
|
|
|
|
my @groupstoadd = ();
|
|
|
|
my @defaultstoremove = ();
|
|
|
|
my @defaultstoadd = ();
|
|
|
|
my @allgroups = ();
|
|
|
|
my $buginanydefault = 0;
|
|
|
|
my $buginanychangingdefault = 0;
|
2006-04-07 02:41:41 +04:00
|
|
|
foreach my $group (@$groups) {
|
|
|
|
my ($groupid, $isactive, $oldcontrol, $newcontrol,
|
|
|
|
$useringroup, $bugingroup) = @$group;
|
2002-11-24 22:56:34 +03:00
|
|
|
# An undefined newcontrol is none.
|
|
|
|
$newcontrol = CONTROLMAPNA unless $newcontrol;
|
|
|
|
$oldcontrol = CONTROLMAPNA unless $oldcontrol;
|
|
|
|
push(@allgroups, $groupid);
|
|
|
|
if (($bugingroup) && ($isactive)
|
|
|
|
&& ($oldcontrol == CONTROLMAPDEFAULT)) {
|
|
|
|
# Bug was in a default group.
|
|
|
|
$buginanydefault = 1;
|
2003-04-25 01:50:33 +04:00
|
|
|
if (($newcontrol != CONTROLMAPDEFAULT)
|
|
|
|
&& ($newcontrol != CONTROLMAPMANDATORY)) {
|
2002-11-24 22:56:34 +03:00
|
|
|
# Bug was in a default group that no longer is.
|
|
|
|
$buginanychangingdefault = 1;
|
|
|
|
push (@defaultstoremove, $groupid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (($isactive) && (!$bugingroup)
|
|
|
|
&& ($newcontrol == CONTROLMAPDEFAULT)
|
|
|
|
&& ($useringroup)) {
|
|
|
|
push (@defaultstoadd, $groupid);
|
|
|
|
}
|
|
|
|
if (($bugingroup) && ($isactive) && ($newcontrol == CONTROLMAPNA)) {
|
|
|
|
# Group is no longer permitted.
|
|
|
|
push(@groupstoremove, $groupid);
|
|
|
|
}
|
|
|
|
if ((!$bugingroup) && ($isactive)
|
|
|
|
&& ($newcontrol == CONTROLMAPMANDATORY)) {
|
|
|
|
# Group is now required.
|
|
|
|
push(@groupstoadd, $groupid);
|
2002-09-22 21:15:13 +04:00
|
|
|
}
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
2002-11-24 22:56:34 +03:00
|
|
|
# If addtonewgroups = "yes", old default groups will be removed
|
|
|
|
# and new default groups will be added.
|
|
|
|
# If addtonewgroups = "yesifinold", old default groups will be removed
|
|
|
|
# and new default groups will be added only if the bug was in ANY
|
|
|
|
# of the old default groups.
|
|
|
|
# If addtonewgroups = "no", old default groups will be removed and not
|
|
|
|
# replaced.
|
|
|
|
push(@groupstoremove, @defaultstoremove);
|
|
|
|
if (AnyDefaultGroups()
|
2005-04-08 04:45:47 +04:00
|
|
|
&& (($cgi->param('addtonewgroup') eq 'yes')
|
|
|
|
|| (($cgi->param('addtonewgroup') eq 'yesifinold')
|
2002-11-24 22:56:34 +03:00
|
|
|
&& ($buginanydefault)))) {
|
|
|
|
push(@groupstoadd, @defaultstoadd);
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
# Now actually update the bug_group_map.
|
|
|
|
my @DefGroupsAdded = ();
|
|
|
|
my @DefGroupsRemoved = ();
|
2006-04-07 02:41:41 +04:00
|
|
|
my $sth_insert =
|
|
|
|
$dbh->prepare(q{INSERT INTO bug_group_map (bug_id, group_id)
|
|
|
|
VALUES (?, ?)});
|
|
|
|
my $sth_delete = $dbh->prepare(q{DELETE FROM bug_group_map
|
|
|
|
WHERE bug_id = ?
|
|
|
|
AND group_id = ?});
|
2002-11-24 22:56:34 +03:00
|
|
|
foreach my $groupid (@allgroups) {
|
|
|
|
my $thisadd = grep( ($_ == $groupid), @groupstoadd);
|
|
|
|
my $thisdel = grep( ($_ == $groupid), @groupstoremove);
|
|
|
|
if ($thisadd) {
|
2006-05-07 23:56:05 +04:00
|
|
|
my $group_obj = new Bugzilla::Group($groupid);
|
|
|
|
push(@DefGroupsAdded, $group_obj->name);
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_insert->execute($id, $groupid);
|
2002-11-24 22:56:34 +03:00
|
|
|
} elsif ($thisdel) {
|
2006-05-07 23:56:05 +04:00
|
|
|
my $group_obj = new Bugzilla::Group($groupid);
|
|
|
|
push(@DefGroupsRemoved, $group_obj->name);
|
2006-04-07 02:41:41 +04:00
|
|
|
$sth_delete->execute($id, $groupid);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((@DefGroupsAdded) || (@DefGroupsRemoved)) {
|
|
|
|
LogActivityEntry($id, "bug_group",
|
|
|
|
join(', ', @DefGroupsRemoved),
|
|
|
|
join(', ', @DefGroupsAdded),
|
|
|
|
$whoid, $timestamp);
|
|
|
|
}
|
2001-08-11 05:18:24 +04:00
|
|
|
}
|
|
|
|
|
1999-12-03 02:21:42 +03:00
|
|
|
# get a snapshot of the newly set values out of the database,
|
|
|
|
# and then generate any necessary bug activity entries by seeing
|
|
|
|
# what has changed since before we wrote out the new values.
|
|
|
|
#
|
2006-08-12 03:45:08 +04:00
|
|
|
my $new_bug_obj = new Bugzilla::Bug($id);
|
1998-09-16 01:49:26 +04:00
|
|
|
my @newvalues = SnapShotBug($id);
|
2002-09-28 22:42:54 +04:00
|
|
|
my %newhash;
|
|
|
|
$i = 0;
|
2006-06-16 17:37:50 +04:00
|
|
|
foreach my $col (@editable_bug_fields) {
|
2002-09-28 22:42:54 +04:00
|
|
|
# Consider NULL db entries to be equivalent to the empty string
|
2005-06-21 00:22:36 +04:00
|
|
|
$newvalues[$i] = defined($newvalues[$i]) ? $newvalues[$i] : '';
|
2005-05-11 00:30:13 +04:00
|
|
|
# Convert the deadline to the YYYY-MM-DD format.
|
|
|
|
if ($col eq 'deadline') {
|
|
|
|
$newvalues[$i] = format_time($newvalues[$i], "%Y-%m-%d");
|
|
|
|
}
|
2002-09-28 22:42:54 +04:00
|
|
|
$newhash{$col} = $newvalues[$i];
|
|
|
|
$i++;
|
|
|
|
}
|
2003-02-10 09:26:39 +03:00
|
|
|
# for passing to Bugzilla::BugMail to ensure that when someone is removed
|
2001-02-14 23:41:26 +03:00
|
|
|
# from one of these fields, they get notified of that fact (if desired)
|
|
|
|
#
|
|
|
|
my $origOwner = "";
|
|
|
|
my $origQaContact = "";
|
2006-02-25 01:53:32 +03:00
|
|
|
|
|
|
|
# $msgs will store emails which have to be sent to voters, if any.
|
|
|
|
my $msgs;
|
|
|
|
|
2006-06-16 17:37:50 +04:00
|
|
|
foreach my $c (@editable_bug_fields) {
|
2000-01-07 00:16:15 +03:00
|
|
|
my $col = $c; # We modify it, don't want to modify array
|
|
|
|
# values in place.
|
1998-09-16 01:49:26 +04:00
|
|
|
my $old = shift @oldvalues;
|
|
|
|
my $new = shift @newvalues;
|
|
|
|
if ($old ne $new) {
|
2001-02-14 23:41:26 +03:00
|
|
|
|
2002-08-12 09:43:05 +04:00
|
|
|
# Products and components are now stored in the DB using ID's
|
|
|
|
# We need to translate this to English before logging it
|
|
|
|
if ($col eq 'product_id') {
|
2006-06-18 03:12:36 +04:00
|
|
|
$old = $old_bug_obj->product;
|
|
|
|
$new = $new_bug_obj->product;
|
2002-08-12 09:43:05 +04:00
|
|
|
$col = 'product';
|
|
|
|
}
|
|
|
|
if ($col eq 'component_id') {
|
2006-05-29 21:24:54 +04:00
|
|
|
$old = $old_bug_obj->component;
|
|
|
|
$new = $new_bug_obj->component;
|
2002-08-12 09:43:05 +04:00
|
|
|
$col = 'component';
|
|
|
|
}
|
|
|
|
|
2003-02-10 09:26:39 +03:00
|
|
|
# save off the old value for passing to Bugzilla::BugMail so
|
2005-06-20 23:16:34 +04:00
|
|
|
# the old assignee can be notified
|
2001-02-14 23:41:26 +03:00
|
|
|
#
|
|
|
|
if ($col eq 'assigned_to') {
|
2006-06-19 21:30:24 +04:00
|
|
|
$old = ($old) ? user_id_to_login($old) : "";
|
|
|
|
$new = ($new) ? user_id_to_login($new) : "";
|
2001-02-14 23:41:26 +03:00
|
|
|
$origOwner = $old;
|
|
|
|
}
|
|
|
|
|
|
|
|
# ditto for the old qa contact
|
|
|
|
#
|
|
|
|
if ($col eq 'qa_contact') {
|
2006-06-19 21:30:24 +04:00
|
|
|
$old = ($old) ? user_id_to_login($old) : "";
|
|
|
|
$new = ($new) ? user_id_to_login($new) : "";
|
2001-02-14 23:41:26 +03:00
|
|
|
$origQaContact = $old;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2001-02-14 23:41:26 +03:00
|
|
|
|
2001-07-20 19:18:30 +04:00
|
|
|
# If this is the keyword field, only record the changes, not everything.
|
|
|
|
if ($col eq 'keywords') {
|
2005-01-16 16:02:35 +03:00
|
|
|
($old, $new) = diff_strings($old, $new);
|
2001-07-20 19:18:30 +04:00
|
|
|
}
|
|
|
|
|
1999-10-08 03:54:52 +04:00
|
|
|
if ($col eq 'product') {
|
2006-02-25 01:53:32 +03:00
|
|
|
# If some votes have been removed, RemoveVotes() returns
|
|
|
|
# a list of messages to send to voters.
|
|
|
|
# We delay the sending of these messages till tables are unlocked.
|
|
|
|
$msgs = RemoveVotes($id, 0,
|
|
|
|
"This bug has been moved to a different product");
|
2006-09-05 16:55:32 +04:00
|
|
|
|
|
|
|
CheckIfVotedConfirmed($id, $whoid);
|
1999-10-08 03:54:52 +04:00
|
|
|
}
|
2006-02-25 01:53:32 +03:00
|
|
|
|
2002-11-08 11:04:58 +03:00
|
|
|
if ($col eq 'bug_status'
|
2006-03-07 00:42:10 +03:00
|
|
|
&& is_open_state($old) ne is_open_state($new))
|
2002-11-08 11:04:58 +03:00
|
|
|
{
|
|
|
|
$check_dep_bugs = 1;
|
|
|
|
}
|
2005-02-25 06:28:02 +03:00
|
|
|
|
2002-10-17 08:31:56 +04:00
|
|
|
LogActivityEntry($id,$col,$old,$new,$whoid,$timestamp);
|
|
|
|
$bug_changed = 1;
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
}
|
2002-09-28 22:42:54 +04:00
|
|
|
# Set and update flags.
|
2006-06-19 02:46:50 +04:00
|
|
|
Bugzilla::Flag::process($new_bug_obj, undef, $timestamp, $cgi);
|
2005-05-07 01:40:32 +04:00
|
|
|
|
2001-11-08 06:38:12 +03:00
|
|
|
if ($bug_changed) {
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{UPDATE bugs SET delta_ts = ? WHERE bug_id = ?},
|
|
|
|
undef, $timestamp, $id);
|
2001-11-08 06:38:12 +03:00
|
|
|
}
|
2005-02-18 00:57:27 +03:00
|
|
|
$dbh->bz_unlock_tables();
|
2001-02-14 23:41:26 +03:00
|
|
|
|
2006-02-25 01:53:32 +03:00
|
|
|
# Now is a good time to send email to voters.
|
|
|
|
foreach my $msg (@$msgs) {
|
2006-06-02 14:50:15 +04:00
|
|
|
MessageToMTA($msg);
|
2006-02-25 01:53:32 +03:00
|
|
|
}
|
|
|
|
|
2001-03-11 03:53:22 +03:00
|
|
|
if ($duplicate) {
|
2006-03-28 02:25:47 +04:00
|
|
|
# If the bug was already marked as a duplicate, remove
|
|
|
|
# the existing entry.
|
|
|
|
$dbh->do('DELETE FROM duplicates WHERE dupe = ?',
|
|
|
|
undef, $cgi->param('id'));
|
|
|
|
|
2001-03-11 03:53:22 +03:00
|
|
|
# Check to see if Reporter of this bug is reporter of Dupe
|
2006-04-07 02:41:41 +04:00
|
|
|
my $reporter = $dbh->selectrow_array(
|
|
|
|
q{SELECT reporter FROM bugs WHERE bug_id = ?}, undef, $id);
|
|
|
|
my $isreporter = $dbh->selectrow_array(
|
|
|
|
q{SELECT reporter FROM bugs WHERE bug_id = ? AND reporter = ?},
|
|
|
|
undef, $duplicate, $reporter);
|
|
|
|
my $isoncc = $dbh->selectrow_array(q{SELECT who FROM cc
|
|
|
|
WHERE bug_id = ? AND who = ?},
|
|
|
|
undef, $duplicate, $reporter);
|
2005-04-08 04:45:47 +04:00
|
|
|
unless ($isreporter || $isoncc
|
|
|
|
|| !$cgi->param('confirm_add_duplicate')) {
|
2002-09-06 07:59:06 +04:00
|
|
|
# The reporter is oblivious to the existence of the new bug and is permitted access
|
2001-08-26 22:51:45 +04:00
|
|
|
# ... add 'em to the cc (and record activity)
|
2006-06-19 21:30:24 +04:00
|
|
|
LogActivityEntry($duplicate,"cc","",user_id_to_login($reporter),
|
2002-10-17 08:31:56 +04:00
|
|
|
$whoid,$timestamp);
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{INSERT INTO cc (who, bug_id) VALUES (?, ?)},
|
|
|
|
undef, $reporter, $duplicate);
|
2001-03-11 03:53:22 +03:00
|
|
|
}
|
2006-09-18 22:56:38 +04:00
|
|
|
# Bug 171639 - Duplicate notifications do not need to be private.
|
2007-03-09 08:17:55 +03:00
|
|
|
my $dup = new Bugzilla::Bug($duplicate);
|
|
|
|
$dup->add_comment("", { type => CMT_HAS_DUPE,
|
|
|
|
extra_data => $new_bug_obj->bug_id });
|
|
|
|
$dup->update($timestamp);
|
2005-02-08 19:51:03 +03:00
|
|
|
|
2006-04-07 02:41:41 +04:00
|
|
|
$dbh->do(q{INSERT INTO duplicates VALUES (?, ?)}, undef,
|
|
|
|
$duplicate, $cgi->param('id'));
|
2005-06-09 01:04:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Now all changes to the DB have been made. It's time to email
|
|
|
|
# all concerned users, including the bug itself, but also the
|
|
|
|
# duplicated bug and dependent bugs, if any.
|
|
|
|
|
|
|
|
$vars->{'mailrecipients'} = { 'cc' => \@ccRemoved,
|
|
|
|
'owner' => $origOwner,
|
|
|
|
'qacontact' => $origQaContact,
|
|
|
|
'changer' => Bugzilla->user->login };
|
|
|
|
|
|
|
|
$vars->{'id'} = $id;
|
2005-08-03 04:26:54 +04:00
|
|
|
$vars->{'type'} = "bug";
|
2005-06-09 01:04:22 +04:00
|
|
|
|
|
|
|
# Let the user know the bug was changed and who did and didn't
|
|
|
|
# receive email about the change.
|
2006-10-17 10:24:18 +04:00
|
|
|
send_results($id, $vars);
|
|
|
|
|
2005-06-09 01:04:22 +04:00
|
|
|
if ($duplicate) {
|
2004-07-21 01:25:33 +04:00
|
|
|
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login };
|
2003-02-10 01:04:25 +03:00
|
|
|
|
2002-04-13 01:02:00 +04:00
|
|
|
$vars->{'id'} = $duplicate;
|
|
|
|
$vars->{'type'} = "dupe";
|
|
|
|
|
2006-10-17 10:24:18 +04:00
|
|
|
# Let the user know a duplication notation was added to the
|
|
|
|
# original bug.
|
|
|
|
send_results($duplicate, $vars);
|
2001-03-11 03:53:22 +03:00
|
|
|
}
|
|
|
|
|
2002-11-08 11:04:58 +03:00
|
|
|
if ($check_dep_bugs) {
|
|
|
|
foreach my $k (keys(%dependencychanged)) {
|
2004-07-21 01:25:33 +04:00
|
|
|
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login };
|
2002-11-08 11:04:58 +03:00
|
|
|
$vars->{'id'} = $k;
|
|
|
|
$vars->{'type'} = "dep";
|
|
|
|
|
2006-10-17 10:24:18 +04:00
|
|
|
# Let the user (if he is able to see the bug) know we checked to
|
|
|
|
# see if we should email notice of this change to users with a
|
|
|
|
# relationship to the dependent bug and who did and didn't
|
|
|
|
# receive email about it.
|
|
|
|
send_results($k, $vars);
|
2002-11-08 11:04:58 +03:00
|
|
|
}
|
1999-05-27 18:13:41 +04:00
|
|
|
}
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
|
|
|
|
2005-07-11 02:37:15 +04:00
|
|
|
# Determine if Patch Viewer is installed, for Diff link
|
|
|
|
# (NB: Duplicate code with show_bug.cgi.)
|
|
|
|
eval {
|
|
|
|
require PatchReader;
|
|
|
|
$vars->{'patchviewerinstalled'} = 1;
|
|
|
|
};
|
2002-03-23 20:58:41 +03:00
|
|
|
|
2005-07-27 23:43:05 +04:00
|
|
|
if (defined $cgi->param('id')) {
|
|
|
|
$action = Bugzilla->user->settings->{'post_bug_submit_action'}->{'value'};
|
|
|
|
} else {
|
|
|
|
# param('id') is not defined when changing multiple bugs
|
|
|
|
$action = 'nothing';
|
|
|
|
}
|
2004-06-01 16:53:27 +04:00
|
|
|
|
2006-10-17 10:24:18 +04:00
|
|
|
if (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
# Do nothing.
|
|
|
|
}
|
|
|
|
elsif ($action eq 'next_bug') {
|
2005-07-11 02:37:15 +04:00
|
|
|
my $next_bug;
|
|
|
|
my $cur = lsearch(\@bug_list, $cgi->param("id"));
|
|
|
|
if ($cur >= 0 && $cur < $#bug_list) {
|
|
|
|
$next_bug = $bug_list[$cur + 1];
|
|
|
|
}
|
|
|
|
if ($next_bug) {
|
|
|
|
if (detaint_natural($next_bug) && Bugzilla->user->can_see_bug($next_bug)) {
|
2006-08-12 03:45:08 +04:00
|
|
|
my $bug = new Bugzilla::Bug($next_bug);
|
2005-07-11 02:37:15 +04:00
|
|
|
ThrowCodeError("bug_error", { bug => $bug }) if $bug->error;
|
2004-06-01 16:53:27 +04:00
|
|
|
|
2005-07-11 02:37:15 +04:00
|
|
|
$vars->{'bugs'} = [$bug];
|
|
|
|
$vars->{'nextbug'} = $bug->bug_id;
|
2002-03-23 20:58:41 +03:00
|
|
|
|
2005-07-11 02:37:15 +04:00
|
|
|
$template->process("bug/show.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
2002-03-23 20:58:41 +03:00
|
|
|
}
|
2005-07-11 02:37:15 +04:00
|
|
|
} elsif ($action eq 'same_bug') {
|
2005-09-15 14:50:04 +04:00
|
|
|
if (Bugzilla->user->can_see_bug($cgi->param('id'))) {
|
2006-08-12 03:45:08 +04:00
|
|
|
my $bug = new Bugzilla::Bug($cgi->param('id'));
|
2005-09-15 14:50:04 +04:00
|
|
|
ThrowCodeError("bug_error", { bug => $bug }) if $bug->error;
|
2005-07-11 02:37:15 +04:00
|
|
|
|
2005-09-15 14:50:04 +04:00
|
|
|
$vars->{'bugs'} = [$bug];
|
2005-07-11 02:37:15 +04:00
|
|
|
|
2005-09-15 14:50:04 +04:00
|
|
|
$template->process("bug/show.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2005-07-11 02:37:15 +04:00
|
|
|
|
2005-09-15 14:50:04 +04:00
|
|
|
exit;
|
|
|
|
}
|
2005-07-11 02:37:15 +04:00
|
|
|
} elsif ($action ne 'nothing') {
|
|
|
|
ThrowCodeError("invalid_post_bug_submit_action");
|
1998-08-26 10:14:20 +04:00
|
|
|
}
|
2002-03-23 20:58:41 +03:00
|
|
|
|
2002-04-13 01:02:00 +04:00
|
|
|
# End the response page.
|
2006-10-17 10:24:18 +04:00
|
|
|
unless (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
|
|
|
|
$template->process("bug/navigate.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
$template->process("global/footer.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|