From 58c859c6defad6d5d9854ede9b599181e2679cb4 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 17 Sep 2006 18:23:35 +0000 Subject: [PATCH] r1161: - Updates to process_custom_fields() to now handle new bugs - Process custom fields on newreport.php --- editreport.php | 2 +- includes/functions.php | 36 ++++++++++++++++++++++++++++++++---- newreport.php | 4 ++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/editreport.php b/editreport.php index d92ed30..f6f22f5 100644 --- a/editreport.php +++ b/editreport.php @@ -219,7 +219,7 @@ if ($_POST['do'] == 'update') $log->add_data(false, $bugapi->values, $bugfields); - process_custom_fields($bug['bugid']); + process_custom_fields($bug['bugid'], $message, false); $bugapi->update(); diff --git a/includes/functions.php b/includes/functions.php index c1289bc..03a12be 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -330,8 +330,20 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau return $fieldbits; } -// ################### Start process_custom_fields ################### -function process_custom_fields($bugid, $inputdata = array()) +// ################################################################### +/** +* This takes the bug ID and input data and then sanitizes, verifies, +* and processes the data for custom fields. If there are any errors, +* they are passed to the message reporter. +* +* @param integer The bug ID; if NULL, then it returns a query that needs to have %1$s replaced with the bug ID, otherwise it executes the query itself +* @param object MessageReporter object +* @param bool If there are errors, add them to an errorbox format? If not, then display-on-encounter +* @param array If you don't want to get the data from $bugsys->in[], then an optional input source +* +* @return mixed NULL if an ID is passed, string if bugid is NULL +*/ +function process_custom_fields($bugid, $msg, $errorbox = false, $inputdata = array()) { global $bugsys; @@ -394,7 +406,17 @@ function process_custom_fields($bugid, $inputdata = array()) if ($errorlist) { - return $errorlist; + if ($errorbox) + { + foreach ($errorlist AS $err) + { + $msg->add_error($err); + } + } + else + { + $msg->error($errorlist[0]); + } } if (sizeof($fieldbuild) < 1) @@ -402,7 +424,13 @@ function process_custom_fields($bugid, $inputdata = array()) return; } - $bugsys->db->query("REPLACE INTO " . TABLE_PREFIX . "bugvaluefill (bugid, " . implode(', ', $fieldbuild) . ") VALUES ($bugid, " . implode(', ', $fieldvalue) . ")"); + $query = "REPLACE INTO " . TABLE_PREFIX . "bugvaluefill (bugid, " . implode(', ', $fieldbuild) . ") VALUES (%1$s, " . implode(', ', $fieldvalue) . ")"; + if ($bugid === null) + { + return $query; + } + + $bugsys->db->query(sprintf($query, $bugid)); } // ####################### Start fetch_on_bits ####################### diff --git a/newreport.php b/newreport.php index 4e94f3d..4aefdaa 100755 --- a/newreport.php +++ b/newreport.php @@ -101,6 +101,8 @@ if ($_POST['do'] == 'insert') $bug->set('component', $pcv['component']); $bug->set('version', $pcv['version']); + $cfields = process_custom_fields(null, $message, true); + if (!$message->items) { $bug->insert(); @@ -125,6 +127,8 @@ if ($_POST['do'] == 'insert') $bug->set('hiddenlastpostbyname', $bugsys->userinfo['displayname']); $bug->update(); + $db->query(sprintf($cfields, $comment->values['bugid'])); + $notif->set_bug_data($bug->objdata); $notif->finalize(); -- 2.43.5