From: lpsolit%gmail.com <> Date: Wed, 30 May 2007 19:08:10 +0000 (+0000) Subject: Bug 369987: Display real field names in editvalues.cgi - Patch by Frédéric Buclin... X-Git-Tag: bugzilla-3.1.2~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e4bfa3f76d565dd27b4d1a8903430b7c0b14140;p=thirdparty%2Fbugzilla.git Bug 369987: Display real field names in editvalues.cgi - Patch by Frédéric Buclin r=ghendricks a=LpSolit --- diff --git a/editvalues.cgi b/editvalues.cgi index fe1ad546a8..c42e0d1428 100755 --- a/editvalues.cgi +++ b/editvalues.cgi @@ -27,6 +27,7 @@ use Bugzilla::Error; use Bugzilla::Constants; use Bugzilla::Config qw(:admin); use Bugzilla::Token; +use Bugzilla::Field; # List of different tables that contain the changeable field values # (the old "enums.") Keep them in alphabetical order by their @@ -63,13 +64,13 @@ sub FieldMustExist { # Is it a valid field to be editing? FieldExists($field) || ThrowUserError('fieldname_invalid', {'field' => $field}); + + return new Bugzilla::Field({name => $field}); } # Returns if the specified value exists for the field specified. sub ValueExists { my ($field, $value) = @_; - FieldMustExist($field); - trick_taint($field); # Value is safe because it's being passed only to a SELECT # statement via a placeholder. trick_taint($value); @@ -155,20 +156,19 @@ unless ($field) { exit; } +# At this point, the field is defined. +$vars->{'field'} = FieldMustExist($field); +trick_taint($field); # # action='' -> Show nice list of values. # unless ($action) { - FieldMustExist($field); - # Now we know the $field is valid. - trick_taint($field); - - my $fieldvalues = + my $fieldvalues = $dbh->selectall_arrayref("SELECT value AS name, sortkey" . " FROM $field ORDER BY sortkey, value", {Slice =>{}}); - $vars->{'field'} = $field; + $vars->{'values'} = $fieldvalues; $vars->{'default'} = Bugzilla->params->{$defaults{$field}} if defined $defaults{$field}; $vars->{'static'} = $static{$field} if exists $static{$field}; @@ -184,10 +184,7 @@ unless ($action) { # (next action will be 'new') # if ($action eq 'add') { - FieldMustExist($field); - $vars->{'value'} = $value; - $vars->{'field'} = $field; $vars->{'token'} = issue_session_token('add_field_value'); $template->process("admin/fieldvalues/create.html.tmpl", $vars) @@ -202,8 +199,6 @@ if ($action eq 'add') { # if ($action eq 'new') { check_token_data($token, 'add_field_value'); - FieldMustExist($field); - trick_taint($field); # Cleanups and validity checks $value || ThrowUserError('fieldvalue_undefined'); @@ -235,7 +230,6 @@ if ($action eq 'new') { delete_token($token); $vars->{'value'} = $value; - $vars->{'field'} = $field; $template->process("admin/fieldvalues/created.html.tmpl", $vars) || ThrowTemplateError($template->error()); @@ -250,7 +244,6 @@ if ($action eq 'new') { # if ($action eq 'del') { ValueMustExist($field, $value); - trick_taint($field); trick_taint($value); # See if any bugs are still using this value. @@ -261,7 +254,6 @@ if ($action eq 'del') { $dbh->selectrow_array("SELECT COUNT(*) FROM $field"); $vars->{'value'} = $value; - $vars->{'field'} = $field; $vars->{'param_name'} = $defaults{$field}; # If the value cannot be deleted, throw an error. @@ -286,7 +278,6 @@ if ($action eq 'delete') { ValueMustExist($field, $value); $vars->{'value'} = $value; - $vars->{'field'} = $field; $vars->{'param_name'} = $defaults{$field}; if (defined $defaults{$field} @@ -299,7 +290,6 @@ if ($action eq 'delete') { ThrowUserError('fieldvalue_not_deletable', $vars); } - trick_taint($field); trick_taint($value); $dbh->bz_lock_tables('bugs READ', "$field WRITE"); @@ -334,14 +324,12 @@ if ($action eq 'delete') { # if ($action eq 'edit') { ValueMustExist($field, $value); - trick_taint($field); trick_taint($value); $vars->{'sortkey'} = $dbh->selectrow_array( "SELECT sortkey FROM $field WHERE value = ?", undef, $value) || 0; $vars->{'value'} = $value; - $vars->{'field'} = $field; $vars->{'is_static'} = (lsearch($static{$field}, $value) >= 0) ? 1 : 0; $vars->{'token'} = issue_session_token('edit_field_value'); @@ -361,12 +349,9 @@ if ($action eq 'update') { my $sortkeyold = trim($cgi->param('sortkeyold') || '0'); ValueMustExist($field, $valueold); - trick_taint($field); trick_taint($valueold); $vars->{'value'} = $value; - $vars->{'field'} = $field; - # If the value cannot be renamed, throw an error. if (lsearch($static{$field}, $valueold) >= 0 && $value ne $valueold) { $vars->{'old_value'} = $valueold; diff --git a/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl b/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl index 4cd0014764..c5baf36588 100644 --- a/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl +++ b/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl @@ -19,13 +19,15 @@ # bug_count: number; The number of bugs that have this field value. # value_count: number; The number of values left for this field, including # this value. - # field: string; The name of the field. + # field: object; the field the value is being deleted from. # param_name: string; The name of the parameter (defaultxxx) associated # with the field. #%] -[% title = BLOCK %]Delete Value '[% value FILTER html %]' from the - '[% field FILTER html %]' field[% END %] +[% title = BLOCK %] + Delete Value '[% value FILTER html %]' from the '[% field.description FILTER html %]' + ([% field.name FILTER html %]) field +[% END %] [% PROCESS global/header.html.tmpl title = title @@ -39,7 +41,7 @@ Field Name: - [% field FILTER html %] + [% field.description FILTER html %] Field Value: @@ -49,9 +51,9 @@ [% terms.Bugs %]: [% IF bug_count %] - [% bug_count FILTER html %] + href="buglist.cgi?[% field.name FILTER url_quote %]=[%- value FILTER url_quote %]">[% bug_count FILTER html %] [% ELSE %] None [% END %] @@ -64,12 +66,12 @@ [% IF (param_name.defined && Param(param_name) == value) || bug_count || (value_count == 1) %]

Sorry, but the '[% value FILTER html %]' value cannot be deleted - from the '[% field FILTER html %]' field for the following reason(s):

+ from the '[% field.description FILTER html %]' field for the following reason(s):

@@ -109,7 +111,7 @@
- +
diff --git a/template/en/default/admin/fieldvalues/create.html.tmpl b/template/en/default/admin/fieldvalues/create.html.tmpl index 29bf857789..9a0ac993e3 100644 --- a/template/en/default/admin/fieldvalues/create.html.tmpl +++ b/template/en/default/admin/fieldvalues/create.html.tmpl @@ -15,17 +15,20 @@ #%] [%# INTERFACE: - # field: string; name of the field the value is being created for + # field: object; the field the value is being created for #%] -[% title = BLOCK %]Add Value for the '[% field FILTER html %]' field[% END %] -[% subheader = BLOCK %]This page allows you to add a new value for the - '[% field FILTER html %]' field.[% END %] +[% title = BLOCK %] + Add Value for the '[% field.description FILTER html %]' ([% field.name FILTER html %]) field +[% END %] [% PROCESS global/header.html.tmpl title = title - subheader = subheader %] +

+ This page allows you to add a new value for the '[% field.description FILTER html %]' field. +

+
@@ -41,7 +44,7 @@
- +
diff --git a/template/en/default/admin/fieldvalues/created.html.tmpl b/template/en/default/admin/fieldvalues/created.html.tmpl index 2184771037..b3d60f0816 100644 --- a/template/en/default/admin/fieldvalues/created.html.tmpl +++ b/template/en/default/admin/fieldvalues/created.html.tmpl @@ -16,21 +16,23 @@ [%# INTERFACE: # value: string; the name of the newly created field value - # field: string; the name of the field the value belongs to + # field: object; the field the value belongs to #%] -[% title = BLOCK %]New Value '[% value FILTER html %]' added to - '[% field FILTER html %]' field[% END %] +[% title = BLOCK %] + New Value '[% value FILTER html %]' added to '[% field.description FILTER html %]' + ([% field.name FILTER html %]) field +[% END %] [% PROCESS global/header.html.tmpl title = title %]

The value ' + [%- field.name FILTER url_quote %]&value=[% value FILTER url_quote %]"> [%- value FILTER html %]' has been added as a valid choice for - the '[% field FILTER html %]' field.

+ the '[% field.description FILTER html %]' field.

[% PROCESS admin/fieldvalues/footer.html.tmpl %] diff --git a/template/en/default/admin/fieldvalues/deleted.html.tmpl b/template/en/default/admin/fieldvalues/deleted.html.tmpl index c966897f68..4210800118 100644 --- a/template/en/default/admin/fieldvalues/deleted.html.tmpl +++ b/template/en/default/admin/fieldvalues/deleted.html.tmpl @@ -17,12 +17,14 @@ [%# INTERFACE: # value: string; the field value that was deleted. # - # field: string; the field the value was deleted from. + # field: object; the field the value was deleted from. # #%] -[% title = BLOCK %]Deleted Value '[% value FILTER html %]' for the - '[% field FILTER html %]' Field[% END %] +[% title = BLOCK %] + Deleted Value '[% value FILTER html %]' for the '[% field.description FILTER html %]' + ([% field.name FILTER html %]) Field +[% END %] [% PROCESS global/header.html.tmpl title = title %] diff --git a/template/en/default/admin/fieldvalues/edit.html.tmpl b/template/en/default/admin/fieldvalues/edit.html.tmpl index e19b7c0b58..919ac090cd 100644 --- a/template/en/default/admin/fieldvalues/edit.html.tmpl +++ b/template/en/default/admin/fieldvalues/edit.html.tmpl @@ -17,13 +17,15 @@ [%# INTERFACE: # value: string; The field value we are editing. # sortkey: number; Sortkey of the field value we are editing. - # field: string; The field this value belongs to. + # field: object; The field this value belongs to. #%] [% PROCESS global/variables.none.tmpl %] -[% title = BLOCK %]Edit Value '[% value FILTER html %]' ' - [%- field FILTER html %]'[% END %] +[% title = BLOCK %] + Edit Value '[% value FILTER html %]' for the '[% field.description FILTER html %]' + ([% field.name FILTER html %]) field +[% END %] [% PROCESS global/header.html.tmpl title = title %] @@ -54,7 +56,7 @@ - + diff --git a/template/en/default/admin/fieldvalues/footer.html.tmpl b/template/en/default/admin/fieldvalues/footer.html.tmpl index 27428f66dd..4403762397 100644 --- a/template/en/default/admin/fieldvalues/footer.html.tmpl +++ b/template/en/default/admin/fieldvalues/footer.html.tmpl @@ -16,8 +16,7 @@ [%# INTERFACE: # value: string; the value being inserted/edited. - # field: string; the name of the field which the value - # belongs/belonged to + # field: object; the field which the value belongs/belonged to. # # no_XXX_link: boolean; if defined, then don't show the corresponding # link. Supported parameters are: @@ -32,24 +31,24 @@

[% UNLESS no_add_link %] - Add a value. + [%- field.name FILTER url_quote %]">Add a value. [% END %] [% IF value && !no_edit_link %] Edit value + [%- field.name FILTER url_quote %]&value=[% value FILTER url_quote %]"> '[% value FILTER html %]'. [% END %] [% UNLESS no_edit_other_link %] Edit other values for the '[% field FILTER html %]' field. + [%- field.name FILTER url_quote %]">'[% field.description FILTER html %]' field. [% END %] diff --git a/template/en/default/admin/fieldvalues/list.html.tmpl b/template/en/default/admin/fieldvalues/list.html.tmpl index 9e3da3c64a..dd96d4872c 100644 --- a/template/en/default/admin/fieldvalues/list.html.tmpl +++ b/template/en/default/admin/fieldvalues/list.html.tmpl @@ -20,7 +20,7 @@ # - sortkey: number; The sortkey used to order the value when # displayed to the user in a list. # - # field: string; the name of the field we are editing values for. + # field: object; the field we are editing values for. # static: array; list of values which cannot be renamed nor deleted. #%] @@ -29,16 +29,16 @@ [% PROCESS global/variables.none.tmpl %] -[% title = BLOCK %]Select value for the - '[% field FILTER html %]' field[% END %] +[% title = BLOCK %]Select value for the '[% field.description FILTER html %]' + ([% field.name FILTER html %]) field[% END %] [% PROCESS global/header.html.tmpl title = title %] [% edit_contentlink = BLOCK %]editvalues.cgi?action=edit&field= - [%- field FILTER url_quote %]&value=%%name%%[% END %] + [%- field.name FILTER url_quote %]&value=%%name%%[% END %] [% delete_contentlink = BLOCK %]editvalues.cgi?action=del&field= - [%- field FILTER url_quote %]&value=%%name%%[% END %] + [%- field.name FILTER url_quote %]&value=%%name%%[% END %] [% columns = [ diff --git a/template/en/default/admin/fieldvalues/updated.html.tmpl b/template/en/default/admin/fieldvalues/updated.html.tmpl index 7b76abb634..2cfb7de96d 100644 --- a/template/en/default/admin/fieldvalues/updated.html.tmpl +++ b/template/en/default/admin/fieldvalues/updated.html.tmpl @@ -23,13 +23,15 @@ # # value & updated_value: the name of the field value # sortkey & updated_sortkey: the field value sortkey - # field: string; the field that the value belongs to + # field: object; the field that the value belongs to # default_value_updated: boolean; whether the default value for # this field has been updated #%] -[% title = BLOCK %]Updating Value '[% value FILTER html %]' of the - '[% field FILTER html %]' Field[% END %] +[% title = BLOCK %] + Updating Value '[% value FILTER html %]' of the '[% field.description FILTER html %]' + ([% field.name FILTER html %]) Field +[% END %] [% PROCESS global/header.html.tmpl title = title %] diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 6154994262..9de2d03fc6 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -424,7 +424,7 @@ [% ELSIF error == "fieldvalue_already_exists" %] [% title = "Field Value Already Exists" %] The value '[% value FILTER html %]' already exists for the - '[%- field FILTER html %]' field. + '[%- field.description FILTER html %]' field. [% ELSIF error == "fieldvalue_doesnt_exist" %] [% title = "Specified Field Value Does Not Exist" %] @@ -434,7 +434,7 @@ [% ELSIF error == "fieldvalue_is_default" %] [% title = "Specified Field Value Is Default" %] '[% value FILTER html %]' is the default value for - the '[% field FILTER html %]' field and cannot be deleted. + the '[% field.description FILTER html %]' field and cannot be deleted. [% IF user.groups.tweakparams %] You have to change the default value first. @@ -448,12 +448,12 @@ [% ELSIF error == "fieldvalue_not_editable" %] [% title = "Field Value Not Editable" %] The value '[% old_value FILTER html %]' cannot be renamed because - it plays some special role for the '[% field FILTER html %]' field. + it plays some special role for the '[% field.description FILTER html %]' field. [% ELSIF error == "fieldvalue_not_deletable" %] [% title = "Field Value Not Deletable" %] The value '[% value FILTER html %]' cannot be removed because - it plays some special role for the '[% field FILTER html %]' field. + it plays some special role for the '[% field.description FILTER html %]' field. [% ELSIF error == "fieldvalue_not_specified" %] [% title = "Field Value Not Specified" %]