summaryrefslogtreecommitdiffstats
path: root/editworkflow.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-05-27 05:27:45 +0200
committerlpsolit%gmail.com <>2007-05-27 05:27:45 +0200
commit2bd57ce8e6f2c2bb59a99d825fc9d181ea2cb4a5 (patch)
tree6bd15d0b6062217eaf3e7f82eaff89f75715f702 /editworkflow.cgi
parent9e81bb0333048f6066610f66614a1ef163917137 (diff)
downloadbugzilla-2bd57ce8e6f2c2bb59a99d825fc9d181ea2cb4a5.tar.gz
bugzilla-2bd57ce8e6f2c2bb59a99d825fc9d181ea2cb4a5.tar.xz
Bug 344965: Fix process_bug.cgi and bug/* templates to work with custom bug status workflow - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=LpSolit
Diffstat (limited to 'editworkflow.cgi')
-rw-r--r--editworkflow.cgi42
1 files changed, 21 insertions, 21 deletions
diff --git a/editworkflow.cgi b/editworkflow.cgi
index 9a369c974..ac914f76d 100644
--- a/editworkflow.cgi
+++ b/editworkflow.cgi
@@ -27,6 +27,7 @@ use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Token;
+use Bugzilla::Status;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
@@ -42,12 +43,6 @@ $user->in_group('admin')
my $action = $cgi->param('action') || 'edit';
my $token = $cgi->param('token');
-sub get_statuses {
- my $statuses = $dbh->selectall_arrayref('SELECT id, value, is_open FROM bug_status
- ORDER BY sortkey, value', { Slice => {} });
- return $statuses;
-}
-
sub get_workflow {
my $workflow = $dbh->selectall_arrayref('SELECT old_status, new_status, require_comment
FROM status_workflow');
@@ -64,7 +59,7 @@ sub load_template {
my $template = Bugzilla->template;
my $vars = {};
- $vars->{'statuses'} = get_statuses();
+ $vars->{'statuses'} = [Bugzilla::Status->get_all];
$vars->{'workflow'} = get_workflow();
$vars->{'token'} = issue_session_token("workflow_$filename");
$vars->{'message'} = $message;
@@ -79,9 +74,8 @@ if ($action eq 'edit') {
}
elsif ($action eq 'update') {
check_token_data($token, 'workflow_edit');
- my $statuses = get_statuses;
+ my $statuses = [Bugzilla::Status->get_all];
my $workflow = get_workflow();
- my $initial_state = {id => 0};
my $sth_insert = $dbh->prepare('INSERT INTO status_workflow (old_status, new_status)
VALUES (?, ?)');
@@ -90,22 +84,28 @@ elsif ($action eq 'update') {
my $sth_delnul = $dbh->prepare('DELETE FROM status_workflow
WHERE old_status IS NULL AND new_status = ?');
- foreach my $old ($initial_state, @$statuses) {
- # Hashes cannot have undef as a key, so we use 0. But the DB
- # must store undef, for referential integrity.
- my $old_id_for_db = $old->{'id'} || undef;
+ # Part 1: Initial bug statuses.
+ foreach my $new (@$statuses) {
+ if ($cgi->param('w_0_' . $new->id)) {
+ $sth_insert->execute(undef, $new->id)
+ unless defined $workflow->{0}->{$new->id};
+ }
+ else {
+ $sth_delnul->execute($new->id);
+ }
+ }
+
+ # Part 2: Bug status changes.
+ foreach my $old (@$statuses) {
foreach my $new (@$statuses) {
- next if $old->{'id'} == $new->{'id'};
+ next if $old->id == $new->id;
- if ($cgi->param('w_' . $old->{'id'} . '_' . $new->{'id'})) {
- $sth_insert->execute($old_id_for_db, $new->{'id'})
- unless defined $workflow->{$old->{'id'}}->{$new->{'id'}};
- }
- elsif ($old_id_for_db) {
- $sth_delete->execute($old_id_for_db, $new->{'id'});
+ if ($cgi->param('w_' . $old->id . '_' . $new->id)) {
+ $sth_insert->execute($old->id, $new->id)
+ unless defined $workflow->{$old->id}->{$new->id};
}
else {
- $sth_delnul->execute($new->{'id'});
+ $sth_delete->execute($old->id, $new->id);
}
}
}