error_permission(); } $show['edit'] = (((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $bug['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true : false; $bugid = intval($bugsys->in['bugid']); // ################################################################### if (empty($bugid) OR $_REQUEST['do'] == 'quicksearch') { if (!empty($bugid)) { if ($db->query_first("SELECT bugid FROM " . TABLE_PREFIX . "bug WHERE bugid = $bugid")) { header("Location: showreport.php?bugid=$bugid"); exit; } else { $error = lang::p('error_invalid_id'); } } eval('$template->flush("' . $template->fetch('quicksearch') . '");'); exit; } // ################################################################### // ------------------------------------------------------------------- // get the report $bug = $db->query_first(" SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail FROM " . TABLE_PREFIX . "bug AS bug LEFT JOIN " . TABLE_PREFIX . "user AS user ON (bug.userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill ON (bug.bugid = bugvaluefill.bugid) WHERE bug.bugid = " . intval($bugsys->in['bugid']) ); if (!is_array($bug)) { $message->error(lang::p('error_invalid_id')); } if ($bug['hidden'] AND !can_perform('canviewhidden')) { $message->error_permission(); } // ################################################################### // global display items $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'); // ################################################################### // edit display if ($show['edit']) { $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']); $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false); if (can_perform('canchangestatus')) { $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']); $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']); $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']); } $show['assign'] = ((can_perform('canassign')) ? true : false); if (can_perform('canassign')) { foreach ($bugsys->datastore['assignto'] AS $dev) { $value = $dev['userid']; $selected = (($dev['userid'] == $bug['assignedto']) ? true : false); $label = construct_user_display($dev, false); eval('$select[dev] .= "' . $template->fetch('selectoption') . '";'); } } $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]"); $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1"); $customfields = construct_custom_fields($bug); if ($bug['duplicateof']) { $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[duplicateof]"); } if ($bug['dependency']) { $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($bug[dependency])"); while ($dependency = $db->fetch_array($dependencies)) { $depends[] = "$dependency[bugid]"; } $dependencies = implode(' ', $depends); } $actions = $db->query("SELECT * FROM " . TABLE_PREFIX . "autoaction ORDER BY name ASC"); $select['autoactions'] = ''; $show['autoactions'] = false; while ($action = $db->fetch_array($actions)) { $label = $action['name']; $value = $action['actionid']; $selected = false; eval('$select[autoaction] .= "' . $bugsys->template->fetch('selectoption') . '";'); $show['autoactions'] = true; } if ($show['autoactions']) { $label = ''; $value = 0; $selected = true; eval('$select[autoaction] = "' . $bugsys->template->fetch('selectoption') . '" . $select[autoaction];'); } } // ################################################################### // non-edit display else { // ------------------------------------------------------------------- // 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) : ''); $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); } // ------------------------------------------------------------------- // 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"; } } // ################################################################### // other elements // ------------------------------------------------------------------- // 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$ || ################################################################### \*=====================================================================*/ ?>