aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-10-03 06:28:31 +0000
committermkanat%bugzilla.org <>2008-10-03 06:28:31 +0000
commit931bd3b651ccca832a618f7b28bbc35e503665d4 (patch)
tree44518a36cc628b44c329319501fcb8e402c72d97 /editvalues.cgi
parentBug 453459: Bug pages no longer added to bfcache due to unload listener on Wi... (diff)
downloadbugzilla-931bd3b651ccca832a618f7b28bbc35e503665d4.tar.gz
bugzilla-931bd3b651ccca832a618f7b28bbc35e503665d4.tar.bz2
bugzilla-931bd3b651ccca832a618f7b28bbc35e503665d4.zip
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 'editvalues.cgi')
-rwxr-xr-xeditvalues.cgi55
1 files changed, 6 insertions, 49 deletions
diff --git a/editvalues.cgi b/editvalues.cgi
index ffb7ce576..4525774e1 100755
--- a/editvalues.cgi
+++ b/editvalues.cgi
@@ -29,7 +29,7 @@ use Bugzilla::Config qw(:admin);
use Bugzilla::Token;
use Bugzilla::Field;
use Bugzilla::Bug;
-use Bugzilla::Status;
+use Bugzilla::Status qw(SPECIAL_STATUS_WORKFLOW_ACTIONS);
# List of different tables that contain the changeable field values
# (the old "enums.") Keep them in alphabetical order by their
@@ -172,12 +172,8 @@ trick_taint($field);
sub display_field_values {
my $template = Bugzilla->template;
my $field = $vars->{'field'}->name;
- my $fieldvalues =
- Bugzilla->dbh->selectall_arrayref("SELECT value AS name, sortkey"
- . " FROM $field ORDER BY sortkey, value",
- {Slice =>{}});
- $vars->{'values'} = $fieldvalues;
+ $vars->{'values'} = $vars->{'field'}->legal_values;
$vars->{'default'} = Bugzilla->params->{$defaults{$field}} if defined $defaults{$field};
$vars->{'static'} = $static{$field} if exists $static{$field};
@@ -212,53 +208,14 @@ if ($action eq 'add') {
if ($action eq 'new') {
check_token_data($token, 'add_field_value');
- # Cleanups and validity checks
- $value || ThrowUserError('fieldvalue_undefined');
-
- if (length($value) > 60) {
- ThrowUserError('fieldvalue_name_too_long',
- {'value' => $value});
- }
- # Need to store in case detaint_natural() clears the sortkey
- my $stored_sortkey = $sortkey;
- if (!detaint_natural($sortkey)) {
- ThrowUserError('fieldvalue_sortkey_invalid',
- {'name' => $field,
- 'sortkey' => $stored_sortkey});
- }
- if (ValueExists($field, $value)) {
- ThrowUserError('fieldvalue_already_exists',
- {'field' => $field_obj,
- 'value' => $value});
- }
- if ($field eq 'bug_status'
- && (grep { lc($value) eq $_ } SPECIAL_STATUS_WORKFLOW_ACTIONS))
- {
- $vars->{'value'} = $value;
- ThrowUserError('fieldvalue_reserved_word', $vars);
- }
-
- # Value is only used in a SELECT placeholder and through the HTML filter.
- trick_taint($value);
-
- # Add the new field value.
- $dbh->do("INSERT INTO $field (value, sortkey) VALUES (?, ?)",
- undef, ($value, $sortkey));
-
- if ($field eq 'bug_status') {
- unless ($cgi->param('is_open')) {
- # The bug status is a closed state, but they are open by default.
- $dbh->do('UPDATE bug_status SET is_open = 0 WHERE value = ?', undef, $value);
- }
- # Allow the transition from this new bug status to the one used
- # by the 'duplicate_or_move_bug_status' parameter.
- Bugzilla::Status::add_missing_bug_status_transitions();
- }
+ my $created_value = Bugzilla::Field::Choice->type($field_obj)->create(
+ { value => $value, sortkey => $sortkey,
+ is_open => scalar $cgi->param('is_open') });
delete_token($token);
$vars->{'message'} = 'field_value_created';
- $vars->{'value'} = $value;
+ $vars->{'value'} = $created_value->name;
display_field_values();
}