2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 $fetchtemplates = array(
27 define('SVN', '$Id$');
29 $focus['showreport'] = 'focus';
31 require_once('./global.php');
32 require_once('./includes/api_user.php');
34 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = " . $bugsys->input_clean('bugid', TYPE_UINT
));
37 $message->error(L_INVALID_ID
);
40 if (!check_bug_permissions($bug))
42 $message->errorPermission();
45 $lookupfields = array(
47 'priority' => 'priority',
48 'severity' => 'severity',
49 'resolution' => 'resolution',
50 'version' => 'version',
52 'component' => 'title'
55 // ###################################################################
57 $customfields = $db->query("
59 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
60 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
61 ON (bugfield.fieldid = permission.fieldid)
62 WHERE permission.mask <> 0
63 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
66 while ($field = $db->fetch_array($customfields))
68 $fieldlist["$field[fieldid]"] = sprintf(_('Custom Field %1$s (%2$s)'), $field['fieldid'], $field['name']);
71 // ###################################################################
74 $logs_fetch = $db->query("
75 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
76 FROM " . TABLE_PREFIX
. "history AS history
77 LEFT JOIN " . TABLE_PREFIX
. "user AS user
78 ON (user.userid = history.userid)
79 WHERE bugid = $bug[bugid]"
81 while ($log = $db->fetch_array($logs_fetch))
83 $log['date'] = $datef->format($bugsys->options
['dateformat'], $log['dateline']);
84 $log['user'] = construct_user_display($log);
86 $logs["$log[dateline]"]["$log[historyid]"] = $log;
87 ksort($logs["$log[dateline]"]);
92 foreach ($logs AS $dateline => $logitems)
94 $show['group'] = true
;
96 foreach ($logitems AS $log)
98 if ($log['field'] == '.' OR ($log['original'] == '' AND $log['changed'] == ''))
103 $funct->exec_swap_bg('', 'altcolor');
104 $bgcolor = $funct->bgcolour
;
106 if (preg_match('#^(comment|attachment)\.(.*)#', $log['field'], $matches))
108 if ($matches[1] == 'comment')
110 $log['field'] = sprintf(_('Comment #%1$s %2$s'), $log['commentid'], ucwords($matches[2]));
112 else if ($matches[1] == 'attachment')
114 $log['field'] = sprintf(_('Attachment #2%1$s %2$s'), $log['attachmentid'], ucwords($matches[2]));
117 else if (preg_match('#^.?custom(.field)?([0-9]+?)#', $log['field'], $matches))
119 if ($fieldlist["$matches[2]"])
121 $log['field'] = $fieldlist["$matches[2]"];
124 else if (preg_match('#^\.(.*)#', $log['field'], $matches))
126 $log['field'] = ucwords($matches[1]);
128 if (isset($lookupfields["$matches[1]"]))
130 $lookup = $matches[1];
131 $log['original'] = $bugsys->datastore
["$lookup"]["$log[original]"][ $lookupfields["$lookup"] ];
132 $log['changed'] = $bugsys->datastore
["$lookup"]["$log[changed]"][ $lookupfields["$lookup"] ];
134 else if ($matches[1] == 'assignto' OR $matches[1] == 'assignedto')
136 if ($log['original'])
138 $user = new UserAPI($bugsys);
139 $user->set('userid', $log['original']);
140 $user->set_condition();
142 $log['original'] = construct_user_display($user->objdata
);
147 $user = new UserAPI($bugsys);
148 $user->set('userid', $log['changed']);
149 $user->set_condition();
151 $log['changed'] = construct_user_display($user->objdata
);
156 eval('$history .= "' . $template->fetch('history_bit') . '";');
157 $show['group'] = false
;
161 eval('$template->flush("' . $template->fetch('history') . '");');
163 /*=====================================================================*\
164 || ###################################################################
167 || ###################################################################
168 \*=====================================================================*/