summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xBugzilla/Bug.pm1
-rwxr-xr-xattachment.cgi57
-rw-r--r--template/en/default/attachment/create.html.tmpl15
3 files changed, 36 insertions, 37 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 1e1dee712..e1b4a6e55 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1466,6 +1466,7 @@ sub set_remaining_time { $_[0]->set('remaining_time', $_[1]); }
sub _zero_remaining_time { $_[0]->{'remaining_time'} = 0; }
sub set_reporter_accessible { $_[0]->set('reporter_accessible', $_[1]); }
sub set_resolution { $_[0]->set('resolution', $_[1]); }
+sub clear_resolution { $_[0]->{'resolution'} = '' }
sub set_severity { $_[0]->set('bug_severity', $_[1]); }
sub set_status {
my ($self, $status) = @_;
diff --git a/attachment.cgi b/attachment.cgi
index 13d225bdd..d9521b591 100755
--- a/attachment.cgi
+++ b/attachment.cgi
@@ -359,45 +359,28 @@ sub insert {
# Assign the bug to the user, if they are allowed to take it
my $owner = "";
-
if ($cgi->param('takebug') && $user->in_group('editbugs', $bug->product_id)) {
-
- my @fields = ("assigned_to", "bug_status", "resolution", "everconfirmed",
- "login_name");
-
- # Get the old values, for the bugs_activity table
- my @oldvalues = $dbh->selectrow_array(
- "SELECT " . join(", ", @fields) . " " .
- "FROM bugs " .
- "INNER JOIN profiles " .
- "ON profiles.userid = bugs.assigned_to " .
- "WHERE bugs.bug_id = ?", undef, $bugid);
-
- my @newvalues = ($user->id, "ASSIGNED", "", 1, $user->login);
-
+ # When taking a bug, we have to follow the workflow.
+ my $bug_status = $cgi->param('bug_status') || '';
+ ($bug_status) = grep {$_->name eq $bug_status} @{$bug->status->can_change_to};
+
+ if ($bug_status && $bug_status->is_open
+ && ($bug_status->name ne 'UNCONFIRMED' || $bug->product_obj->votes_to_confirm))
+ {
+ $bug->set_status($bug_status->name);
+ $bug->clear_resolution();
+ $bug->update($timestamp);
+ }
# Make sure the person we are taking the bug from gets mail.
- $owner = $oldvalues[4];
-
- # Update the bug record. Note that this doesn't involve login_name.
- $dbh->do('UPDATE bugs SET delta_ts = ?, ' .
- join(', ', map("$fields[$_] = ?", (0..3))) . ' WHERE bug_id = ?',
- undef, ($timestamp, map($newvalues[$_], (0..3)) , $bugid));
-
- # If the bug was a dupe, we have to remove its entry from the
- # 'duplicates' table.
- $dbh->do('DELETE FROM duplicates WHERE dupe = ?', undef, $bugid);
-
- # We store email addresses in the bugs_activity table rather than IDs.
- $oldvalues[0] = $oldvalues[4];
- $newvalues[0] = $newvalues[4];
-
- for (my $i = 0; $i < 4; $i++) {
- if ($oldvalues[$i] ne $newvalues[$i]) {
- LogActivityEntry($bugid, $fields[$i], $oldvalues[$i],
- $newvalues[$i], $user->id, $timestamp);
- }
- }
- }
+ $owner = $bug->assigned_to->login;
+
+ # Ideally, the code below should be replaced by $bug->set_assignee().
+ $dbh->do('UPDATE bugs SET assigned_to = ?, delta_ts = ? WHERE bug_id = ?',
+ undef, ($user->id, $timestamp, $bugid));
+
+ LogActivityEntry($bugid, 'assigned_to', $owner, $user->login, $user->id, $timestamp);
+
+ }
# Define the variables and functions that will be passed to the UI template.
$vars->{'mailrecipients'} = { 'changer' => $user->login,
diff --git a/template/en/default/attachment/create.html.tmpl b/template/en/default/attachment/create.html.tmpl
index 10a6abec2..781674a96 100644
--- a/template/en/default/attachment/create.html.tmpl
+++ b/template/en/default/attachment/create.html.tmpl
@@ -73,6 +73,21 @@
check the box below.</em><br>
<input type="checkbox" id="takebug" name="takebug" value="1">
<label for="takebug">take [% terms.bug %]</label>
+ [% bug_statuses = [] %]
+ [% FOREACH bug_status = bug.status.can_change_to %]
+ [% NEXT IF bug_status.name == "UNCONFIRMED" && !bug.product_obj.votes_to_confirm %]
+ [% bug_statuses.push(bug_status) IF bug_status.is_open %]
+ [% END %]
+ [% IF bug_statuses.size %]
+ <label for="takebug">and set the [% terms.bug %] status to</label>
+ <select id="bug_status" name="bug_status">
+ <option label="[% bug.status.name FILTER html %]">[% bug.status.name FILTER html %] (current)</option>
+ [% FOREACH bug_status = bug_statuses %]
+ [% NEXT IF bug_status.id == bug.status.id %]
+ <option label="[% bug_status.name FILTER html %]">[% bug_status.name FILTER html %]</option>
+ [% END %]
+ </select>
+ [% END %]
</td>
</tr>
[% END %]