diff options
author | mkanat%bugzilla.org <> | 2007-07-13 23:02:57 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-07-13 23:02:57 +0200 |
commit | e3837b96c71158697052cd72f253f910ae7f79dc (patch) | |
tree | 765d03eb8b347d5458d7f1ed7fbb2073bd16b93f /Bugzilla | |
parent | 5ab86735ff66381698b1e8e0bc587970dacc69fe (diff) | |
download | bugzilla-e3837b96c71158697052cd72f253f910ae7f79dc.tar.gz bugzilla-e3837b96c71158697052cd72f253f910ae7f79dc.tar.xz |
Bug 388022: Use Bugzilla::Bug to set/update custom fields in process_bug.cgi
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index da9e9a6b3..60fd18bb6 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -133,12 +133,19 @@ sub VALIDATORS { 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; + # Set up validators for custom fields. + my @custom_fields = Bugzilla->get_fields({custom => 1, obsolete => 0}); + foreach my $field (@custom_fields) { + my $validator; + if ($field->type == FIELD_TYPE_SINGLE_SELECT) { + $validator = \&_check_select_field; + } + else { + $validator = \&_check_freetext_field; + } + $validators->{$field->name} = $validator; } + return $validators; }; @@ -147,18 +154,22 @@ use constant UPDATE_VALIDATORS => { resolution => \&_check_resolution, }; -use constant UPDATE_COLUMNS => qw( - everconfirmed - bug_file_loc - bug_severity - bug_status - op_sys - priority - rep_platform - resolution - short_desc - status_whiteboard -); +sub UPDATE_COLUMNS { + my @columns = qw( + everconfirmed + bug_file_loc + bug_severity + bug_status + op_sys + priority + rep_platform + resolution + short_desc + status_whiteboard + ); + push(@columns, Bugzilla->custom_field_names); + return @columns; +}; # This is used by add_comment to know what we validate before putting in # the DB. @@ -896,6 +907,8 @@ sub _check_estimated_time { return $_[0]->_check_time($_[1], 'estimated_time'); } +sub _check_freetext_field { return defined $_[1] ? trim($_[1]) : ''; } + sub _check_groups { my ($invocant, $product, $group_ids) = @_; @@ -1169,6 +1182,11 @@ sub _set_global_validator { # "Set" Methods # ################# +sub set_custom_field { + my ($self, $field, $value) = @_; + ThrowCodeError('field_not_custom', { field => $field }) if !$field->custom; + $self->set($field->name, $value); +} sub set_dependencies { my ($self, $dependson, $blocked) = @_; ($dependson, $blocked) = $self->_check_dependencies($dependson, $blocked); |