From d87baa94dda2fd0df12a6cb1cc76684d6f324067 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Apr 2006 01:04:48 +0000 Subject: [PATCH] r775: Implementing the comment API --- editcomment.php | 25 +++++++---------------- editreport.php | 54 +++++++++++++++---------------------------------- newreport.php | 13 +++++++++--- 3 files changed, 33 insertions(+), 59 deletions(-) diff --git a/editcomment.php b/editcomment.php index e532093..db38514 100644 --- a/editcomment.php +++ b/editcomment.php @@ -28,6 +28,7 @@ define('SVN', '$Id$'); $focus['showreport'] = 'focus'; require_once('./global.php'); +require_once('./includes/api_comment.php'); $comment = $db->query_first(" SELECT comment.*, user.email, user.showemail, user.displayname @@ -65,10 +66,11 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'update') { - if (!$bugsys->in['comment']) - { - $message->items[] = $lang->string('You need to enter text into the comment field'); - } + $commentapi = new CommentAPI($bugsys); + $commentapi->set('commentid', $bugsys->in['commentid']); + $commentapi->set_condition(); + $commentapi->set('comment', $bugsys->in['comment']); + $commentapi->set('hidden', $bugsys->in['hidden']); if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden']) { @@ -77,20 +79,7 @@ if ($_POST['do'] == 'update') if (!$message->items) { - $bugsys->in['comment_parsed'] = $bugsys->in['comment']; - - if (!$bugsys->options['allowhtml']) - { - $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); - } - - $db->query(" - UPDATE " . TABLE_PREFIX . "comment - SET comment = '" . $bugsys->in['comment'] . "', - comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "', - hidden = " . intval($bugsys->in['hidden']) . " - WHERE commentid = $comment[commentid]" - ); + $commentapi->update(); // setup logging require_once('./includes/class_history.php'); diff --git a/editreport.php b/editreport.php index e490ec1..27f08b7 100644 --- a/editreport.php +++ b/editreport.php @@ -25,6 +25,8 @@ $focus['showreport'] = 'focus'; require_once('./global.php'); require_once('./includes/functions_product.php'); +require_once('./includes/api_bug.php'); +require_once('./includes/api_comment.php'); $bug = $db->query_first(" SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail @@ -77,26 +79,14 @@ if ($_POST['do'] == 'update') $bugsys->in['comment'] = $autoaction['comment']; } - $bugsys->in['comment_parsed'] = $bugsys->in['comment']; + $comment = new CommentAPI($bugsys); + $comment->set('bugid', $bugsys->in['bugid']); + $comment->set('userid', $bugsys->userinfo['userid']); + $comment->set('comment', $_POST['comment']); + $comment->insert(); - if (!$bugsys->options['allowhtml']) - { - $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); - } - - $time = TIMENOW; - - $db->query(" - INSERT INTO " . TABLE_PREFIX . "comment - (bugid, userid, dateline, comment, comment_parsed) - VALUES - (" . intval($bugsys->in['bugid']) . ", " . $bugsys->userinfo['userid'] . ", - $time, '" . $bugsys->in['comment'] . "', - '" . nl2br($bugsys->in['comment_parsed']) . "' - )" - ); - - $commentid = $db->insert_id(); + $time = $comment->values['dateline']; + $commentid = $comment->insertid; $db->query(" UPDATE " . TABLE_PREFIX . "bug @@ -280,26 +270,14 @@ if ($_POST['do'] == 'update') $bugsys->in['comment'] = $autoaction['comment']; } - $bugsys->in['comment_parsed'] = $bugsys->in['comment']; - - if (!$bugsys->options['allowhtml']) - { - $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); - } - - $time = TIMENOW; - - $db->query(" - INSERT INTO " . TABLE_PREFIX . "comment - (bugid, userid, dateline, comment, comment_parsed) - VALUES - (" . intval($bugsys->in['bugid']) . ", " . $bugsys->userinfo['userid'] . ", - $time, '" . $bugsys->in['comment'] . "', - '" . nl2br($bugsys->in['comment_parsed']) . "' - )" - ); + $comment = new CommentAPI($bugsys); + $comment->set('bugid', $bugsys->in['bugid']); + $comment->set('userid', $bugsys->userinfo['userid']); + $comment->set('comment', $bugsys->in['comment']); + $comment->insert(); - $commentid = $db->insert_id(); + $time = $comment->values['dateline']; + $commentid = $comment->insertid; $db->query(" UPDATE " . TABLE_PREFIX . "bug diff --git a/newreport.php b/newreport.php index 44dc772..3841055 100755 --- a/newreport.php +++ b/newreport.php @@ -29,6 +29,7 @@ $focus['newreport'] = 'focus'; require_once('./global.php'); require_once('./includes/functions_product.php'); +require_once('./includes/api_bug.php'); if (!can_perform('cansubmitbugs', intval($bugsys->in['productid']))) { @@ -46,6 +47,8 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'insert') { + $bug = new BugAPI($bugsys); + // ------------------------------------------------------------------- // check permissions on various input values if (!can_perform('canchangestatus', intval($bugsys->in['productid']))) @@ -125,7 +128,11 @@ if ($_POST['do'] == 'insert') $bugid = $db->insert_id(); - $time = TIMENOW; + $comment = new CommentAPI($bugsys); + $comment->set('bugid', $bugid); + $comment->set('userid', $bugsys->userinfo['userid']); + $comment->set('comment', $_POST['comment']); + $comment->insert(); // insert the comment to the database $db->query(" @@ -138,12 +145,12 @@ if ($_POST['do'] == 'insert') )" ); - $initialreport = $db->insert_id(); + $time = $comment->values['dateline']; $db->query(" UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, - initialreport = $initialreport, + initialreport = " . $comment->insertid . ", lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . ", hiddenlastposttime = $time, -- 2.22.5