Updating editcomment.php
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 15:11:50 +0000 (11:11 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 15:11:50 +0000 (11:11 -0400)
editcomment.php
templates/editcomment.tpl

index 527e56e0370aa2ec43dd75b18cb25e5009a4c588..efdf3298bfa9eb27c7c6827bd433c99a09d76ac4 100644 (file)
@@ -31,14 +31,12 @@ 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();
 $commentapi->set('commentid',  $input->in['commentid']);
-$commentapi->set_condition();
 $commentapi->fetch();
 
-$comment =$commentapi->record;
+$comment = &$commentapi->record;
 
 $bug = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
 
@@ -66,7 +64,7 @@ if ($_POST['do'] == 'kill')
        // get the last post (as in prior to deletion)
        $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'])
@@ -91,10 +89,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]"
                );
        }
@@ -128,9 +126,9 @@ if ($_POST['do'] == 'update')
                $message->errorPermission();
        }
        
-       $commentapi->set('comment',     $input->in['comment']);
-       $commentapi->set('parselinks', $input->in['parselinks']);
-       $commentapi->set('hidden',      $input->in['hidden']);
+       $commentapi->set('comment',             $input->in['comment']);
+       $commentapi->set('parselinks',  $input->in['parselinks']);
+       $commentapi->set('hidden',              $input->in['hidden']);
        
        if ($input->in['commentid'] == $bug['initialreport'] AND $input->in['hidden'])
        {
@@ -162,7 +160,7 @@ 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]"
                );
                
@@ -193,14 +191,19 @@ if ($_REQUEST['do'] == 'edit')
        {
                $commenter = new UserAPI();
                $commenter->set('userid', $comment['userid']);
-               $commenter->set_condition();
                $commenter->fetch();
                $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();
 }
 
 /*=====================================================================*\
index 91cf78216152db429a9eae4ef036cabacd064b27..1eaa36dc6e295f20de484bf3bb0b50e1b68aeeee 100644 (file)
@@ -3,12 +3,12 @@
 <head>
 <%- $headinclude %>
        <link rel="stylesheet" type="text/css" href="templates/box.css" media="screen" />
-       <title><lang 1="$comment[commentid]">{@"Edit Comment %1$s"}</lang> - $bug[summary]</title>
+       <title><%- sprintf(T('Edit Comment %1$s'), $comment['commentid']) %> - <%- $bug['summary'] %></title>
 </head>
 
 <body>
 
-$header
+<%- $header %>
 
 <% if ($show['errors']): %>
 <div class="error" style="text-align: <%- $stylevar['left'] %>">
@@ -23,10 +23,10 @@ $header
 
 <div class="box">
        <div class="box-head" style="text-align: <%- $stylevar['left'] %>">
-               <lang 1="$comment[commentid]" 2="$bug[bugid]" 3="$bug[summary]">{@"Comment #%1$s in bug #%2$s <em>%3$s</em>"}</lang>
+               <%- sprintf(T('Comment #%1$s in bug #%2$s <em>%3$s</em>'), $comment['commentid'], $bug['bugid'], $bug['summary']) %>
        </div>
 
-       <div class="box-foot box-margmod-bottom" style="text-align: <%- $stylevar['left'] %>"><lang 1="$comment[posttime]" 2="$comment[postby]">{@"Posted on %1$s by %2$s"}</lang></div>
+       <div class="box-foot box-margmod-bottom" style="text-align: <%- $stylevar['left'] %>"><%- sprintf(T('Posted on %1$s by %2$s'), $comment['posttime'], $comment['postby']) %></div>
 
        <div class="box-mid" style="text-align: <%- $stylevar['left'] %>">
                <% if ($show['hide']): %><div><strong<% if ($comment['hidden']): %> style="color: red"<% endif %>><%-T("Hidden")%>:</strong> <input type="checkbox" name="hidden" value="1"<% if ($comment['hidden']): %> checked="checked"<% endif %> /></div><% endif %>
@@ -43,4 +43,4 @@ $header
        <script type="text/javascript"> draw_cancel("showreport.php?bugid=<%- $bug['bugid'] %>"); </script>
 </div>
 
-$footer
\ No newline at end of file
+<%- $footer %>
\ No newline at end of file