summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-04-11 04:30:32 +0200
committerlpsolit%gmail.com <>2007-04-11 04:30:32 +0200
commit09becc83e7b67df0e72ede95592cce22b04a806c (patch)
treed1bc23e98614d6fef3c100c7f39131724bcf33ce /Bugzilla
parentedcc538e961a21c18566bf71fea02c0ef5bbd256 (diff)
downloadbugzilla-09becc83e7b67df0e72ede95592cce22b04a806c.tar.gz
bugzilla-09becc83e7b67df0e72ede95592cce22b04a806c.tar.xz
Bug 375191: Remove ChangeStatus() and ChangeResolution() from process_bug.cgi - Patch by Frédéric Buclin <LpSolit@gmail.com> r=gerv r=mkanat r=bkor a=LpSolit
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm84
1 files changed, 84 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index daebaf701..777fca323 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1495,6 +1495,90 @@ sub bug_alias_to_id {
}
#####################################################################
+# Workflow Control routines
+#####################################################################
+
+sub get_new_status_and_resolution {
+ my ($self, $action, $resolution) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ my $status;
+ if ($action eq 'none') {
+ # Leaving the status unchanged doesn't need more investigation.
+ return ($self->bug_status, $self->resolution);
+ }
+ elsif ($action eq 'reopen') {
+ $status = $self->everconfirmed ? 'REOPENED' : 'UNCONFIRMED';
+ $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') {
+ # Only alter the bug status if the bug is currently open.
+ $status = is_open_state($self->bug_status) ? 'RESOLVED' : $self->bug_status;
+ $resolution = 'DUPLICATE';
+ }
+ elsif ($action eq 'change_resolution') {
+ $status = $self->bug_status;
+ # You cannot change the resolution of an open bug.
+ ThrowUserError('resolution_not_allowed') if is_open_state($status);
+ $resolution || ThrowUserError('missing_resolution', {status => $status});
+ }
+ elsif ($action eq 'clearresolution') {
+ $status = $self->bug_status;
+ is_open_state($status) || ThrowUserError('missing_resolution', {status => $status});
+ $resolution = '';
+ }
+ else {
+ # That's where actions not requiring any specific trigger (such as future
+ # custom statuses) come.
+ # XXX - This is hardcoded here for now, but will disappear soon when
+ # this routine will look at the DB directly to get the workflow.
+ if ($action eq 'confirm') {
+ $status = 'NEW';
+ }
+ elsif ($action eq 'accept') {
+ $status = 'ASSIGNED';
+ }
+ elsif ($action eq 'resolve') {
+ $status = 'RESOLVED';
+ }
+ elsif ($action eq 'verify') {
+ $status = 'VERIFIED';
+ }
+ elsif ($action eq 'close') {
+ $status = 'CLOSED';
+ }
+ else {
+ ThrowCodeError('unknown_action', { action => $action });
+ }
+
+ if (is_open_state($status)) {
+ # Open bugs have no resolution.
+ $resolution = '';
+ }
+ else {
+ # All non-open statuses must have a resolution.
+ $resolution || ThrowUserError('missing_resolution', {status => $status});
+ }
+ }
+ # Now it's time to validate the bug resolution.
+ # Bug resolutions have no workflow specific rules, so any valid
+ # resolution will do it.
+ check_field('resolution', $resolution) if ($resolution ne '');
+ trick_taint($resolution);
+
+ return ($status, $resolution);
+}
+
+#####################################################################
# Subroutines
#####################################################################