From 5371dcf03064519791d9549ba09ae00ba87527b5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 24 May 2005 05:40:03 +0000 Subject: [PATCH] r199: Completed the backend creation of the fields--it works with new bugs but it's untested with existing ones. --- global.php | 7 +- includes/functions.php | 84 +++++++++++++++++++ templates/default/bugfield_input_checkbox.tpl | 1 + templates/default/bugfield_input_text.tpl | 1 + templates/default/bugfield_select_single.tpl | 1 + .../default/bugfield_select_single_option.tpl | 1 + templates/default/bugfield_textarea.tpl | 3 + 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 templates/default/bugfield_input_checkbox.tpl create mode 100644 templates/default/bugfield_input_text.tpl create mode 100644 templates/default/bugfield_select_single.tpl create mode 100644 templates/default/bugfield_select_single_option.tpl create mode 100644 templates/default/bugfield_textarea.tpl diff --git a/global.php b/global.php index 9c7540e..03f3884 100755 --- a/global.php +++ b/global.php @@ -64,7 +64,12 @@ $globaltemplates = array( 'selectoptgroup', 'std_error', 'std_redirect', - 'std_message' + 'std_message', + 'bugfield_input_text', + 'bugfield_textarea', + 'bugfield_input_checkbox', + 'bugfield_select_single_option', + 'bugfield_select_single' ); $template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); diff --git a/includes/functions.php b/includes/functions.php index a16a841..5eb9752 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -324,6 +324,90 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte return $select; } +// ################## Start construct_custom_fields ################## +function construct_custom_fields($bug = array()) +{ + global $bugsys; + static $fields; + + if (!is_array($fields)) + { + $fields = array(); + $fields_fetch = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield"); + while ($field = $bugsys->db->fetch_array($fields_fetch)) + { + $fields["$field[fieldid]"] = $field; + } + } + + $fieldbits = ''; + + foreach ($fields AS $field) + { + switch ($field['type']) + { + case 'input_text': + eval('$tempfield = "' . $bugsys->template->fetch('bugfield_input_text') . '";'); + break; + + case 'textarea': + eval('$tempfield = "' . $bugsys->template->fetch('bugfield_textarea') . '";'); + break; + + case 'input_checkbox': + $selected = (($field['defaultvalue']) ? ' 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; + } + + $options = ''; + foreach ($selects AS $id => $select) + { + $selected = ''; + $select = trim($select); + if ($canfind) + { + if ($id == $lookfor) + { + $selected = ' selected="selected"'; + } + } + else + { + if ($field['usedef'] AND $id == 0) + { + $selected = ' selected="selected"'; + } + } + eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); + } + eval('$tempfield = "' . $bugsys->template->fetch('bugfield_select_single') . '";'); + break; + } + $fieldbits .= $tempfield; + } + + return $fieldbits; +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/templates/default/bugfield_input_checkbox.tpl b/templates/default/bugfield_input_checkbox.tpl new file mode 100644 index 0000000..693afe2 --- /dev/null +++ b/templates/default/bugfield_input_checkbox.tpl @@ -0,0 +1 @@ +
$field[name]:
\ No newline at end of file diff --git a/templates/default/bugfield_input_text.tpl b/templates/default/bugfield_input_text.tpl new file mode 100644 index 0000000..e0d195d --- /dev/null +++ b/templates/default/bugfield_input_text.tpl @@ -0,0 +1 @@ +
$field[name]: maxlength="$field[maxlength] />
\ No newline at end of file diff --git a/templates/default/bugfield_select_single.tpl b/templates/default/bugfield_select_single.tpl new file mode 100644 index 0000000..2f92034 --- /dev/null +++ b/templates/default/bugfield_select_single.tpl @@ -0,0 +1 @@ +
$field[name]:
\ No newline at end of file diff --git a/templates/default/bugfield_select_single_option.tpl b/templates/default/bugfield_select_single_option.tpl new file mode 100644 index 0000000..aaa9591 --- /dev/null +++ b/templates/default/bugfield_select_single_option.tpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/default/bugfield_textarea.tpl b/templates/default/bugfield_textarea.tpl new file mode 100644 index 0000000..aecdf0b --- /dev/null +++ b/templates/default/bugfield_textarea.tpl @@ -0,0 +1,3 @@ +
$field[name]: +
+
\ No newline at end of file -- 2.43.5