From f478434c6231399ace697d15d6d26b296ec6aad9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 11 May 2006 05:12:41 +0000 Subject: [PATCH] r822: A lot of this is now working... except for those pesky versions --- showhistory.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/showhistory.php b/showhistory.php index a1312b3..918ec37 100644 --- a/showhistory.php +++ b/showhistory.php @@ -29,6 +29,7 @@ define('SVN', '$Id$'); $focus['showreport'] = 'focus'; require_once('./global.php'); +require_once('./includes/api_user.php'); $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid'])); if (!$bug) @@ -41,6 +42,18 @@ if (($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid'])) OR !ca $message->error_permission(); } +$lookupfields = array( + 'status' => 'status', + 'priority' => 'priority', + 'secerity' => 'severity', + 'resolution' => 'resolution', + 'versionid' => 'version', + 'version' => 'version', + 'productid' => 'product', + 'componentid' => 'product' +); +$lookupkeys = array_keys($lookupfields); + // ################################################################### $customfields = $db->query(" @@ -54,11 +67,12 @@ $customfields = $db->query(" while ($field = $db->fetch_array($customfields)) { - $fieldlist["custom_field$field[fieldid]"] = 'custom_field' . $field['fieldid'] . " (\"$field[name]\")"; + $fieldlist["custom.field$field[fieldid]"] = sprintf($lang->string('Custom Field %1$s (%2$s)'), $field['fieldid'], $field['name']); } // ################################################################### +$logs = array(); $logs_fetch = $db->query(" SELECT history.*, user.userid, user.email, user.displayname, user.showemail FROM " . TABLE_PREFIX . "history AS history @@ -83,12 +97,55 @@ foreach ($logs AS $dateline => $logitems) foreach ($logitems AS $log) { + if ($log['field'] == '.' OR ($log['original'] == '' AND $log['changed'] == '')) + { + continue; + } + $funct->exec_swap_bg('', $stylevar['alt_colour']); $bgcolour = $funct->bgcolour; - if ($newlog = $fieldlist["$log[field]"]) + if (preg_match('#^(comment|attachment)\.(.*)#', $log['field'], $matches)) + { + if ($matches[1] == 'comment') + { + $log['field'] = sprintf($lang->string('Comment #%1$s %2$s'), $log['commentid'], ucwords($matches[2])); + } + else if ($matches[1] == 'attachment') + { + $log['field'] = sprintf($lang->string('Attachment #2%1$s %2$s'), $log['attachmentid'], ucwords($matches[2])); + } + } + else if (preg_match('#^custom.field([0-9]+?)#', $log['field'], $matches)) + { + if ($fieldlist["$log[field]"]) + { + $log['field'] = $fieldlist["$log[field]"]; + } + } + else if (preg_match('#^\.(.*)#', $log['field'], $matches)) { - $log['field'] = $newlog; + $log['field'] = ucwords($matches[1]); + + if (in_array($matches[1], $lookupkeys)) + { + $log['original'] = $bugsys->datastore[ $lookupfields["$matches[1]"] ]["$log[original]"]["$matches[1]"]; + $log['changed'] = $bugsys->datastore[ $lookupfields["$matches[1]"] ]["$log[changed]"]["$matches[1]"]; + } + else if ($matches[1] == 'assignto' OR $matches[1] == 'assignedto') + { + $user = new UserAPI($bugsys); + $user->set('userid', $log['original']); + $user->set_condition(); + $user->fetch(); + $log['original'] = construct_user_display($user->objdata); + + $user = new UserAPI($bugsys); + $user->set('userid', $log['changed']); + $user->set_condition(); + $user->fetch(); + $log['changed'] = construct_user_display($user->objdata); + } } eval('$history .= "' . $template->fetch('history_bit') . '";'); -- 2.22.5