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($lang->getlex('error_invalid_id'));
40 if (!check_bug_permissions($bug))
42 $message->error_permission();
45 $lookupfields = array(
47 'priority' => 'priority',
48 'severity' => 'severity',
49 'resolution' => 'resolution',
50 'version' => 'version',
51 'product' => 'product',
52 'component' => 'product'
54 $lookupkeys = array_keys($lookupfields);
56 // ###################################################################
58 $customfields = $db->query("
60 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
61 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
62 ON (bugfield.fieldid = permission.fieldid)
63 WHERE permission.mask <> 0
64 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
67 while ($field = $db->fetch_array($customfields))
69 $fieldlist["custom.field$field[fieldid]"] = sprintf(_('Custom Field %1$s (%2$s)'), $field['fieldid'], $field['name']);
72 // ###################################################################
75 $logs_fetch = $db->query("
76 SELECT history.*, user.userid, user.email, user.displayname, user.showemail
77 FROM " . TABLE_PREFIX
. "history AS history
78 LEFT JOIN " . TABLE_PREFIX
. "user AS user
79 ON (user.userid = history.userid)
80 WHERE bugid = $bug[bugid]"
82 while ($log = $db->fetch_array($logs_fetch))
84 $log['date'] = $datef->format($bugsys->options
['dateformat'], $log['dateline']);
85 $log['user'] = construct_user_display($log);
87 $logs["$log[dateline]"]["$log[historyid]"] = $log;
88 ksort($logs["$log[dateline]"]);
93 foreach ($logs AS $dateline => $logitems)
95 $show['group'] = true
;
97 foreach ($logitems AS $log)
99 if ($log['field'] == '.' OR ($log['original'] == '' AND $log['changed'] == ''))
104 $funct->exec_swap_bg('', $stylevar['alt_color']);
105 $bgcolor = $funct->bgcolour
;
107 if (preg_match('#^(comment|attachment)\.(.*)#', $log['field'], $matches))
109 if ($matches[1] == 'comment')
111 $log['field'] = sprintf(_('Comment #%1$s %2$s'), $log['commentid'], ucwords($matches[2]));
113 else if ($matches[1] == 'attachment')
115 $log['field'] = sprintf(_('Attachment #2%1$s %2$s'), $log['attachmentid'], ucwords($matches[2]));
118 else if (preg_match('#^custom.field([0-9]+?)#', $log['field'], $matches))
120 if ($fieldlist["$log[field]"])
122 $log['field'] = $fieldlist["$log[field]"];
125 else if (preg_match('#^\.(.*)#', $log['field'], $matches))
127 $log['field'] = ucwords($matches[1]);
129 if (in_array($matches[1], $lookupkeys))
131 $lookup = $lookupfields["$matches[1]"];
132 $log['original'] = $bugsys->datastore
[ $lookupfields["$lookup"] ]["$log[original]"]["$lookup"];
133 $log['changed'] = $bugsys->datastore
[ $lookupfields["$lookup"] ]["$log[changed]"]["$lookup"];
135 else if ($matches[1] == 'assignto' OR $matches[1] == 'assignedto')
137 if ($log['original'])
139 $user = new UserAPI($bugsys);
140 $user->set('userid', $log['original']);
141 $user->set_condition();
143 $log['original'] = construct_user_display($user->objdata
);
148 $user = new UserAPI($bugsys);
149 $user->set('userid', $log['changed']);
150 $user->set_condition();
152 $log['changed'] = construct_user_display($user->objdata
);
157 eval('$history .= "' . $template->fetch('history_bit') . '";');
158 $show['group'] = false
;
162 eval('$template->flush("' . $template->fetch('history') . '");');
164 /*=====================================================================*\
165 || ###################################################################
168 || ###################################################################
169 \*=====================================================================*/