From 3f5c73cce7d1cc1b4e7323013a690d2eab225c1a Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 22 Aug 2006 01:48:41 +0000 Subject: Bug 348537: Move bug status validation out of post_bug and into Bugzilla::Bug Patch By Max Kanat-Alexander r=bkor, a=myk --- Bugzilla/Bug.pm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 08677967a..3e65ab9b3 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -102,6 +102,14 @@ use constant MAX_LINE_LENGTH => 254; # Used in ValidateComment(). Gives the max length allowed for a comment. use constant MAX_COMMENT_LENGTH => 65535; +# The statuses that are valid on enter_bug.cgi and post_bug.cgi. +# The order is important--see _check_bug_status +use constant VALID_ENTRY_STATUS => qw( + UNCONFIRMED + NEW + ASSIGNED +); + ##################################################################### sub new { @@ -253,6 +261,33 @@ sub _check_bug_file_loc { return $url; } +sub _check_bug_status { + my ($status, $product) = @_; + my $user = Bugzilla->user; + + my @valid_statuses = VALID_ENTRY_STATUS; + + if ($user->in_group('editbugs') || $user->in_group('canconfirm')) { + # Default to NEW if the user with privs hasn't selected another status. + $status ||= 'NEW'; + } + elsif (!$product->votes_to_confirm) { + # Without privs, products that don't support UNCONFIRMED default to + # NEW. + $status = 'NEW'; + } + else { + $status = 'UNCONFIRMED'; + } + + # UNCONFIRMED becomes an invalid status if votes_to_confirm is 0, + # even if you are in editbugs. + shift @valid_statuses if !$product->votes_to_confirm; + + check_field('bug_status', $status, \@valid_statuses); + return $status; +} + sub _check_comment { my ($comment) = @_; -- cgit v1.2.3-24-g4f1b