From 545de49a156fb2975133418e9d9abc6969ffe0ee Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 28 May 2005 04:42:52 +0000 Subject: [PATCH] r200: - Show edit fields on editreport.php and editreport.tpl - Fields processed with process_custom_fields() [includes/functions.php] --- editreport.php | 8 ++++- includes/functions.php | 56 ++++++++++++++++++++++++++++++++ templates/default/editreport.tpl | 2 ++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/editreport.php b/editreport.php index 81ae2fb..dd445ab 100644 --- a/editreport.php +++ b/editreport.php @@ -18,10 +18,12 @@ $fetchtemplates = array( require_once('./global.php'); $bug = $db->query_first(" - SELECT bug.*, user.email, user.displayname, user.showemail + SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail FROM " . TABLE_PREFIX . "bug AS bug LEFT JOIN " . TABLE_PREFIX . "user AS user ON (bug.userid = user.userid) + LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill + ON (bug.bugid = bugvaluefill.bugid) WHERE bug.bugid = " . intval($bugsys->in['bugid']) ); @@ -79,6 +81,8 @@ if ($_POST['do'] == 'update') $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); + process_custom_fields($bug['bugid']); + $db->query(" UPDATE " . TABLE_PREFIX . "bug SET summary = '" . $bugsys->in['summary'] . "', @@ -200,6 +204,8 @@ if ($_REQUEST['do'] == 'edit') $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1"); + $customfields = construct_custom_fields($bug); + eval('$template->flush("' . $template->fetch('editreport') . '");'); } diff --git a/includes/functions.php b/includes/functions.php index 5eb9752..b4e4c37 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -408,6 +408,62 @@ function construct_custom_fields($bug = array()) return $fieldbits; } +// ################### Start process_custom_fields ################### +function process_custom_fields($bugid, $inputdata = array()) +{ + global $bugsys; + + if (!$inputdata) + { + $inputdata =& $bugsys->in; + } + + $fields = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield"); + while ($field = $bugsys->db->fetch_array($fields)) + { + if ($field['type'] == 'input_checkbox') + { + $fieldbuild[] = $field['shortname']; + if (isset($inputdata["$field[shortname]"])) + { + $fieldvalue[] = 1; + } + else + { + $fieldvalue[] = 0; + } + continue; + } + + if ($field['required'] AND empty($inputdata["$field[shortname]"])) + { + $errorlist[] = phrase('field_x_is_required', $field['name']); + continue; + } + + if (isset($inputdata["$field[shortname]"])) + { + $fieldbuild[] = $field['shortname']; + + if ($field['type'] == 'input_text' OR $field['type'] == 'textarea') + { + $fieldvalue[] = "'" . $inputdata["$field[shortname]"] . "'"; + } + else + { + $fieldvalue[] = intval($inputdata["$field[shortname]"]); + } + } + } + + if ($errorlist) + { + return $errorlist; + } + + $bugsys->db->query("REPLACE INTO " . TABLE_PREFIX . "bugvaluefill (bugid, " . implode(', ', $fieldbuild) . ") VALUES ($bugid, " . implode(', ', $fieldvalue) . ")"); +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/templates/default/editreport.tpl b/templates/default/editreport.tpl index add408a..2851d76 100644 --- a/templates/default/editreport.tpl +++ b/templates/default/editreport.tpl @@ -22,5 +22,7 @@
First Comment:
+$customfields +
\ No newline at end of file -- 2.43.5