error_permission();
}
// ###################################################################
// -------------------------------------------------------------------
// get the report
$bug = $db->query_first("
SELECT bug.*, user.displayname, user.email, user.showemail
FROM " . TABLE_PREFIX . "bug AS bug
LEFT JOIN " . TABLE_PREFIX . "user AS user
ON (bug.userid = user.userid)
WHERE bug.bugid = " . intval($bugsys->in['bugid'])
);
if (!is_array($bug))
{
$message->error('alert: bad bug');
}
if ($bug['hidden'] AND !can_perform('canviewhidden'))
{
$message->error_permission();
}
// -------------------------------------------------------------------
// prep display
$bug['userinfo'] = construct_user_display($bug);
$bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
$bug['component'] = (($bug['componentid']) ? $bugsys->datastore['product']["$bug[componentid]"]['title'] : '');
$bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
$bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
$bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
$bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
$bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
$assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
$bug['assigninfo'] = ((is_array($assigninfo)) ? construct_user_display($assigninfo) : '');
$show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true : false);
$duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[duplicateof]");
$duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE duplicateof = $bug[bugid]");
while ($duplicate = $db->fetch_array($duplicates))
{
$dupelist[] = "$duplicate[summary]";
}
$dupelist = implode(', ', $dupelist);
if ($bug['dependency'])
{
$dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($bug[dependency])");
while ($dependency = $db->fetch_array($dependencies))
{
$depends[] = "$dependency[bugid]";
}
$dependencies = implode(' ', $depends);
}
$favourite = (bool)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo['userid']);
$favouritetext = (($favourite) ? 'Remove from Favourites' : 'Add to Favourites');
// -------------------------------------------------------------------
// custom fields
$customfields = '';
$allfields = $db->query("
SELECT bugfield.*
FROM " . TABLE_PREFIX . "bugfield AS bugfield
LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
ON (bugfield.fieldid = permission.fieldid)
WHERE permission.mask <> 0
AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
);
while ($field = $db->fetch_array($allfields))
{
$fieldlist["$field[fieldid]"] = $field;
}
$fieldvalues = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
foreach ($fieldlist AS $fieldid => $field)
{
if (is_null($fieldvalues["field$fieldid"]))
{
if ($field['type'] == 'select_single')
{
if ($field['usedefault'])
{
$temp = unserialize($field['selects']);
$value = trim($temp[0]);
}
else
{
continue;
}
}
else
{
$value = $field['defaultvalue'];
}
}
else
{
$value = $fieldvalues["field$fieldid"];
}
$customfields .= "
$field[name]: ";
if ($field['type'] == 'input_text' OR $field['type'] == 'select_single')
{
$customfields .= $value;
}
else if ($field['type'] == 'input_checkbox')
{
$customfields .= (($value) ? 'True' : 'False');
}
$customfields .= "
\n\n";
}
// -------------------------------------------------------------------
// hilight
$words = explode(' ', $bugsys->in['hilight']);
foreach ($words AS $word)
{
if (trim($word))
{
$word = preg_quote($bugsys->unsanitize($word));
$hilight[] = $temp = trim(preg_replace('#[^0-9a-zA-Z_ ]#', '', $word));
}
}
// -------------------------------------------------------------------
// attachments
$show['getattachments'] = ((can_perform('cangetattach') OR can_perform('caneditattach')) ? true : false);
$show['putattachments'] = ((can_perform('canputattach') OR can_perform('caneditattach')) ? true : false);
if ($show['getattachments'] OR $show['putattachments'])
{
$attachments_fetch = $db->query("
SELECT attachment.*, user.email, user.showemail,
user.displayname
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "user AS user
ON (attachment.userid = user.userid)
WHERE attachment.bugid = $bug[bugid]
ORDER BY attachment.dateline"
);
while ($attachment = $db->fetch_array($attachments_fetch))
{
$show['editattach'] = ((can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach'))) ? true : false);
$attachment['date'] = $datef->format($bugsys->options['dateformat'], $attachment['dateline']);
$attachment['user'] = construct_user_display($attachment, false);
eval('$attachments .= "' . $template->fetch('showreport_attachment') . '";');
}
}
// -------------------------------------------------------------------
// votes
$vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX . "vote WHERE bugid = $bug[bugid]");
$vote['total'] = $vote['votefor'] + $vote['voteagainst'];
$vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100;
$vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100;
$show['vote'] = ((can_perform('canvote') AND !$vote['uservote']) ? true : false);
// -------------------------------------------------------------------
// get comments
$comments_fetch = $db->query("
SELECT comment.*, user.email, user.showemail, user.displayname
FROM " . TABLE_PREFIX . "comment AS comment
LEFT JOIN " . TABLE_PREFIX . "user AS user
ON (comment.userid = user.userid)
WHERE comment.bugid = $bug[bugid]" . ((!can_perform('canviewhidden')) ? "
AND !hidden" : '') . "
ORDER BY comment.dateline ASC"
);
while ($comment = $db->fetch_array($comments_fetch))
{
$comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
$comment['postby'] = construct_user_display($comment);
$show['editcomment'] = (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) ? true : false);
if (is_array($hilight))
{
foreach ($hilight AS $id => $find)
{
$find = "#($find)#";
$replace = "\\1";
$comment['comment_parsed'] = preg_replace($find, $replace, $comment['comment_parsed']);
}
}
eval('$comments .= "' . $template->fetch('showreport_comment') . '";');
}
$show['newreply'] = ((can_perform('canpostcomments')) ? true : false);
if (is_array($hilight))
{
foreach ($hilight AS $id => $find)
{
$find = "#($find)#";
$replace = "\\1";
$bug['summary'] = preg_replace($find, $replace, $bug['summary']);
}
}
eval('$template->flush("' . $template->fetch('SHOWREPORT') . '");');
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>