r324: Comment adding is now done on showreport.php
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Jul 2005 22:18:39 +0000 (22:18 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Jul 2005 22:18:39 +0000 (22:18 +0000)
editreport.php
newcomment.php
showreport.php
templates/newcomment.tpl [deleted file]
templates/showreport.tpl

index cf6548814ee19ffd698d98b641a9cbebdddcf0a8..97ceafc8b0bd9fb9e83c13023d817f0459adb5d9 100644 (file)
@@ -48,13 +48,6 @@ $log->bugid = $bug['bugid'];
 
 // ###################################################################
 
-if (empty($_REQUEST['do']))
-{
-       $_REQUEST['do'] = 'edit';
-}
-
-// ###################################################################
-
 if ($_POST['do'] == 'update')
 {
        $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
@@ -207,60 +200,58 @@ if ($_POST['do'] == 'update')
        
        // -------------------------------------------------------------------
        // process comment stuff
-       /*
-       if (!$bugsys->in['firstcomment'])
-       {
-               $message->error('you need to enter some text in the first comment');
-       }
        
-       $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment'];
-       
-       if (!$bugsys->options['allowhtml'])
-       {
-               $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
-       }
-       
-       // we could pass this as a GET param, but that's unsafe
-       $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
-       
-       $db->query("
-               UPDATE " . TABLE_PREFIX . "comment
-               SET comment = '" . $bugsys->in['firstcomment'] . "',
-                       comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "'
-               WHERE commentid = $firstcomment[commentid]"
-       );
-       */
-       // -------------------------------------------------------------------
-       // auto action comment
+       $hascomment = (!empty($bugsys->in['comment'])) ? true : false;
        
-       if ($autoaction['comment'])
+       if ($hascomment OR $autoaction['comment'])
        {
-               $comment = $autoaction['comment'];
+               if ($hascomment AND $autoaction['comment'])
+               {
+                       $bugsys->in['comment'] .= "\n\n--------------- AUTOMATIC RESPONSE ---------------\n" . $autoaction['comment'];
+               }
+               else if (!$hascomment AND $autoaction['comment'])
+               {
+                       $bugsys->in['comment'] = $autoaction['comment'];
+               }
+               
+               $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
+               
                if (!$bugsys->options['allowhtml'])
                {
-                       $comment_parsed = $bugsys->sanitize($comment);
+                       $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
                }
                
+               $time = TIMENOW;
+               
                $db->query("
-                       INSERT INTO comment
+                       INSERT INTO " . TABLE_PREFIX . "comment
                                (bugid, userid, dateline, comment, comment_parsed)
                        VALUES
-                               ($bug[bugid], " . $bugsys->userinfo['userid'] . ", " . LOG_TIME . ",
-                               '" . $bugsys->escape($comment) . "',
-                               '" . $bugsys->escape($comment_parsed) . "'
+                               (" . intval($bugsys->in['bugid']) . ", " . $bugsys->userinfo['userid'] . ",
+                               $time, '" . $bugsys->in['comment'] . "',
+                               '" . nl2br($bugsys->in['comment_parsed']) . "'
                        )"
                );
                
+               $commentid = $db->insert_id();
+               
                $db->query("
                        UPDATE " . TABLE_PREFIX . "bug
-                       SET lastposttime = " . LOG_TIME . ",
+                       SET lastposttime = $time,
                                lastpostby = " . $bugsys->userinfo['userid'] . ",
-                               hiddenlastposttime = " . LOG_TIME . ",
+                               hiddenlastposttime = $time,
                                hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
-                       WHERE bugid = $bug[bugid]"
+                       WHERE bugid = " . intval($bugsys->in['bugid'])
                );
+               
+               if ($hascomment)
+               {
+                       $log->language = 'log_new_comment';
+                       $log->arguments = array($commentid);
+                       $log->log();
+               }
        }
-       
+
        $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
 }
 
index 52d033e808229e4dfcb816c0f71d7d92050f5906..9449801e76edebad800966e828dfcfa12476fbae 100644 (file)
 || ################################################################### ||
 \*=====================================================================*/
 
-$fetchtemplates = array(
-       'newcomment'
-);
-
 define('SVN', '$Id$');
 
 require_once('./global.php');
@@ -25,13 +21,6 @@ if (!can_perform('canpostcomments'))
 
 // ###################################################################
 
-if (empty($_REQUEST['do']))
-{
-       $_REQUEST['do'] = 'add';
-}
-
-// ###################################################################
-
 if ($_POST['do'] == 'insert')
 {
        $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
@@ -75,19 +64,6 @@ if ($_POST['do'] == 'insert')
        $message->redirect('comment inesrted', "showreport.php?bugid=" . intval($bugsys->in['bugid']));
 }
 
-// ###################################################################
-
-if ($_REQUEST['do'] == 'add')
-{
-       $bug = $db->query_first("SELECT bug.*, comment.comment FROM " . TABLE_PREFIX . "bug AS bug LEFT JOIN " . TABLE_PREFIX . "comment AS comment ON (bug.bugid = comment.bugid) WHERE bug.bugid = " . intval($bugsys->in['bugid']));
-       if (!$bug)
-       {
-               $message->error('alert: bad bug');
-       }
-       
-       eval('$template->flush("' . $template->fetch('newcomment') . '");');
-}
-
 /*=====================================================================*\
 || ###################################################################
 || # $HeadURL$
index 33adcb25f074cf6bcead25cf4258654a9ec4d332..5fb7f4eaa650550586926049f5fab8465aa437b7 100644 (file)
@@ -169,9 +169,7 @@ else
        
        $assigninfo = $bugsys->datastore['assignto']["$bug[assignedto]"];
        $bug['assigninfo'] = ((is_array($assigninfo)) ? construct_user_display($assigninfo) : '');
-       
-       $show['editreport'] = ((((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) ? true : false);
-       
+               
        $duplicateof = $db->query_first("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[duplicateof]");
        
        $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE duplicateof = $bug[bugid]");
diff --git a/templates/newcomment.tpl b/templates/newcomment.tpl
deleted file mode 100644 (file)
index 7b743a5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-$doctype
-$headinclude
-$header
-
-<div><strong>New comment for:</strong> <em>$bug[summary]</em></div>
-
-<form name="newcomment" method="post" action="newcomment.php">
-<input type="hidden" name="do" value="insert" />
-<input type="hidden" name="bugid" value="$bug[bugid]" />
-<div><strong>Comment:</strong></div>
-<textarea name="comment" cols="100" rows="35"></textarea>
-<div><input type="submit" name="submit" value="Add Comment" /></div>
-</form>
-
-<br />
-<br />
-
-<table border="1" cellspacing="2" cellpadding="4" width="100%">
-<tr style="background-color:#EEEEEE">
-       <td><strong>Summary Report:</strong>$bug[summary]</td>
-</tr>
-<tr>
-       <td>$bug[comment]</td>
-</tr>
-</table>
-
-$footer
\ No newline at end of file
index c269a58c2518f26acdc594a15129a675054c629f..d3c8c2e426dd74500cdd6e4f2a8fbb4a8669c63d 100644 (file)
@@ -2,9 +2,11 @@ $doctype
 $headinclude
 $header
 
-<form name="bugreport" action="editreport.php" method="post">
-<input type="hidden" name="do" value="update" />
-<input type="hidden" name="bugid" value="$bug[bugid]" />
+<if condition="$show['edit']">
+       <form name="bugreport" action="editreport.php" method="post">
+       <input type="hidden" name="do" value="update" />
+       <input type="hidden" name="bugid" value="$bug[bugid]" />
+</if>
 
 <if condition="$show['edit']">
        <div><strong<if condition="$bug['hidden']"> style="color: red"</if>>Hidden:</strong> <input type="checkbox" name="hidden" value="1"<if condition="$bug['hidden']"> checked="checked"</if> /></div>
@@ -42,6 +44,11 @@ $header
        </div>
        
        $customfields
+       
+       <if condition="$show['newreply']">
+               <div><strong>Comment:</strong></div>
+               <textarea name="comment" cols="100" rows="35"></textarea>
+       </if>
 <else />
        <div><strong>Product:</strong> $bug[product] <if condition="$bug['componentid']">/ <strong>Component:</strong> $bug[component]</if> / <strong>Version:</strong> $bug[version]</div>
        <div><strong>Title / summary:</strong> $bug[summary]</div>
@@ -53,6 +60,16 @@ $header
        <if condition="$dupelist"><div><strong>Bugs marked as duplicates of this:</strong> $dupelist</div></if>
        <if condition="$dependencies"><div><strong>Dependencies:</strong> $dependencies</div></if>
        $customfields
+       
+       <if condition="$show['newreply']">
+               <form name="newcomment" method="post" action="newcomment.php">
+               <input type="hidden" name="do" value="insert" />
+               <input type="hidden" name="bugid" value="$bug[bugid]" />
+               <div><strong>Comment:</strong></div>
+               <textarea name="comment" cols="100" rows="35"></textarea>
+               <div><input type="submit" name="submit" value="Add Comment" /></div>
+               </form>
+       </if>
 </if>
 
 <div><input type="submit" name="submit" value="Save Changes" /></div>