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 (!$bug) { $message->error('alert: bad bug'); } if (!(((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo'))) { $message->error_permission(); } if ($bug['hidden'] AND !can_perform('canviewhidden')) { $message->error_permission(); } // setup logging require_once('./includes/class_history.php'); $log = new History(); $log->bugid = $bug['bugid']; // ################################################################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'edit'; } // ################################################################### if ($_POST['do'] == 'update') { $pcv = parse_pcv_select($bugsys->in['pcv_select'], true); if (!$bugsys->in['summary']) { $message->error('you need to enter a summary'); } if (!$pcv) { $message->error('invalid product/component/version'); } $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); process_custom_fields($bug['bugid']); $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY); $dependencies = ((count($dependencies) < 1) ? '' : implode(', ', $dependencies)); $db->query(" UPDATE " . TABLE_PREFIX . "bug SET summary = '" . $bugsys->in['summary'] . "', priority = " . intval($bugsys->in['priority']) . ", status = " . intval($bugsys->in['status']) . ", severity = " . intval($bugsys->in['severity']) . ", resolution = " . intval($bugsys->in['resolution']) . ", assignedto = " . intval($bugsys->in['assignedto']) . ", duplicateof = " . intval($bugsys->in['duplicateof']) . ", dependency = '$dependencies', productid = " . $pcv['product'] . ", componentid = " . $pcv['component'] . ", versionid = " . $pcv['version'] . ", hidden = " . intval($bugsys->in['hidden']) . " WHERE bugid = $bug[bugid]" ); // ------------------------------------------------------------------- // do diff history $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]"); $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); $diff[0] = array_diff_assoc($hist[0], $hist[1]); $diff[1] = array_diff_assoc($hist[1], $hist[0]); $lookupindex = array( 'status' => 'status', 'severity' => 'severity', 'priority' => 'priority', 'versionid' => 'version', 'assignedto' => 'assignto', 'resolution' => 'resolution', 'productid' => 'product', 'componentid' => 'product' ); $log->language = 'log_update_bug'; foreach ($diff AS $num => $diffs) { foreach ($diffs AS $key => $value) { if (!isset($lookupindex["$key"])) { continue; } $ref = $lookupindex["$key"]; $temp =& $bugsys->datastore["$ref"]["$value"]; $thevalue = $temp["$ref"]; $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')'; if ($key == 'assignedto') { $thevalue = (($temp['userid']) ? construct_user_display($temp) : ''); $idbit = ''; } else if ($key == 'productid' OR $key == 'componentid') { $ref = 'product'; $thevalue = $temp['title']; } $diff["$num"]["$key"] = (($thevalue) ? $thevalue . $idbit : ''); } } foreach ($diff[1] AS $key => $value) { $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"])); } $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]); $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]); if ($noinitialcustom === false) { $canallowempty = true; $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield WHERE type = 'input_checkbox'"); while ($box = $db->fetch_array($checkbox)) { $boxlist[] = $box['shortname']; } } foreach ($diff2[1] AS $key => $value) { if (in_array($key, $boxlist) AND $canallowempty) { $log->allowempty = true; } else { $log->allowempty = false; } if ($key == 'bugid') { continue; } $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"])); } $log->allowempty = false; // ------------------------------------------------------------------- // process comment stuff if (!$bugsys->in['firstcomment']) { $message->error('you need to enter some text in the first comment'); } $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment']; if (!$bugsys->options['allowhtml']) { $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); } // we could pass this as a GET param, but that's unsafe $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1"); $db->query(" UPDATE " . TABLE_PREFIX . "comment SET comment = '" . $bugsys->in['firstcomment'] . "', comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "' WHERE commentid = $firstcomment[commentid]" ); $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]"); } // ################################################################### if ($_REQUEST['do'] == '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); } eval('$template->flush("' . $template->fetch('editreport') . '");'); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>