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 = " . $bugsys->input_clean('bugid', TYPE_UINT) ); if (!$bug) { $message->error(L_INVALID_ID); } if (!check_bug_permissions($bug)) { $message->error_permission(); } // setup logging require_once('./includes/class_logging.php'); $log = new Logging; $log->set_bugid($bug['bugid']); $bugfields = array( 'duplicateof', 'dependency', 'hidden', 'summary', 'status', 'severity', 'priority', 'version', 'assignedto' => 'assignto', 'resolution', 'product', 'component' ); $notif = new NotificationCenter; $bugapi = new BugAPI($bugsys); $bugapi->set('bugid', $bugsys->in['bugid']); $bugapi->set_condition(); $bugapi->dorelations = array(); $bugapi->fetch(); // ################################################################### if ($_POST['do'] == 'kill') { if (!can_perform('candeletedata', $bug['product'])) { $message->error_permission(); } $bugapi->delete(); $message->redirect(_('The entire bug has been deleted.'), 'index.php'); } // ################################################################### if ($_REQUEST['do'] == 'delete') { if (!can_perform('candeletedata', $bug['product'])) { $message->error_permission(); } $message->confirm(_('Are you sure you want to delete this bug? Doing so will destroy all associated data, including comments, attachments, and votes. We strongly recommend only deleting span records and nothing else as users may wish to go back and look at any bug to check its status.'), 'editreport.php', 'kill', _('Delete Bug Permanently'), 'showreport.php?bugid=' . $bug['bugid'], array('bugid' => $bug['bugid'])); } // ################################################################### if ($_POST['do'] == 'update') { if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product'])) { $message->error_permission(); } $log->add_data(true, $bugapi->objdata, $bugfields); // ------------------------------------------------------------------- // handle automations $automation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "automation WHERE actionid = " . $bugsys->input_clean('automation', TYPE_UINT)); if ($automation) { $automation['fields'] = unserialize($automation['fieldchanges']); if (is_array($automation['fields']['builtin'])) { foreach ($automation['fields']['builtin'] AS $field => $value) { $bugsys->in["$field"] = $value; } } if (is_array($automation['fields']['custom'])) { foreach ($automation['fields']['custom'] AS $field => $value) { $bugsys->in["field$field"] = $value; } } } // ------------------------------------------------------------------- // process comment stuff if ($bugsys->in['comment'] OR $automation['comment']) { if (!empty($bugsys->in['comment']) AND $automation['comment']) { $commenttext = $bugsys->in['comment'] . "\n\n" . _('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $automation['comment']; } else if (empty($bugsys->in['comment']) AND $automation['comment']) { $commenttext = $automation['comment']; } else { $commenttext = $bugsys->in['comment']; } $comment = new CommentAPI($bugsys); $comment->set('bugid', $bugsys->in['bugid']); $comment->set('userid', $bugsys->userinfo['userid']); $comment->set('comment', $commenttext); $comment->insert(); // we redefine the bug data later, but it needs to be here in order to generate the user list $notif->set_bug_data($bugapi->objdata); $notif->send_new_comment_notice($comment->values); $bugapi->set('lastposttime', $comment->values['dateline']); $bugapi->set('lastpostby', $bugsys->userinfo['userid']); $bugapi->set('lastpostbyname', $bugsys->userinfo['displayname']); $bugapi->set('hiddenlastposttime', $comment->values['dateline']); $bugapi->set('hiddenlastpostby', $bugsys->userinfo['userid']); $bugapi->set('hiddenlastpostbyname', $bugsys->userinfo['displayname']); if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid']))) { $bugapi->update(); $notif->finalize(); $message->redirect(_('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]"); } } // ------------------------------------------------------------------- // do update stuff $pcv = parse_pcv_select($bugsys->in['pcv_select'], true); $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY); $dependencies = ((sizeof($dependencies) < 1) ? '' : implode(', ', $dependencies)); $bugapi->set('summary', $bugsys->in['summary']); $bugapi->set('severity', $bugsys->in['severity']); $bugapi->set('duplicateof', $bugsys->in['duplicateof']); $bugapi->set('dependency', $dependencies); $bugapi->set('product', $pcv['product']); $bugapi->set('component', $pcv['component']); $bugapi->set('version', $pcv['version']); $bugapi->set('hidden', $bugsys->in['hidden']); if (can_perform('canchangestatus', $bug['product'])) { $bugapi->set('priority', $bugsys->in['priority']); $bugapi->set('status', $bugsys->in['status']); $bugapi->set('resolution', $bugsys->in['resolution']); } if (can_perform('canassign', $bug['product'])) { $bugapi->set('assignedto', $bugsys->in['assignedto']); } $notif->set_bug_data($bugapi->objdata, $bugapi->values); // ------------------------------------------------------------------- // handle logging and perform updates if ($fields = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]")) { $log->add_data(true, $fields, array('bugid'), true, 'custom'); } $log->add_data(false, $bugapi->values, $bugfields); process_custom_fields($bug['bugid'], $message, false); $bugapi->update(); // ------------------------------------------------------------------- // do diff history $fieldsnew = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); $log->add_data(false, $fieldsnew, array('bugid'), true, 'custom'); $log->update_history(); $notif->send_bug_changes_notice($fields, $fieldsnew); $notif->finalize(); $message->redirect(_('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]"); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>