From 6d3989de256be9fdb0c0119314c45560e7077765 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Mar 2007 17:47:05 +0000 Subject: [PATCH] r1500: In showhistory.php: - Enable multi-group support for custom fields - Do not show custom fields in the history if users don't have permission to see them - When we have a useless log (the very first empty checks at the top of the loop), kill them with a database query --- showhistory.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/showhistory.php b/showhistory.php index f79f88e..4c123c3 100644 --- a/showhistory.php +++ b/showhistory.php @@ -55,12 +55,13 @@ $lookupfields = array( // ################################################################### $customfields = $db->query(" - SELECT bugfield.* + SELECT bugfield.*, MAX(permission.mask) AS mask FROM " . TABLE_PREFIX . "bugfield AS bugfield LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission ON (bugfield.fieldid = permission.fieldid) - WHERE permission.mask <> 0 - AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}" + WHERE mask <> 0 + AND permission.usergroupid IN ({$bugsys->userinfo['usergroupid']}" . (sizeof($bugsys->userinfo['groupids']) != 0 ? ',' . implode(',', $bugsys->userinfo['groupids']) : '') . ") + GROUP BY (bugfield.fieldid)" ); while ($field = $db->fetch_array($customfields)) @@ -89,6 +90,8 @@ while ($log = $db->fetch_array($logs_fetch)) ksort($logs); +$toKill = array(); + foreach ($logs AS $dateline => $logitems) { $show['group'] = true; @@ -97,12 +100,10 @@ foreach ($logs AS $dateline => $logitems) { if ($log['field'] == '.' OR ($log['original'] == '' AND $log['changed'] == '')) { + $toKill[] = $log['historyid']; continue; } - $funct->exec_swap_bg('', 'altcolor'); - $bgcolor = $funct->bgcolour; - if (preg_match('#^(comment|attachment)\.(.*)#', $log['field'], $matches)) { if ($matches[1] == 'comment') @@ -120,6 +121,10 @@ foreach ($logs AS $dateline => $logitems) { $log['field'] = $fieldlist["$matches[2]"]; } + else + { + continue; + } } else if (preg_match('#^\.(.*)#', $log['field'], $matches)) { @@ -153,11 +158,20 @@ foreach ($logs AS $dateline => $logitems) } } + $funct->exec_swap_bg('', 'altcolor'); + $bgcolor = $funct->bgcolour; + eval('$history .= "' . $template->fetch('history_bit') . '";'); $show['group'] = false; } } +// we can now remove all useless logs +if (sizeof($toKill) > 0) +{ + $db->query("DELETE FROM " . TABLE_PREFIX . "history WHERE historyid IN (" . implode(',', $toKill) . ")"); +} + eval('$template->flush("' . $template->fetch('history') . '");'); /*=====================================================================*\ -- 2.43.5