Commit b3630da1 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 92552: Separate reassignment from bug status change (they are now…

Bug 92552: Separate reassignment from bug status change (they are now independent) - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=gerv a=LpSolit
parent 09becc83
...@@ -1511,15 +1511,6 @@ sub get_new_status_and_resolution { ...@@ -1511,15 +1511,6 @@ sub get_new_status_and_resolution {
$status = $self->everconfirmed ? 'REOPENED' : 'UNCONFIRMED'; $status = $self->everconfirmed ? 'REOPENED' : 'UNCONFIRMED';
$resolution = ''; $resolution = '';
} }
elsif ($action =~ /^reassign(?:bycomponent)?$/) {
if (!is_open_state($self->bug_status) || $self->bug_status eq 'UNCONFIRMED') {
$status = $self->bug_status;
}
else {
$status = 'NEW';
}
$resolution = $self->resolution;
}
elsif ($action eq 'duplicate') { elsif ($action eq 'duplicate') {
# Only alter the bug status if the bug is currently open. # Only alter the bug status if the bug is currently open.
$status = is_open_state($self->bug_status) ? 'RESOLVED' : $self->bug_status; $status = is_open_state($self->bug_status) ? 'RESOLVED' : $self->bug_status;
...@@ -2153,14 +2144,6 @@ sub check_can_change_field { ...@@ -2153,14 +2144,6 @@ sub check_can_change_field {
return 1; return 1;
} }
# Ignore the assigned_to field if the bug is not being reassigned
if ($field eq 'assigned_to'
&& $data->{'knob'} ne 'reassignbycomponent'
&& $data->{'knob'} ne 'reassign')
{
return 1;
}
# If the user isn't allowed to change a field, we must tell him who can. # If the user isn't allowed to change a field, we must tell him who can.
# We store the required permission set into the $PrivilegesRequired # We store the required permission set into the $PrivilegesRequired
# variable which gets passed to the error template. # variable which gets passed to the error template.
......
...@@ -744,6 +744,8 @@ if ($cgi->param('product') ne $cgi->param('dontchange')) { ...@@ -744,6 +744,8 @@ if ($cgi->param('product') ne $cgi->param('dontchange')) {
} }
my $component; my $component;
my (%cc_add, %cc_remove);
if ($cgi->param('component') ne $cgi->param('dontchange')) { if ($cgi->param('component') ne $cgi->param('dontchange')) {
if (scalar(@newprod_ids) > 1) { if (scalar(@newprod_ids) > 1) {
ThrowUserError("no_component_change_for_multiple_products"); ThrowUserError("no_component_change_for_multiple_products");
...@@ -756,6 +758,16 @@ if ($cgi->param('component') ne $cgi->param('dontchange')) { ...@@ -756,6 +758,16 @@ if ($cgi->param('component') ne $cgi->param('dontchange')) {
DoComma(); DoComma();
$::query .= "component_id = ?"; $::query .= "component_id = ?";
push(@values, $component->id); push(@values, $component->id);
# 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;
}
}
} }
# If this installation uses bug aliases, and the user is changing the alias, # If this installation uses bug aliases, and the user is changing the alias,
...@@ -829,12 +841,9 @@ if ( defined $cgi->param('id') && ...@@ -829,12 +841,9 @@ if ( defined $cgi->param('id') &&
} }
} }
my $duplicate;
# We need to check the addresses involved in a CC change before we touch any bugs. # 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 # 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. # in this CC change. Then those hashes can be used later on for the actual change.
my (%cc_add, %cc_remove);
if (defined $cgi->param('newcc') if (defined $cgi->param('newcc')
|| defined $cgi->param('addselfcc') || defined $cgi->param('addselfcc')
|| defined $cgi->param('removecc') || defined $cgi->param('removecc')
...@@ -891,9 +900,38 @@ my $assignee_checked = 0; ...@@ -891,9 +900,38 @@ my $assignee_checked = 0;
my %usercache = (); my %usercache = ();
if (defined $cgi->param('qa_contact') if (defined $cgi->param('assigned_to')
&& $cgi->param('knob') ne "reassignbycomponent") && !$cgi->param('set_default_assignee')
&& trim($cgi->param('assigned_to')) ne $cgi->param('dontchange'))
{ {
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')) {
my $name = trim($cgi->param('qa_contact')); my $name = trim($cgi->param('qa_contact'));
# The QA contact cannot be deleted from show_bug.cgi for a single bug! # The QA contact cannot be deleted from show_bug.cgi for a single bug!
if ($name ne $cgi->param('dontchange')) { if ($name ne $cgi->param('dontchange')) {
...@@ -928,6 +966,12 @@ if (defined $cgi->param('qa_contact') ...@@ -928,6 +966,12 @@ if (defined $cgi->param('qa_contact')
} }
} }
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.
SWITCH: for ($cgi->param('knob')) { SWITCH: for ($cgi->param('knob')) {
/^none$/ && do { /^none$/ && do {
last SWITCH; last SWITCH;
...@@ -983,43 +1027,6 @@ SWITCH: for ($cgi->param('knob')) { ...@@ -983,43 +1027,6 @@ SWITCH: for ($cgi->param('knob')) {
} }
last SWITCH; last SWITCH;
}; };
/^reassign$/ && CheckonComment( "reassign" ) && do {
if ($cgi->param('andconfirm')) {
DoConfirm($bug);
}
if (defined $cgi->param('assigned_to')
&& trim($cgi->param('assigned_to')) ne "") {
$assignee = login_to_id(trim($cgi->param('assigned_to')), 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;
last SWITCH;
};
/^reassignbycomponent$/ && CheckonComment( "reassignbycomponent" ) && do {
if ($cgi->param('compconfirm')) {
DoConfirm($bug);
}
last SWITCH;
};
/^reopen$/ && CheckonComment( "reopen" ) && do { /^reopen$/ && CheckonComment( "reopen" ) && do {
last SWITCH; last SWITCH;
}; };
...@@ -1290,10 +1297,10 @@ foreach my $id (@idlist) { ...@@ -1290,10 +1297,10 @@ foreach my $id (@idlist) {
$comma = ','; $comma = ',';
} }
if ($cgi->param('knob') eq 'reassignbycomponent') { # We have to check whether the bug is moved to another product
# We have to check whether the bug is moved to another product # and/or component before reassigning. If $component is defined,
# and/or component before reassigning. If $component is defined, # use it; else use the product/component the bug is already in.
# use it; else use the product/component the bug is already in. if ($cgi->param('set_default_assignee')) {
my $new_comp_id = $component ? $component->id : $old_bug_obj->{'component_id'}; my $new_comp_id = $component ? $component->id : $old_bug_obj->{'component_id'};
$assignee = $dbh->selectrow_array('SELECT initialowner $assignee = $dbh->selectrow_array('SELECT initialowner
FROM components FROM components
...@@ -1302,29 +1309,22 @@ foreach my $id (@idlist) { ...@@ -1302,29 +1309,22 @@ foreach my $id (@idlist) {
$query .= "$comma assigned_to = ?"; $query .= "$comma assigned_to = ?";
push(@bug_values, $assignee); push(@bug_values, $assignee);
$comma = ','; $comma = ',';
if (Bugzilla->params->{"useqacontact"}) { }
$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);
}
else {
$query .= "$comma qa_contact = NULL";
}
}
# And add in the Default CC for the Component. if (Bugzilla->params->{'useqacontact'} && $cgi->param('set_default_qa_contact')) {
my $comp_obj = $component || new Bugzilla::Component($new_comp_id); my $new_comp_id = $component ? $component->id : $old_bug_obj->{'component_id'};
my @new_init_cc = @{$comp_obj->initial_cc}; $qacontact = $dbh->selectrow_array('SELECT initialqacontact
foreach my $cc (@new_init_cc) { FROM components
# NewCC must be defined or the code below won't insert WHERE components.id = ?',
# any CCs. undef, $new_comp_id);
$cgi->param('newcc') || $cgi->param('newcc', []); if ($qacontact) {
$cc_add{$cc->id} = $cc->login; $query .= "$comma qa_contact = ?";
push(@bug_values, $qacontact);
} }
else {
$query .= "$comma qa_contact = NULL";
}
$comma = ',';
} }
my %dependencychanged; my %dependencychanged;
...@@ -1362,24 +1362,19 @@ foreach my $id (@idlist) { ...@@ -1362,24 +1362,19 @@ foreach my $id (@idlist) {
} }
$oldhash{$col} = $oldvalues[$i]; $oldhash{$col} = $oldvalues[$i];
$formhash{$col} = $cgi->param($col) if defined $cgi->param($col); $formhash{$col} = $cgi->param($col) if defined $cgi->param($col);
# The status and resolution are defined by the workflow.
$formhash{$col} = $status if $col eq 'bug_status';
$formhash{$col} = $resolution if $col eq 'resolution';
$i++; $i++;
} }
# If the user is reassigning bugs, we need to: # The status and resolution are defined by the workflow.
# - convert $newhash{'assigned_to'} and $newhash{'qa_contact'} $formhash{'bug_status'} = $status;
# email addresses into their corresponding IDs; $formhash{'resolution'} = $resolution;
# We need to convert $newhash{'assigned_to'} and $newhash{'qa_contact'}
# email addresses into their corresponding IDs;
$formhash{'qa_contact'} = $qacontact if Bugzilla->params->{'useqacontact'}; $formhash{'qa_contact'} = $qacontact if Bugzilla->params->{'useqacontact'};
if ($cgi->param('knob') eq 'reassignbycomponent' $formhash{'assigned_to'} = $assignee;
|| $cgi->param('knob') eq 'reassign') {
$formhash{'assigned_to'} = $assignee;
}
# This hash is required by Bug::check_can_change_field(). # This hash is required by Bug::check_can_change_field().
my $cgi_hash = { my $cgi_hash = {'dontchange' => scalar $cgi->param('dontchange')};
'dontchange' => scalar $cgi->param('dontchange'),
'knob' => scalar $cgi->param('knob')
};
foreach my $col (@editable_bug_fields) { foreach my $col (@editable_bug_fields) {
if (exists $formhash{$col} if (exists $formhash{$col}
&& !$old_bug_obj->check_can_change_field($col, $oldhash{$col}, $formhash{$col}, && !$old_bug_obj->check_can_change_field($col, $oldhash{$col}, $formhash{$col},
......
...@@ -667,7 +667,7 @@ ...@@ -667,7 +667,7 @@
[%############################################################################%] [%############################################################################%]
[% BLOCK section_people %] [% BLOCK section_people %]
<table cellpadding="1" cellspacing="1"> <table cellpadding="3" cellspacing="1">
<tr> <tr>
<td align="right"> <td align="right">
<b>Reporter</b>: <b>Reporter</b>:
...@@ -678,20 +678,34 @@ ...@@ -678,20 +678,34 @@
</tr> </tr>
<tr> <tr>
<td align="right"> <td align="right" valign="top">
<b><a href="page.cgi?id=fields.html#assigned_to">Assigned&nbsp;To</a></b>: <b><a href="page.cgi?id=fields.html#assigned_to">Assignee</a></b>:
</td> </td>
<td> <td>
[% INCLUDE user_identity user => bug.assigned_to %] [% IF bug.check_can_change_field("assigned_to", 0, 1) %]
[% INCLUDE global/userselect.html.tmpl
id => "assigned_to"
name => "assigned_to"
value => bug.assigned_to.login
size => 30
%]
<br>
<input type="checkbox" id="set_default_assignee" name="set_default_assignee" value="1">
<label for="set_default_assignee">Reset Assignee to default</label>
[% ELSE %]
<input type="hidden" name="assigned_to" id="assigned_to"
value="[% bug.assigned_to.login FILTER html %]">
[% INCLUDE user_identity user => bug.assigned_to %]
[% END %]
</td> </td>
</tr> </tr>
[% IF Param('useqacontact') %] [% IF Param('useqacontact') %]
<tr> <tr>
<td align="right"> <td align="right" valign="top">
<label for="qa_contact" accesskey="q"><b><u>Q</u>A Contact</b></label>: <label for="qa_contact" accesskey="q"><b><u>Q</u>A Contact</b></label>:
</td> </td>
<td colspan="7"> <td>
[% IF bug.check_can_change_field("qa_contact", 0, 1) %] [% IF bug.check_can_change_field("qa_contact", 0, 1) %]
[% INCLUDE global/userselect.html.tmpl [% INCLUDE global/userselect.html.tmpl
id => "qa_contact" id => "qa_contact"
...@@ -700,6 +714,9 @@ ...@@ -700,6 +714,9 @@
size => 30 size => 30
emptyok => 1 emptyok => 1
%] %]
<br>
<input type="checkbox" id="set_default_qa_contact" name="set_default_qa_contact" value="1">
<label for="set_default_qa_contact">Reset QA Contact to default</label>
[% ELSE %] [% ELSE %]
<input type="hidden" name="qa_contact" id="qa_contact" <input type="hidden" name="qa_contact" id="qa_contact"
value="[% bug.qa_contact.login FILTER html %]"> value="[% bug.qa_contact.login FILTER html %]">
......
...@@ -76,49 +76,6 @@ ...@@ -76,49 +76,6 @@
[% PROCESS select_resolution %] [% PROCESS select_resolution %]
[% PROCESS duplicate %] [% PROCESS duplicate %]
[% IF bug.user.canedit %]
<input type="radio" id="knob-reassign" name="knob" value="reassign">
<label for="knob-reassign">
<a href="page.cgi?id=fields.html#assigned_to">Reassign</a>
[% terms.bug %] to
</label>
[% safe_assigned_to = FILTER js; bug.assigned_to.login; END %]
[% INCLUDE global/userselect.html.tmpl
id => "assigned_to"
name => "assigned_to"
value => bug.assigned_to.login
size => 32
onchange => "if ((this.value != '$safe_assigned_to') && (this.value != '')) {
document.changeform.knob[$knum].checked=true;
}"
%]
<br>
[% IF bug.isunconfirmed && bug.user.canconfirm %]
&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="andconfirm" name="andconfirm">
<label for="andconfirm">
and confirm [% terms.bug %] (change status to <b>[% get_status("NEW") FILTER html %]</b>)
</label>
<br>
[% END %]
[% knum = knum + 1 %]
<input type="radio" id="knob-reassign-cmp" name="knob" value="reassignbycomponent">
<label for="knob-reassign-cmp">
Reassign [% terms.bug %] to default assignee
[% " and QA contact," IF Param('useqacontact') %]
and add Default CC of selected component
</label>
<br>
[% IF bug.isunconfirmed && bug.user.canconfirm %]
&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="compconfirm" name="compconfirm">
<label for="compconfirm">
and confirm [% terms.bug %] (change status to <b>[% get_status("NEW") FILTER html %]</b>)
</label>
<br>
[% END %]
[% knum = knum + 1 %]
[% END %]
[% ELSE %] [% ELSE %]
[% IF bug.resolution != "MOVED" || [% IF bug.resolution != "MOVED" ||
(bug.resolution == "MOVED" && bug.user.canmove) %] (bug.resolution == "MOVED" && bug.user.canmove) %]
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# userlist: select only; array reference with list of users and identities
# userlist is built by Bugzilla::User::get_userlist()
# name: mandatory; field name # name: mandatory; field name
# id: optional; field id # id: optional; field id
# value: optional; default field value/selection # value: optional; default field value/selection
...@@ -26,7 +24,7 @@ ...@@ -26,7 +24,7 @@
# size: optional, input only; size attribute value # size: optional, input only; size attribute value
# emptyok: optional, select only; if true, prepend menu option to start of select # emptyok: optional, select only; if true, prepend menu option to start of select
# multiple: optional, do multiselect box, value is size (height) of box # multiple: optional, do multiselect box, value is size (height) of box
# # do_not_change: optional, contains the string meaning "do not alter this role"
#%] #%]
[% IF Param("usemenuforusers") %] [% IF Param("usemenuforusers") %]
...@@ -40,6 +38,13 @@ ...@@ -40,6 +38,13 @@
[% IF emptyok %] [% IF emptyok %]
<option value=""></option> <option value=""></option>
[% END %] [% END %]
[% IF do_not_change %]
<option value="[% do_not_change FILTER html %]">
[% do_not_change FILTER html %]
</option>
[% END %]
[% FOREACH tmpuser = user.get_userlist %] [% FOREACH tmpuser = user.get_userlist %]
[% IF tmpuser.visible OR value.match("\\b$tmpuser.login\\b") %] [% IF tmpuser.visible OR value.match("\\b$tmpuser.login\\b") %]
<option value="[% tmpuser.login FILTER html %]" <option value="[% tmpuser.login FILTER html %]"
......
...@@ -150,14 +150,34 @@ ...@@ -150,14 +150,34 @@
</tr> </tr>
[% END %] [% END %]
<tr>
<th><label for="assigned_to">Assignee:</label></th>
<td colspan="3">
[% INCLUDE global/userselect.html.tmpl
id => "assigned_to"
name => "assigned_to"
value => dontchange
do_not_change => dontchange
size => 32
%]
<input type="checkbox" id="set_default_assignee" name="set_default_assignee" value="1">
<label for="set_default_assignee">Reset Assignee to default</label>
</td>
</tr>
[% IF Param("useqacontact") %] [% IF Param("useqacontact") %]
<tr> <tr>
<th><label for="qa_contact">QA Contact:</label></th> <th><label for="qa_contact">QA Contact:</label></th>
<td colspan="3"> <td colspan="3">
<input id="qa_contact" [% INCLUDE global/userselect.html.tmpl
name="qa_contact" id => "qa_contact"
value="[% dontchange FILTER html %]" name => "qa_contact"
size="32"> value => dontchange
do_not_change => dontchange
size => 32
%]
<input type="checkbox" id="set_default_qa_contact" name="set_default_qa_contact" value="1">
<label for="set_default_qa_contact">Reset QA Contact to default</label>
</td> </td>
</tr> </tr>
[% END %] [% END %]
...@@ -336,27 +356,6 @@ ...@@ -336,27 +356,6 @@
<label for="knob-close">Mark [% terms.bugs %] as <b>[% get_status("CLOSED") FILTER html %]</b></label><br> <label for="knob-close">Mark [% terms.bugs %] as <b>[% get_status("CLOSED") FILTER html %]</b></label><br>
[% END %] [% END %]
[% knum = knum + 1 %]
<input id="knob-reassign" type="radio" name="knob" value="reassign">
<label for="knob-reassign"><a href="page.cgi?id=fields.html#assigned_to">
Reassign</a> [% terms.bugs %] to
</label>
[% INCLUDE global/userselect.html.tmpl
name => "assigned_to"
value => user.login
size => 32
onchange => "document.forms.changeform.knob[$knum].checked=true;"
%]<br>
[% knum = knum + 1 %]
<input id="knob-reassignbycomponent"
type="radio"
name="knob"
value="reassignbycomponent">
<label for="knob-reassignbycomponent">
Reassign [% terms.bugs %] to default assignee of selected component
</label><br>
<input type="submit" id="commit" value="Commit"> <input type="submit" id="commit" value="Commit">
[% IF Param('move-enabled') && user.is_mover %] [% IF Param('move-enabled') && user.is_mover %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment