From 931bd3b651ccca832a618f7b28bbc35e503665d4 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 3 Oct 2008 06:28:31 +0000 Subject: Bug 455632: Add Bugzilla::Field::Choice->create and have editvalues.cgi use it Patch By Max Kanat-Alexander r=bbaetz, a=mkanat --- Bugzilla/Status.pm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'Bugzilla/Status.pm') 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 #### ############################### -- cgit v1.2.3-24-g4f1b