set('commentid', $bugsys->in['commentid']); $commentapi->set_condition(); $commentapi->fetch(); $comment =& $commentapi->objdata; $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]"); if (!((can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo['userid'] != $comment['userid']))) { $message->error_permission(); } if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid'])) { $message->error_permissison(); } // ################################################################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'edit'; } // ################################################################### if ($_POST['do'] == 'update') { $commentapi->set('comment', $bugsys->in['comment']); $commentapi->set('hidden', $bugsys->in['hidden']); if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden']) { $message->add_error($lang->string('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.')); } if (!$message->items) { $commentapi->update(); // setup logging require_once('./includes/class_logging.php'); $log = new Logging; $log->set_bugid($bug['bugid']); $log->set_commentid($comment['commentid']); $log->add_data(true, $commentapi->objdata, array('comment', 'hidden'), false, 'comment'); $log->add_data(false, $commentapi->values, array('comment', 'hidden'), false, 'comment'); $lastgood = $db->query_first(" SELECT comment.* AS comment, user.displayname AS username FROM " . TABLE_PREFIX . "comment LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = comment.userid) WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC "); $db->query(" UPDATE " . TABLE_PREFIX . "bug SET hiddenlastposttime = $lastgood[dateline], hiddenlastpostby = $lastgood[userid], hiddenlastpostbyname = '" . $db->escape_string($lastgood['username']) . "' WHERE bugid = $bug[bugid]" ); $log->update_history(); $message->redirect($lang->string('The comment was modified successfully.'), "showreport.php?bugid=$bug[bugid]"); } else { $show['errors'] = true; $_REQUEST['do'] = 'edit'; $message->error_list_process(); $comment['comment'] = $bugsys->in['comment']; $comment['hidden'] = $bugsys->in['hidden']; } } // ################################################################### if ($_REQUEST['do'] == 'edit') { $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']); $comment['postby'] = construct_user_display($commentapi->relations['userid']->objdata); $comment['comment'] = $bugsys->sanitize($comment['comment']); $show['hide'] = ($bug['initialreport'] != $comment['commentid'] ? true : false); eval('$template->flush("' . $template->fetch('editcomment') . '");'); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>