summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Status.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-10-03 08:28:31 +0200
committermkanat%bugzilla.org <>2008-10-03 08:28:31 +0200
commit931bd3b651ccca832a618f7b28bbc35e503665d4 (patch)
tree44518a36cc628b44c329319501fcb8e402c72d97 /Bugzilla/Status.pm
parent7bfd680d6fb32886fcbad107ffed75974ff7009f (diff)
downloadbugzilla-931bd3b651ccca832a618f7b28bbc35e503665d4.tar.gz
bugzilla-931bd3b651ccca832a618f7b28bbc35e503665d4.tar.xz
Bug 455632: Add Bugzilla::Field::Choice->create and have editvalues.cgi use it
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat
Diffstat (limited to 'Bugzilla/Status.pm')
-rw-r--r--Bugzilla/Status.pm55
1 files changed, 51 insertions, 4 deletions
diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm
index f8b77331c..5f37974e7 100644
--- a/Bugzilla/Status.pm
+++ b/Bugzilla/Status.pm
@@ -22,13 +22,28 @@ use strict;
package Bugzilla::Status;
-use base qw(Bugzilla::Object Exporter);
-@Bugzilla::Status::EXPORT = qw(BUG_STATE_OPEN is_open_state closed_bug_statuses);
+use Bugzilla::Error;
+
+use base qw(Bugzilla::Field::Choice Exporter);
+@Bugzilla::Status::EXPORT = qw(
+ BUG_STATE_OPEN
+ SPECIAL_STATUS_WORKFLOW_ACTIONS
+
+ is_open_state
+ closed_bug_statuses
+);
################################
##### Initialization #####
################################
+use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw(
+ none
+ duplicate
+ change_resolution
+ clearresolution
+);
+
use constant DB_TABLE => 'bug_status';
use constant DB_COLUMNS => qw(
@@ -39,8 +54,24 @@ use constant DB_COLUMNS => qw(
is_open
);
-use constant NAME_FIELD => 'value';
-use constant LIST_ORDER => 'sortkey, value';
+sub VALIDATORS {
+ my $invocant = shift;
+ my $validators = $invocant->SUPER::VALIDATORS;
+ $validators->{is_open} = \&Bugzilla::Object::check_boolean;
+ $validators->{value} = \&_check_value;
+ return $validators;
+}
+
+#########################
+# Database Manipulation #
+#########################
+
+sub create {
+ my $class = shift;
+ my $self = $class->SUPER::create(@_);
+ add_missing_bug_status_transitions();
+ return $self;
+}
###############################
##### Accessors ####
@@ -51,6 +82,22 @@ sub sortkey { return $_[0]->{'sortkey'}; }
sub is_active { return $_[0]->{'isactive'}; }
sub is_open { return $_[0]->{'is_open'}; }
+##############
+# Validators #
+##############
+
+sub _check_value {
+ my $invocant = shift;
+ my $value = $invocant->SUPER::_check_value(@_);
+
+ if (grep { lc($value) eq lc($_) } SPECIAL_STATUS_WORKFLOW_ACTIONS) {
+ ThrowUserError('fieldvalue_reserved_word',
+ { field => $invocant->field, value => $value });
+ }
+ return $value;
+}
+
+
###############################
##### Methods ####
###############################