From ceda1143cdaeffd0c4731fb719f6a2e44cf3c512 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 May 2005 03:34:28 +0000 Subject: [PATCH] r203: - Custom field `select_single` now is stored as a string instead of an integer representation of the string in the $field['selects'][] array - construct_custom_fields() [includes/functions.php] now supports existing values in the $bug[] parameter --- includes/functions.php | 45 +++++++++-------------- showreport.php | 7 +--- templates/default/bugfield_input_text.tpl | 2 +- templates/default/bugfield_textarea.tpl | 2 +- 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index b4e4c37..505b3c0 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -344,6 +344,15 @@ function construct_custom_fields($bug = array()) foreach ($fields AS $field) { + if (!is_null($bug["$field[shortname]"])) + { + $value = $bug["$field[shortname]"]; + } + else + { + $value = $field['defaultvalue']; + } + switch ($field['type']) { case 'input_text': @@ -355,47 +364,26 @@ function construct_custom_fields($bug = array()) break; case 'input_checkbox': - $selected = (($field['defaultvalue']) ? ' checked="checked"' : ''); + $selected = (($value) ? ' checked="checked"' : ''); eval('$tempfield = "' . $bugsys->template->fetch('bugfield_input_checkbox') . '";'); break; case 'select_single': $selects = unserialize($field['selects']); - - if ($lookfor = $bug["$field[shortname]"]) - { - if (in_array($lookfor, $selects)) - { - $canfind = true; - } - else - { - $canfind = false; - } - } - else - { - $canfind = false; - } + $value = trim($value); $options = ''; foreach ($selects AS $id => $select) { $selected = ''; $select = trim($select); - if ($canfind) + if ($select == $value) { - if ($id == $lookfor) - { - $selected = ' selected="selected"'; - } + $selected = ' selected="selected"'; } - else + else if ($field['usedef'] AND $id == 0) { - if ($field['usedef'] AND $id == 0) - { - $selected = ' selected="selected"'; - } + $selected = ' selected="selected"'; } eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); } @@ -451,7 +439,8 @@ function process_custom_fields($bugid, $inputdata = array()) } else { - $fieldvalue[] = intval($inputdata["$field[shortname]"]); + $temp = unserialize($field['selects']); + $fieldvalue[] = "'" . trim($temp[ intval($inputdata["$field[shortname]"]) ]) . "'"; } } } diff --git a/showreport.php b/showreport.php index c7acabc..50406a0 100644 --- a/showreport.php +++ b/showreport.php @@ -84,7 +84,7 @@ foreach ($fieldvalues AS $shortname => $value) $value = $field['defaultvalue']; } - if ($field['type'] == 'input_text' OR $field['type'] == 'textarea') + if ($field['type'] == 'input_text' OR $field['type'] == 'textarea' OR $field['type'] == 'select_single') { $customfields .= $value; } @@ -92,11 +92,6 @@ foreach ($fieldvalues AS $shortname => $value) { $customfields .= (($value) ? 'True' : 'False'); } - else - { - $temp = unserialize($field['selects']); - $customfields .= $temp["$value"]; - } $customfields .= "\n\n"; } diff --git a/templates/default/bugfield_input_text.tpl b/templates/default/bugfield_input_text.tpl index e0d195d..d3d4146 100644 --- a/templates/default/bugfield_input_text.tpl +++ b/templates/default/bugfield_input_text.tpl @@ -1 +1 @@ -
$field[name]: maxlength="$field[maxlength] />
\ No newline at end of file +
$field[name]: maxlength="$field[maxlength] />
\ No newline at end of file diff --git a/templates/default/bugfield_textarea.tpl b/templates/default/bugfield_textarea.tpl index aecdf0b..e4211d8 100644 --- a/templates/default/bugfield_textarea.tpl +++ b/templates/default/bugfield_textarea.tpl @@ -1,3 +1,3 @@
$field[name]: -
+
\ No newline at end of file -- 2.22.5