From a806b298f5bfe5914f27a1419d27366fe59da449 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 9 Sep 2006 06:11:40 +0000 Subject: Bug 287326: Ability to add custom single-select fields to a bug - Patch by Frédéric Buclin and Max Kanat-Alexander r=mkanat a=myk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Bug.pm | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 03a28bf5d..6e8079d27 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -110,20 +110,30 @@ use constant REQUIRED_CREATE_FIELDS => qw( # There are also other, more complex validators that are called # from run_create_validators. -use constant VALIDATORS => { - alias => \&_check_alias, - bug_file_loc => \&_check_bug_file_loc, - bug_severity => \&_check_bug_severity, - cc => \&_check_cc, - deadline => \&_check_deadline, - estimated_time => \&_check_estimated_time, - op_sys => \&_check_op_sys, - priority => \&_check_priority, - product => \&_check_product, - remaining_time => \&_check_remaining_time, - rep_platform => \&_check_rep_platform, - short_desc => \&_check_short_desc, - status_whiteboard => \&_check_status_whiteboard, +sub VALIDATORS { + my $validators = { + alias => \&_check_alias, + bug_file_loc => \&_check_bug_file_loc, + bug_severity => \&_check_bug_severity, + cc => \&_check_cc, + deadline => \&_check_deadline, + estimated_time => \&_check_estimated_time, + op_sys => \&_check_op_sys, + priority => \&_check_priority, + product => \&_check_product, + remaining_time => \&_check_remaining_time, + rep_platform => \&_check_rep_platform, + short_desc => \&_check_short_desc, + status_whiteboard => \&_check_status_whiteboard, + }; + + my @select_fields = Bugzilla->get_fields({custom => 1, obsolete => 0, + type => FIELD_TYPE_SINGLE_SELECT}); + + foreach my $field (@select_fields) { + $validators->{$field->name} = \&_check_select_field; + } + return $validators; }; # Used in LogActivityEntry(). Gives the max length of lines in the @@ -279,7 +289,7 @@ sub run_create_validators { $params->{remaining_time} = $params->{estimated_time}; $class->_check_strict_isolation($product, $params->{cc}, - $params->{assigned_to}, $params->{qa_contact}); + $params->{assigned_to}, $params->{qa_contact}); return $params; } @@ -657,6 +667,12 @@ sub _check_version { return $version; } +sub _check_select_field { + my ($invocant, $value, $field) = @_; + $value = trim($value); + check_field($field, $value); + return $value; +} ##################################################################### # Class Accessors -- cgit v1.2.3-24-g4f1b