Commit 620caf68 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 402791: Move status and resolution updating from process_bug.cgi into Bugzilla::Bug

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
parent f39fc76d
......@@ -106,6 +106,24 @@ sub can_change_to {
return $self->{'can_change_to'};
}
sub allow_change_from {
my ($self, $old_status, $product) = @_;
# Always allow transitions from a status to itself.
return 1 if ($old_status && $old_status->id == $self->id);
if ($self->name eq 'UNCONFIRMED' && !$product->votes_to_confirm) {
# UNCONFIRMED is an invalid status transition if votes_to_confirm is 0
# in this product.
return 0;
}
my ($cond, $values) = $self->_status_condition($old_status);
my ($transition_allowed) = Bugzilla->dbh->selectrow_array(
"SELECT 1 FROM status_workflow WHERE $cond", undef, @$values);
return $transition_allowed ? 1 : 0;
}
sub can_change_from {
my $self = shift;
my $dbh = Bugzilla->dbh;
......@@ -128,6 +146,32 @@ sub can_change_from {
return $self->{'can_change_from'};
}
sub comment_required_on_change_from {
my ($self, $old_status) = @_;
my ($cond, $values) = $self->_status_condition($old_status);
my ($require_comment) = Bugzilla->dbh->selectrow_array(
"SELECT require_comment FROM status_workflow
WHERE $cond", undef, @$values);
return $require_comment;
}
# Used as a helper for various functions that have to deal with old_status
# sometimes being NULL and sometimes having a value.
sub _status_condition {
my ($self, $old_status) = @_;
my @values;
my $cond = 'old_status IS NULL';
# For newly-filed bugs
if ($old_status) {
$cond = 'old_status = ?';
push(@values, $old_status->id);
}
$cond .= " AND new_status = ?";
push(@values, $self->id);
return ($cond, \@values);
}
sub add_missing_bug_status_transitions {
my $bug_status = shift || Bugzilla->params->{'duplicate_or_move_bug_status'};
my $dbh = Bugzilla->dbh;
......@@ -215,6 +259,60 @@ below.
Returns: A list of Bugzilla::Status objects.
=item C<allow_change_from>
=over
=item B<Description>
Tells you whether or not a change to this status from another status is
allowed.
=item B<Params>
=over
=item C<$old_status> - The Bugzilla::Status you're changing from.
=item C<$product> - A L<Bugzilla::Product> representing the product of
the bug you're changing. Needed to check product-specific workflow
issues (such as whether or not the C<UNCONFIRMED> status is enabled
in this product).
=back
=item B<Returns>
C<1> if you are allowed to change to this status from that status, or
C<0> if you aren't allowed.
Note that changing from a status to itself is always allowed.
=back
=item C<comment_required_on_change_from>
=over
=item B<Description>
Checks if a comment is required to change to this status from another
status, according to the current settings in the workflow.
Note that this doesn't implement the checks enforced by the various
C<commenton> parameters--those are checked by internal checks in
L<Bugzilla::Bug>.
=item B<Params>
C<$old_status> - The status you're changing from.
=item B<Returns>
C<1> if a comment is required on this change, C<0> if not.
=back
=item C<add_missing_bug_status_transitions>
Description: Insert all missing transitions to a given bug status.
......
......@@ -309,6 +309,10 @@
[% ELSIF error == "need_quipid" %]
A valid quipid is needed.
[% ELSIF error == "no_manual_moved" %]
You cannot set the resolution of [% terms.abug %] to MOVED without
moving the [% terms.bug %].
[% ELSIF error == "param_must_be_numeric" %]
[% title = "Invalid Parameter" %]
Invalid parameter passed to [% function FILTER html %].
......
......@@ -252,14 +252,15 @@
[% ELSIF error == "comment_required" %]
[% title = "Comment Required" %]
You have to specify a <b>comment</b>
[% IF old.size && new %]
to change the [% terms.bug %] status from [% old.join(", ") FILTER html %]
to [% new FILTER html %].
You have to specify a
[% IF old && new %]
<b>comment</b> when changing the status of [% terms.abug %] from
[%+ old.name FILTER html %] to [% new.name FILTER html %].
[% ELSIF new %]
description for this [% terms.bug %].
[% ELSE %]
on this change.
<b>comment</b> on this change.
[% END %]
Please explain your change.
[% ELSIF error == "comment_too_long" %]
[% title = "Comment Too Long" %]
......@@ -346,9 +347,10 @@
[% title = "Dependency Loop Detected" %]
You can't make [% terms.abug %] block itself or depend on itself.
[% ELSIF error == "description_required" %]
[% title = "Description Required" %]
You must provide a description of the [% terms.bug %].
[% ELSIF error == "dupe_id_required" %]
[% title = "Duplicate Bug Id Required" %]
You must specify [% terms.abug %] id to mark this [% terms.bug %]
as a duplicate of.
[% ELSIF error == "dupe_not_allowed" %]
[% title = "Cannot mark $terms.bugs as duplicates" %]
......@@ -679,8 +681,13 @@
[% ELSIF error == "illegal_bug_status_transition" %]
[% title = "Illegal $terms.Bug Status Change" %]
[% IF old.defined %]
You are not allowed to change the [% terms.bug %] status from
[%+ old FILTER html %] to [% new FILTER html %].
[%+ old.name FILTER html %] to [% new.name FILTER html %].
[% ELSE %]
You are not allowed to file new [% terms.bugs %] with the
[%+ new.name FILTER html %] status.
[% END %]
[% ELSIF error == "illegal_change" %]
[% title = "Not allowed" %]
......@@ -940,7 +947,7 @@
[% ELSIF error == "milestone_required" %]
[% title = "Milestone Required" %]
You must determine a target milestone for [% terms.bug %]
[%+ bug_id FILTER html %]
[%+ bug.id FILTER html %]
if you are going to accept it. Part of accepting
[%+ terms.abug %] is giving an estimate of when it will be fixed.
......@@ -1379,6 +1386,10 @@
[% title = "Summary Needed" %]
You must enter a summary for this [% terms.bug %].
[% ELSIF error == "resolution_cant_clear" %]
[% terms.Bug %] [% bug_id FILTER bug_link(bug_id) FILTER none %] is
closed, so you cannot clear its resolution.
[% ELSIF error == "resolution_not_allowed" %]
[% title = "Resolution Not Allowed" %]
You cannot set a resolution for open [% terms.bugs %].
......@@ -1659,5 +1670,7 @@
version
[% ELSIF class == "Bugzilla::Milestone" %]
milestone
[% ELSIF class == "Bugzilla::Status" %]
status
[% END %]
[% END %]
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