From 33cf2dbff6ca196c9c9c681b280a702c08349bf2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 6 Jun 2005 05:30:12 +0000 Subject: [PATCH] r242: Biggest hack ever to get custom checkboxes to be logged if they have not been written to before and the user unticks them by default. --- editreport.php | 29 +++++++++++++++++++++++++---- showhistory.php | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/editreport.php b/editreport.php index 3f49d17..5c7808f 100644 --- a/editreport.php +++ b/editreport.php @@ -69,8 +69,8 @@ if ($_POST['do'] == 'update') $message->error('invalid product/component/version'); } - $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); - $hist2[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); + $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); + $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); process_custom_fields($bug['bugid']); @@ -97,8 +97,8 @@ if ($_POST['do'] == 'update') // ------------------------------------------------------------------- // do diff history - $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); - $hist2[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); + $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); + $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); $diff[0] = array_diff_assoc($hist[0], $hist[1]); $diff[1] = array_diff_assoc($hist[1], $hist[0]); @@ -153,11 +153,32 @@ if ($_POST['do'] == 'update') $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]); $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]); + if ($noinitialcustom === false) + { + $canallowempty = true; + $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield WHERE type = 'input_checkbox'"); + while ($box = $db->fetch_array($checkbox)) + { + $boxlist[] = $box['shortname']; + } + } + foreach ($diff2[1] AS $key => $value) { + if (in_array($key, $boxlist) AND $canallowempty) + { + $log->allowempty = true; + } + else + { + $log->allowempty = false; + } + $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"])); } + $log->allowempty = false; + // ------------------------------------------------------------------- // process comment stuff diff --git a/showhistory.php b/showhistory.php index e1ba3c6..459687c 100644 --- a/showhistory.php +++ b/showhistory.php @@ -74,7 +74,7 @@ foreach ($logs AS $dateline => $logitems) $messages = array(); foreach ($logitems AS $log) { - $hasvalues = ((empty($log['original']) AND empty($log['changed'])) ? false : true); + $hasvalues = ((empty($log['original']) AND (empty($log['changed']) AND $log['changed'] != 0)) ? false : true); if (preg_match('#^custom_#', $log['field'])) { -- 2.43.5