r263: Got the hack for checkboxes to work again; had to do with an instance of 'short...
[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('canviewhidden'))
28 {
29 $message->error_permission();
30 }
31
32 // ###################################################################
33
34 $customfields = $db->query("
35 SELECT bugfield.*
36 FROM " . TABLE_PREFIX . "bugfield AS bugfield
37 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
38 ON (bugfield.fieldid = permission.fieldid)
39 WHERE permission.mask <> 0
40 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
41 );
42
43 while ($field = $db->fetch_array($customfields))
44 {
45 $fieldlist["custom_field$field[fieldid]"] = 'custom_field' . $field['fieldid'] . " (\"$field[name]\")";
46 }
47
48 // ###################################################################
49
50 $logs_fetch = $db->query("
51 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
52 FROM " . TABLE_PREFIX . "history AS history
53 LEFT JOIN " . TABLE_PREFIX . "user AS user
54 ON (user.userid = history.userid)
55 WHERE bugid = $bug[bugid]"
56 );
57 while ($log = $db->fetch_array($logs_fetch))
58 {
59 $log['formatted'] = call_user_func_array(array(lang, 'p'), array_merge(array($log['language']), unserialize($log['arguments'])));
60 $log['date'] = datelike('standard', $log['dateline']);
61 $log['user'] = construct_user_display($log);
62
63 $logs["$log[dateline]"]["$log[historyid]"] = $log;
64 ksort($logs["$log[dateline]"]);
65 }
66
67 ksort($logs);
68
69 foreach ($logs AS $dateline => $logitems)
70 {
71 $rowspan = 1;
72 $changes = '';
73 $show['changes'] = false;
74 $messages = array();
75 foreach ($logitems AS $log)
76 {
77 $hasvalues = ((empty($log['original']) AND (empty($log['changed']) AND $log['changed'] != '0')) ? false : true);
78
79 if ($newlog = $fieldlist["$log[field]"])
80 {
81 $log['field'] = $newlog;
82 }
83
84 $show['changes'] = (($hasvalues) ? true : $show['changes']);
85
86 if ($hasvalues)
87 {
88 $rowspan++;
89 eval('$changes .= "' . $template->fetch('history_bit') . '";');
90 }
91
92 if (!in_array($log['formatted'], $messages))
93 {
94 $messages[] = $log['formatted'];
95 }
96 }
97
98 $log['messages'] = implode("</div>\n<div>", $messages);
99
100 eval('$history .= "' . $template->fetch('history_group') . '";');
101 }
102
103 eval('$template->flush("' . $template->fetch('history') . '");');
104
105 /*=====================================================================*\
106 || ###################################################################
107 || # $HeadURL$
108 || # $Id$
109 || ###################################################################
110 \*=====================================================================*/
111 ?>