Squash-merging the ISSO3 branch back onto master
[bugdar.git] / editcomment.php
index 2dbf56e4893130f489b79f5df8a3f631aef78bb9..0b3de8c0d22c5d0005534afa3fb65f11667b7e5d 100644 (file)
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Bugdar
-|| # Copyright ©2002-2007 Blue Static
+|| # Copyright (c)2004-2008 Blue Static
 || #
 || # This program is free software; you can redistribute it and/or modify
 || # it under the terms of the GNU General Public License as published by
@@ -23,24 +23,20 @@ $fetchtemplates = array(
        'editcomment'
 );
 
-define('SVN', '$Id$');
 
 $focus['showreport'] = 'focus';
 
 require_once('./global.php');
 require_once('./includes/api_comment.php');
 
-require_once('./includes/class_api_error.php');
-APIError(array(new API_Error_Handler($message), 'user_cumulative'));
 
-$commentapi = new CommentAPI($bugsys);
-$commentapi->set('commentid',  $bugsys->in['commentid']);
-$commentapi->set_condition();
+$commentapi = new CommentAPI();
+$commentapi->set('commentid',  $input->in['commentid']);
 $commentapi->fetch();
 
-$comment =& $commentapi->objdata;
+$comment = &$commentapi->record;
 
-$bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
+$bug = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
 
 if (!check_bug_permissions($bug))
 {
@@ -64,14 +60,14 @@ if ($_POST['do'] == 'kill')
        }
        
        // get the last post (as in prior to deletion)
-       $lastpost = $db->query_first("SELECT commentid FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline DESC");
+       $lastpost = $db->queryFirst("SELECT commentid FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline DESC");
        
-       $commentapi->delete();
+       $commentapi->remove();
        
        // check to see if we need to rebuild the lastpost information
        if ($lastpost['commentid'] == $comment['commentid'])
        {
-               $lastgoodpublic = $db->query_first("
+               $lastgoodpublic = $db->queryFirst("
                        SELECT comment.* AS comment, user.displayname AS username
                        FROM " . TABLE_PREFIX . "comment AS comment
                        LEFT JOIN " . TABLE_PREFIX . "user AS user
@@ -79,7 +75,7 @@ if ($_POST['do'] == 'kill')
                        WHERE bugid = $bug[bugid]
                                AND !hidden ORDER BY dateline DESC
                ");
-               $lastgoodprivate = $db->query_first("
+               $lastgoodprivate = $db->queryFirst("
                        SELECT comment.* AS comment, user.displayname AS username
                        FROM " . TABLE_PREFIX . "comment AS comment
                        LEFT JOIN " . TABLE_PREFIX . "user AS user
@@ -91,10 +87,10 @@ if ($_POST['do'] == 'kill')
                        UPDATE " . TABLE_PREFIX . "bug
                        SET hiddenlastposttime = $lastgoodpublic[dateline],
                                hiddenlastpostby = $lastgoodpublic[userid],
-                               hiddenlastpostbyname = '" . $db->escape_string($lastgoodpublic['username']) . "',
+                               hiddenlastpostbyname = '" . $db->escapeString($lastgoodpublic['username']) . "',
                                lastposttime = $lastgoodprivate[dateline],
                                lastpostby = $lastgoodprivate[userid],
-                               lastpostbyname = '" . $db->escape_string($lastgoodprivate['username']) . "'
+                               lastpostbyname = '" . $db->escapeString($lastgoodprivate['username']) . "'
                        WHERE bugid = $bug[bugid]"
                );
        }
@@ -123,16 +119,16 @@ if ($_REQUEST['do'] == 'delete')
 
 if ($_POST['do'] == 'update')
 {
-       if (!((can_perform('caneditownreply', $bug['product']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND $bugsys->userinfo['userid'] != $comment['userid'])))
+       if (!((can_perform('caneditownreply', $bug['product']) AND bugdar::$userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND bugdar::$userinfo['userid'] != $comment['userid'])))
        {
                $message->errorPermission();
        }
        
-       $commentapi->set('comment',     $bugsys->in['comment']);
-       $commentapi->set('parselinks', $bugsys->in['parselinks']);
-       $commentapi->set('hidden',      $bugsys->in['hidden']);
+       $commentapi->set('comment',             $input->in['comment']);
+       $commentapi->set('parselinks',  $input->in['parselinks']);
+       $commentapi->set('hidden',              $input->in['hidden']);
        
-       if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden'])
+       if ($input->in['commentid'] == $bug['initialreport'] AND $input->in['hidden'])
        {
                $message->addError(T('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.'));
        }
@@ -144,13 +140,13 @@ if ($_POST['do'] == 'update')
                // setup logging
                require_once('./includes/class_logging.php');
                $log = new Logging;
-               $log->set_bugid($bug['bugid']);
-               $log->set_commentid($comment['commentid']);
+               $log->setBugId($bug['bugid']);
+               $log->setCommentId($comment['commentid']);
                
-               $log->add_data(true, $commentapi->objdata, array('comment', 'hidden'), false, 'comment');
-               $log->add_data(false, $commentapi->values, array('comment', 'hidden'), false, 'comment');
+               $log->addData(true, $commentapi->record, array('comment', 'hidden'), false, 'comment');
+               $log->addData(false, $commentapi->values, array('comment', 'hidden'), false, 'comment');
                
-               $lastgood = $db->query_first("
+               $lastgood = $db->queryFirst("
                        SELECT comment.* AS comment, user.displayname AS username
                        FROM " . TABLE_PREFIX . "comment AS comment
                        LEFT JOIN " . TABLE_PREFIX . "user AS user
@@ -162,11 +158,11 @@ if ($_POST['do'] == 'update')
                        UPDATE " . TABLE_PREFIX . "bug
                        SET hiddenlastposttime = $lastgood[dateline],
                                hiddenlastpostby = $lastgood[userid],
-                               hiddenlastpostbyname = '" . $db->escape_string($lastgood['username']) . "'
+                               hiddenlastpostbyname = '" . $db->escapeString($lastgood['username']) . "'
                        WHERE bugid = $bug[bugid]"
                );
                
-               $log->update_history();
+               $log->updateHistory();
                
                $message->redirect(T('The comment was modified successfully.'), "showreport.php?bugid=$bug[bugid]");
        }
@@ -174,8 +170,8 @@ if ($_POST['do'] == 'update')
        {
                $show['errors'] = true;
                $_REQUEST['do'] = 'edit';
-               $comment['comment'] = $bugsys->in['comment'];
-               $comment['hidden'] = $bugsys->in['hidden'];
+               $comment['comment'] = $input->in['comment'];
+               $comment['hidden'] = $input->in['hidden'];
        }
 }
 
@@ -183,30 +179,29 @@ if ($_POST['do'] == 'update')
 
 if ($_REQUEST['do'] == 'edit')
 {
-       if (!((can_perform('caneditownreply', $bug['product']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND $bugsys->userinfo['userid'] != $comment['userid'])))
+       if (!((can_perform('caneditownreply', $bug['product']) AND bugdar::$userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND bugdar::$userinfo['userid'] != $comment['userid'])))
        {
                $message->errorPermission();
        }
        
-       $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
+       $comment['posttime'] = $datef->format(bugdar::$options['dateformat'], $comment['dateline']);
        if ($comment['userid'])
        {
-               $commenter = new UserAPI($bugsys);
+               $commenter = new UserAPI();
                $commenter->set('userid', $comment['userid']);
-               $commenter->set_condition();
                $commenter->fetch();
-               $commenter = $commenter->objdata;
+               $commenter = $commenter->record;
        }
        $comment['postby'] = construct_user_display($commenter);
-       $comment['comment'] = $bugsys->sanitize($comment['comment']);
-       $show['hide'] = ($bug['initialreport'] != $comment['commentid'] ? true : false);
-       eval('$template->flush("' . $template->fetch('editcomment') . '");');
+       $comment['comment'] = $input->sanitize($comment['comment']);
+       $show['hide'] = ($bug['initialreport'] != $comment['commentid']);
+       
+       $tpl = new BSTemplate('editcomment');
+       $tpl->vars = array(
+               'comment'       => $comment,
+               'bug'           => $bug
+       );
+       $tpl->evaluate()->flush();
 }
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file