]>
src.bluestatic.org Git - bugdar.git/blob - showhistory.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 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 2 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->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $input->inputClean('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("
58 SELECT bugfield.*, MAX(permission.mask) AS mask
59 FROM " . TABLE_PREFIX . "bugfield AS bugfield
60 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
61 ON (bugfield.fieldid = permission.fieldid)
63 AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid
'] . (sizeof(bugdar::$userinfo['groupids
']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids
']) : '') . ")
64 GROUP BY (bugfield.fieldid)"
67 foreach ($customfields as $field)
69 $fieldlist["$field[fieldid]"] = sprintf(T('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 foreach ($logs_fetch as $log)
84 $log['date
'] = $datef->format(bugdar::$options['dateformat
'], $log['dateline
']);
85 $log['user
'] = construct_user_display($log);
87 $logs["$log[dateline]"]["$log[historyid]"] = $log;
88 ksort($logs["$log[dateline]"]);
95 foreach ($logs AS $dateline => $logitems)
97 $show['group
'] = true;
100 foreach ($logitems AS $log)
102 if ($log['field
'] == '.' OR ($log['original
'] == '' AND $log['changed
'] == ''))
104 $toKill[] = $log['historyid
'];
108 if (preg_match('#^(comment|attachment)\.(.*)#', $log['field'], $matches))
110 if ($matches[1] == 'comment')
112 $log['field'] = sprintf(T('Comment #%1$s %2$s'), $log['commentid
'], ucwords($matches[2]));
114 else if ($matches[1] == 'attachment
')
116 $log['field
'] = sprintf(T('Attachment
#2%1$s %2$s'), $log['attachmentid'], ucwords($matches[2]));
119 else if (preg_match('#^.?custom(.field)?([0-9]+?)#', $log['field'], $matches))
121 if ($fieldlist["$matches[2]"])
123 $log['field'] = $fieldlist["$matches[2]"];
130 else if (preg_match('#^\.(.*)#', $log['field'], $matches))
132 $log['field'] = ucwords($matches[1]);
134 if (isset($lookupfields["$matches[1]"]))
136 $lookup = $matches[1];
137 $log['original'] = bugdar
::$datastore["$lookup"]["$log[original
]"][ $lookupfields["$lookup"] ];
138 $log['changed'] = bugdar
::$datastore["$lookup"]["$log[changed
]"][ $lookupfields["$lookup"] ];
140 else if ($matches[1] == 'assignto' OR $matches[1] == 'assignedto')
142 if ($log['original'])
144 $user = new UserAPI();
145 $user->set('userid', $log['original']);
146 $user->setCondition();
148 $log['original'] = construct_user_display($user->record
);
153 $user = new UserAPI();
154 $user->set('userid', $log['changed']);
155 $user->setCondition();
157 $log['changed'] = construct_user_display($user->record
);
162 BSFunctions
::swap_css_classes('', 'altcolor');
164 $tpl = new BSTemplate('history_bit');
166 'bgcolor' => BSFunctions
::$cssClass,
169 $history .= $tpl->evaluate()->getTemplate();
170 $show['group'] = false;
174 // we can now remove all useless logs
175 if (sizeof($toKill) > 0)
177 $db->query("DELETE FROM " . TABLE_PREFIX
. "history WHERE historyid IN (" . implode(',', $toKill) . ")");
180 $tpl = new BSTemplate('history');
182 'history' => $history,
185 $tpl->evaluate()->flush();
187 /*=====================================================================*\
188 || ###################################################################
191 || ###################################################################
192 \*=====================================================================*/