From 19a9c4d4cabb2485cf564f0874ddf46b8423245a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 6 May 2006 02:11:13 +0000 Subject: [PATCH] r806: Simplify the commenting system; we no longer have duplicate code --- editreport.php | 122 +++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 76 deletions(-) diff --git a/editreport.php b/editreport.php index 71e3c81..f9ab84d 100644 --- a/editreport.php +++ b/editreport.php @@ -62,54 +62,15 @@ $log->bugid = $bug['bugid']; if ($_POST['do'] == 'update') { - // ------------------------------------------------------------------- - // process comment stuff - if ($bugsys->in['comment'] AND !((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid']))) - { - $comment = new CommentAPI($bugsys); - $comment->set('bugid', $bugsys->in['bugid']); - $comment->set('userid', $bugsys->userinfo['userid']); - $comment->set('comment', $_POST['comment']); - $comment->insert(); - - $time = $comment->values['dateline']; - $commentid = $comment->insertid; - - $db->query(" - UPDATE " . TABLE_PREFIX . "bug - SET lastposttime = $time, - lastpostby = " . $bugsys->userinfo['userid'] . ", - hiddenlastposttime = $time, - hiddenlastpostby = " . $bugsys->userinfo['userid'] . " - WHERE bugid = " . intval($bugsys->in['bugid']) - ); - - if ($hascomment) - { - $log->arguments = array($commentid); - $log->log(); - } - - $message->redirect($lang->string('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); - $bugapi = new BugAPI($bugsys); $bugapi->set('bugid', $bugsys->in['bugid']); $bugapi->set_condition(); $bugapi->dorelations = array(); $bugapi->fetch(); - $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); - // ------------------------------------------------------------------- - // start updates - - // auto action - $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['autoaction'])); + // handle autoaction + $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . $bugsys->input_clean('autoaction', TYPE_UINT)); if ($autoaction) { $autoaction['fields'] = unserialize($autoaction['fieldchanges']); @@ -125,6 +86,50 @@ if ($_POST['do'] == 'update') } } + // ------------------------------------------------------------------- + // process comment stuff + if ($bugsys->in['comment']) + { + if (!empty($bugsys->in['comment']) AND $autoaction['comment']) + { + $commenttext = $bugsys->in['comment'] . "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment']; + } + else if (empty($bugsys->in['comment']) AND $autoaction['comment']) + { + $commenttext = $autoaction['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(); + + $bugapi->set('lastposttime', $comment->values['dateline']); + $bugapi->set('lastpostby', $bugsys->userinfo['userid']); + $bugapi->set('hiddenlastposttime', $comment->values['dateline']); + $bugapi->set('hiddenlastpostby', $bugsys->userinfo['userid']); + + if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid']))) + { + $bugapi->update(); + $message->redirect($lang->string('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); + + $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); + + // ------------------------------------------------------------------- + // start updates + process_custom_fields($bug['bugid']); $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY); @@ -239,41 +244,6 @@ if ($_POST['do'] == 'update') $log->allowempty = false; - // ------------------------------------------------------------------- - // more comment - $hascomment = (!empty($bugsys->in['comment'])) ? true : false; - - if ($hascomment OR $autoaction['comment']) - { - if ($hascomment AND $autoaction['comment']) - { - $bugsys->in['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment']; - } - else if (!$hascomment AND $autoaction['comment']) - { - $bugsys->in['comment'] = $autoaction['comment']; - } - - $comment = new CommentAPI($bugsys); - $comment->set('bugid', $bugsys->in['bugid']); - $comment->set('userid', $bugsys->userinfo['userid']); - $comment->set('comment', $bugsys->in['comment']); - $comment->insert(); - - $time = $comment->values['dateline']; - $commentid = $comment->insertid; - - $db->query(" - UPDATE " . TABLE_PREFIX . "bug - SET lastposttime = $time, - lastpostby = " . $bugsys->userinfo['userid'] . ", - hiddenlastposttime = $time, - hiddenlastpostby = " . $bugsys->userinfo['userid'] . " - WHERE bugid = " . intval($bugsys->in['bugid']) - ); - } - - $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]"); } -- 2.22.5