r206: Allow bugs to be hidden for security reasons or if they want to look deleted.
[bugdar.git] / showhistory.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'history',
15 'history_group',
16 'history_bit'
17 );
18
19 require_once('./global.php');
20
21 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']));
22 if (!$bug)
23 {
24 $message->error('alert: bad bug');
25 }
26
27 if ($bug['hidden'] AND !can_perform('canviewhiddenbugs'))
28 {
29 $message->error_permission();
30 }
31
32 // ###################################################################
33
34 $logs_fetch = $db->query("
35 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
36 FROM " . TABLE_PREFIX . "history AS history
37 LEFT JOIN " . TABLE_PREFIX . "user AS user
38 ON (user.userid = history.userid)
39 WHERE bugid = $bug[bugid]"
40 );
41 while ($log = $db->fetch_array($logs_fetch))
42 {
43 $log['formatted'] = call_user_func_array('phrase', array_merge(array($log['language']), unserialize($log['arguments'])));
44 $log['date'] = datelike('standard', $log['dateline']);
45 $log['user'] = construct_user_display($log);
46
47 $logs["$log[dateline]"]["$log[historyid]"] = $log;
48 ksort($logs["$log[dateline]"]);
49 }
50
51 ksort($logs);
52
53 foreach ($logs AS $dateline => $logitems)
54 {
55 $rowspan = 1;
56 $changes = '';
57 $show['changes'] = false;
58 $messages = array();
59 foreach ($logitems AS $log)
60 {
61 $hasvalues = ((empty($log['original']) AND empty($log['changed'])) ? false : true);
62 $show['changes'] = (($hasvalues) ? true : $show['changes']);
63
64 if ($hasvalues)
65 {
66 $rowspan++;
67 eval('$changes .= "' . $template->fetch('history_bit') . '";');
68 }
69
70 if (!in_array($log['formatted'], $messages))
71 {
72 $messages[] = $log['formatted'];
73 }
74 }
75
76 $log['messages'] = implode("</div>\n<div>", $messages);
77
78 eval('$history .= "' . $template->fetch('history_group') . '";');
79 }
80
81 eval('$template->flush("' . $template->fetch('history') . '");');
82
83 /*=====================================================================*\
84 || ###################################################################
85 || # $HeadURL$
86 || # $Id$
87 || ###################################################################
88 \*=====================================================================*/
89 ?>