r433: Merging the locale-change branch onto trunk; we now use ISSO's localize system
[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 define('SVN', '$Id$');
20
21 $focus['showreport'] = 'focus';
22
23 require_once('./global.php');
24
25 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']));
26 if (!$bug)
27 {
28 $message->error($lang->getlex('error_invalid_id'));
29 }
30
31 if ($bug['hidden'] AND !can_perform('canviewhidden'))
32 {
33 $message->error_permission();
34 }
35
36 // ###################################################################
37
38 $customfields = $db->query("
39 SELECT bugfield.*
40 FROM " . TABLE_PREFIX . "bugfield AS bugfield
41 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
42 ON (bugfield.fieldid = permission.fieldid)
43 WHERE permission.mask <> 0
44 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
45 );
46
47 while ($field = $db->fetch_array($customfields))
48 {
49 $fieldlist["custom_field$field[fieldid]"] = 'custom_field' . $field['fieldid'] . " (\"$field[name]\")";
50 }
51
52 // ###################################################################
53
54 $logs_fetch = $db->query("
55 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
56 FROM " . TABLE_PREFIX . "history AS history
57 LEFT JOIN " . TABLE_PREFIX . "user AS user
58 ON (user.userid = history.userid)
59 WHERE bugid = $bug[bugid]"
60 );
61 while ($log = $db->fetch_array($logs_fetch))
62 {
63 $log['formatted'] = call_user_func_array(array(lang, 'p'), array_merge(array($log['language']), unserialize($log['arguments'])));
64 $log['date'] = $datef->format($bugsys->options['dateformat'], $log['dateline']);
65 $log['user'] = construct_user_display($log);
66
67 $logs["$log[dateline]"]["$log[historyid]"] = $log;
68 ksort($logs["$log[dateline]"]);
69 }
70
71 ksort($logs);
72
73 foreach ($logs AS $dateline => $logitems)
74 {
75 $rowspan = 1;
76 $changes = '';
77 $show['changes'] = false;
78 $messages = array();
79 foreach ($logitems AS $log)
80 {
81 $hasvalues = ((empty($log['original']) AND (empty($log['changed']) AND $log['changed'] != '0')) ? false : true);
82
83 if ($newlog = $fieldlist["$log[field]"])
84 {
85 $log['field'] = $newlog;
86 }
87
88 $show['changes'] = (($hasvalues) ? true : $show['changes']);
89
90 if ($hasvalues)
91 {
92 $rowspan++;
93 eval('$changes .= "' . $template->fetch('history_bit') . '";');
94 }
95
96 if (!in_array($log['formatted'], $messages))
97 {
98 $messages[] = $log['formatted'];
99 }
100 }
101
102 $log['messages'] = implode("<br />\n", $messages);
103
104 eval('$history .= "' . $template->fetch('history_group') . '";');
105 }
106
107 eval('$template->flush("' . $template->fetch('history') . '");');
108
109 /*=====================================================================*\
110 || ###################################################################
111 || # $HeadURL$
112 || # $Id$
113 || ###################################################################
114 \*=====================================================================*/
115 ?>