summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-08-22 03:48:41 +0200
committermkanat%bugzilla.org <>2006-08-22 03:48:41 +0200
commit3f5c73cce7d1cc1b4e7323013a690d2eab225c1a (patch)
treeccebf0e1330533c8dfb4f3842ead771685bf006e /Bugzilla/Bug.pm
parentdc9ce3a8bc08c8f7c35b926bfaf7cfdd007c6380 (diff)
downloadbugzilla-3f5c73cce7d1cc1b4e7323013a690d2eab225c1a.tar.gz
bugzilla-3f5c73cce7d1cc1b4e7323013a690d2eab225c1a.tar.xz
Bug 348537: Move bug status validation out of post_bug and into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bkor, a=myk
Diffstat (limited to 'Bugzilla/Bug.pm')
-rwxr-xr-xBugzilla/Bug.pm35
1 files changed, 35 insertions, 0 deletions
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) = @_;