]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 369987: Display real field names in editvalues.cgi - Patch by Frédéric Buclin...
authorlpsolit%gmail.com <>
Wed, 30 May 2007 19:08:10 +0000 (19:08 +0000)
committerlpsolit%gmail.com <>
Wed, 30 May 2007 19:08:10 +0000 (19:08 +0000)
editvalues.cgi
template/en/default/admin/fieldvalues/confirm-delete.html.tmpl
template/en/default/admin/fieldvalues/create.html.tmpl
template/en/default/admin/fieldvalues/created.html.tmpl
template/en/default/admin/fieldvalues/deleted.html.tmpl
template/en/default/admin/fieldvalues/edit.html.tmpl
template/en/default/admin/fieldvalues/footer.html.tmpl
template/en/default/admin/fieldvalues/list.html.tmpl
template/en/default/admin/fieldvalues/updated.html.tmpl
template/en/default/global/user-error.html.tmpl

index fe1ad546a8e88332af239857eb8c9c37552ac5d3..c42e0d1428a6b4d33461d03013e9590adbee8e94 100755 (executable)
@@ -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;
index 4cd0014764310f03e37446c34caed9f8c15bc775..c5baf365882c19382630dc346b355cf0719e9a85 100644 (file)
   # 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 @@
 </tr>
 <tr>
   <td valign="top">Field Name:</td>
-  <td valign="top">[% field FILTER html %]</td>
+  <td valign="top">[% field.description FILTER html %]</td>
 </tr>
 <tr>
   <td valign="top">Field Value:</td>
@@ -49,9 +51,9 @@
   <td valign="top">[% terms.Bugs %]:</td>
   <td valign="top">
 [% IF bug_count %]
-  <a title="List of [% terms.bugs %] where '[% field FILTER html %]' is '
+  <a title="List of [% terms.bugs %] where '[% field.description FILTER html %]' is '
             [% value FILTER html %]'"
-     href="buglist.cgi?[% field FILTER url_quote %]=[%- value FILTER url_quote %]">[% bug_count FILTER html %]</a>
+     href="buglist.cgi?[% field.name FILTER url_quote %]=[%- value FILTER url_quote %]">[% bug_count FILTER html %]</a>
 [% ELSE %]
   None
 [% END %]
 [% IF (param_name.defined && Param(param_name) == value) || bug_count || (value_count == 1) %]
 
   <p>Sorry, but the '[% value FILTER html %]' value cannot be deleted
-  from the '[% field FILTER html %]' field for the following reason(s):</p>
+  from the '[% field.description FILTER html %]' field for the following reason(s):</p>
 
   <ul class="warningmessages">
     [% IF param_name.defined && Param(param_name) == value %]
       <li>'[% value FILTER html %]' is the default value for
-          the '[% field FILTER html %]' field.
+          the '[% field.description FILTER html %]' field.
           [% IF user.groups.tweakparams %]
             You first have to <a href="editparams.cgi?section=bugfields#
             [%- param_name FILTER url_quote %]">change the default value</a> for
@@ -85,8 +87,8 @@
             is 1 [% terms.bug %] 
           [% END %]
           with this field value. You must change the field value on
-          <a title="List of [% terms.bugs %] where '[% field FILTER html %]' is '[% value FILTER html %]'"
-             href="buglist.cgi?[% field FILTER url_quote %]=[% value FILTER url_quote %]">
+          <a title="List of [% terms.bugs %] where '[% field.description FILTER html %]' is '[% value FILTER html %]'"
+             href="buglist.cgi?[% field.name FILTER url_quote %]=[% value FILTER url_quote %]">
             [% IF bug_count > 1 %]
               those [% terms.bugs %] 
             [% ELSE %]
 
     [% IF value_count == 1 %]
       <li>'[% value FILTER html %]' is the last value for
-          '[%- field FILTER html %]', and so it can not be deleted.
+          '[%- field.description FILTER html %]', and so it can not be deleted.
     [% END %]
   </ul>
 
   <form method="post" action="editvalues.cgi">
     <input type="submit" value="Yes, delete" id="delete">
     <input type="hidden" name="action" value="delete">
-    <input type="hidden" name="field" value="[% field FILTER html %]">
+    <input type="hidden" name="field" value="[% field.name FILTER html %]">
     <input type="hidden" name="value" value="[% value FILTER html %]">
     <input type="hidden" name="token" value="[% token FILTER html %]">
   </form>
index 29bf857789d0868a2aed091d995cf051baae612e..9a0ac993e35b96b910997d564e5728aadd7bb28b 100644 (file)
   #%]
 
 [%# 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
 %]
 
+<p>
+  This page allows you to add a new value for the '[% field.description FILTER html %]' field.
+</p>
+
 <form method="post" action="editvalues.cgi">
   <table border="0" cellpadding="4" cellspacing="0">
     <tr>
@@ -41,7 +44,7 @@
   </table>
   <input type="submit" id="create" value="Add">
   <input type="hidden" name="action" value="new">
-  <input type="hidden" name='field' value="[% field FILTER html %]">
+  <input type="hidden" name='field' value="[% field.name FILTER html %]">
   <input type="hidden" name="token" value="[% token FILTER html %]">
 </form>
 
index 21847710375fa4e1658ce2a988a49a87a4ea7c40..b3d60f081684626fe36462e3af8dc95579950b4c 100644 (file)
 
 [%# 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
 %]
 
 <p>The value '<a title="Edit value '[% value FILTER html %]' of 
-   for the '[% field FILTER html %]' field"
+   for the '[% field.description FILTER html %]' field"
    href="editvalues.cgi?action=edit&amp;field=
-   [%- field FILTER url_quote %]&amp;value=[% value FILTER url_quote %]">
+   [%- field.name FILTER url_quote %]&amp;value=[% value FILTER url_quote %]">
    [%- value FILTER html %]</a>' has been added as a valid choice for
-   the '[% field FILTER html %]' field.</p>
+   the '[% field.description FILTER html %]' field.</p>
 
 [% PROCESS admin/fieldvalues/footer.html.tmpl %]
 
index c966897f68eab7374d3e653350e9ce8f29951f3f..4210800118a290cad84d9f9a963097cb9a30b8fc 100644 (file)
 [%# 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
 %]
index e19b7c0b58ae9a7563457e823035a47bc802f7e3..919ac090cd388dd6abb7f73b5623cd9da04b3422 100644 (file)
 [%# 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 @@
   <input type="hidden" name="valueold" value="[% value FILTER html %]">
   <input type="hidden" name="sortkeyold" value="[% sortkey FILTER html %]">
   <input type="hidden" name="action" value="update">
-  <input type="hidden" name="field" value="[% field FILTER html %]">
+  <input type="hidden" name="field" value="[% field.name FILTER html %]">
   <input type="hidden" name="token" value="[% token FILTER html %]">
   <input type="submit" id="update" value="Update">
 </form>
index 27428f66dd9cbaeddcafdf0d15bbc84ff020e436..4403762397f4f94516869a2ce3fd12e7a4c99160 100644 (file)
@@ -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:
 <p>
 
 [% UNLESS no_add_link %]
-  <a title="Add a value for the '[% field FILTER html %]' field."
+  <a title="Add a value for the '[% field.description FILTER html %]' field."
      href="editvalues.cgi?action=add&amp;field=
-          [%- field FILTER url_quote %]">Add</a> a value.
+          [%- field.name FILTER url_quote %]">Add</a> a value.
 [% END %]
 
 [% IF value && !no_edit_link %]
   Edit value <a 
   title="Edit value '[% value FILTER html %]' for the '
-         [%- field FILTER html %]' field"
+         [%- field.name FILTER html %]' field"
   href="editvalues.cgi?action=edit&amp;field=
-        [%- field FILTER url_quote %]&amp;value=[% value FILTER url_quote %]">
+        [%- field.name FILTER url_quote %]&amp;value=[% value FILTER url_quote %]">
         '[% value FILTER html %]'</a>.
 [% END %]
 
 [% UNLESS no_edit_other_link %]
   Edit other values for the <a 
   href="editvalues.cgi?field=
-        [%- field FILTER url_quote %]">'[% field FILTER html %]'</a> field.
+        [%- field.name FILTER url_quote %]">'[% field.description FILTER html %]'</a> field.
 
 [% END %]
 
index 9e3da3c64a0cd41ab3aaf59b7a2f8f1f6dd61509..dd96d4872cc13b1d684dc012099e18e19a228293 100644 (file)
@@ -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.
   #%]
 
 
 [% 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&amp;field=
-  [%- field FILTER url_quote %]&amp;value=%%name%%[% END %]
+  [%- field.name FILTER url_quote %]&amp;value=%%name%%[% END %]
 [% delete_contentlink = BLOCK %]editvalues.cgi?action=del&amp;field=
-  [%- field FILTER url_quote %]&amp;value=%%name%%[% END %]
+  [%- field.name FILTER url_quote %]&amp;value=%%name%%[% END %]
 
 
 [% columns = [
index 7b76abb6341e0409fd21072efc94594192f5812f..2cfb7de96d499684c07234b7882fa723cc4ef9ba 100644 (file)
   #
   # 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
 %]
index 615499426212aaf84849727cea33c8c0aa8a869a..9de2d03fc604d19c4fe20ebd220756ffd45e892b 100644 (file)
   [% 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" %]
   [% 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 <a href="editparams.cgi?section=bugfields#
       [%- param_name FILTER url_quote %]">change</a> the default value first.
   [% 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" %]