From 36478e4ed9e8b3f1e613a0829e4ee9f54c1f8f40 Mon Sep 17 00:00:00 2001 From: Robert Webb Date: Wed, 28 Sep 2011 16:23:31 -0700 Subject: Bug 512648 - Make Bugzilla::Bug centrally control available statuses in enter_bug.cgi r=mkanat, a=mkanat --- enter_bug.cgi | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'enter_bug.cgi') diff --git a/enter_bug.cgi b/enter_bug.cgi index 497209df4..4ef886741 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -342,27 +342,15 @@ if ( Bugzilla->params->{'usetargetmilestone'} ) { } # Construct the list of allowable statuses. -my @statuses = @{ Bugzilla::Status->can_change_to() }; +my @statuses = @{ Bugzilla::Bug->new_bug_statuses($product) }; # Exclude closed states from the UI, even if the workflow allows them. # The back-end code will still accept them, though. +# XXX We should remove this when the UI accepts closed statuses and update +# Bugzilla::Bug->default_bug_status. @statuses = grep { $_->is_open } @statuses; -# UNCONFIRMED is illegal if allows_unconfirmed is false. -if (!$product->allows_unconfirmed) { - @statuses = grep { $_->name ne 'UNCONFIRMED' } @statuses; -} scalar(@statuses) || ThrowUserError('no_initial_bug_status'); -# If the user has no privs... -unless ($has_editbugs || $has_canconfirm) { - # ... use UNCONFIRMED if available, else use the first status of the list. - my ($unconfirmed) = grep { $_->name eq 'UNCONFIRMED' } @statuses; - - # Because of an apparent Perl bug, "$unconfirmed || $statuses[0]" doesn't - # work, so we're using an "?:" operator. See bug 603314 for details. - @statuses = ($unconfirmed ? $unconfirmed : $statuses[0]); -} - $vars->{'bug_status'} = \@statuses; # Get the default from a template value if it is legitimate. @@ -372,12 +360,8 @@ $vars->{'bug_status'} = \@statuses; my $picked_status = formvalue('bug_status'); if ($picked_status and grep($_->name eq $picked_status, @statuses)) { $default{'bug_status'} = formvalue('bug_status'); -} elsif (scalar @statuses == 1) { - $default{'bug_status'} = $statuses[0]->name; -} -else { - $default{'bug_status'} = ($statuses[0]->name ne 'UNCONFIRMED') - ? $statuses[0]->name : $statuses[1]->name; +} else { + $default{'bug_status'} = Bugzilla::Bug->default_bug_status(@statuses); } my @groups = $cgi->param('groups'); -- cgit v1.2.3-24-g4f1b