r784: Globalize the $commentapi variable so that it can be used for both do branches
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 30 Apr 2006 08:04:43 +0000 (08:04 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 30 Apr 2006 08:04:43 +0000 (08:04 +0000)
editcomment.php

index db385147e4aa62b329e47fd7bb796f95590824e6..3ab4f44947e2d7ffa86b9549d9bc286178e9ec85 100644 (file)
@@ -30,18 +30,12 @@ $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
-       FROM " . TABLE_PREFIX . "comment AS comment
-       LEFT JOIN " . TABLE_PREFIX . "user AS user
-               ON (comment.userid = user.userid)
-       WHERE comment.commentid = " . intval($bugsys->in['commentid'])
-);
+$commentapi = new CommentAPI($bugsys);
+$commentapi->set('commentid',  $bugsys->in['commentid']);
+$commentapi->set_condition();
+$commentapi->fetch();
 
-if (!$comment)
-{
-       $message->error($lang->getlex('error_invalid_id'));
-}
+$comment =& $commentapi->objdata;
 
 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
 
@@ -66,9 +60,6 @@ if (empty($_REQUEST['do']))
 
 if ($_POST['do'] == 'update')
 {
-       $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']);
        
@@ -114,7 +105,7 @@ if ($_POST['do'] == 'update')
 if ($_REQUEST['do'] == 'edit')
 {
        $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
-       $comment['postby'] = construct_user_display($comment);
+       $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') . '");');