From 89763104c8e99f754cc5fd6f00d210b6466f6bb2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Jan 2006 08:23:03 +0000 Subject: [PATCH] r722: Error box for edit comment --- editcomment.php | 75 ++++++++++++++++++++++----------------- templates/editcomment.tpl | 7 ++++ 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/editcomment.php b/editcomment.php index bac4901..029ebcc 100644 --- a/editcomment.php +++ b/editcomment.php @@ -58,46 +58,57 @@ if ($_POST['do'] == 'update') { if (!$bugsys->in['comment']) { - $message->error($lang->string('You need to enter text into the comment field')); + $message->items[] = $lang->string('You need to enter text into the comment field'); } if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden']) { - $message->error($lang->string('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.')); + $message->items[] = $lang->string('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.'); } - $bugsys->in['comment_parsed'] = $bugsys->in['comment']; - - if (!$bugsys->options['allowhtml']) + if (!$message->items) { - $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); + $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]" + ); + + // setup logging + require_once('./includes/class_history.php'); + $log = new History(); + $log->bugid = $bug['bugid']; + $log->commentid = $comment['commentid']; + $log->log($log->diff('comment ' . $comment['commentid'] . ' text', $comment['comment_parsed'], nl2br($bugsys->in['comment_parsed']))); + $log->log($log->diff('comment ' . $comment['commentid'] . ' hidden', $comment['hidden'], intval($bugsys->in['hidden']))); + + $lastgood = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC"); + $db->query(" + UPDATE " . TABLE_PREFIX . "bug + SET hiddenlastposttime = $lastgood[dateline], + hiddenlastpostby = $lastgood[userid] + WHERE bugid = $bug[bugid]" + ); + + $message->redirect($lang->string('The comment was modified successfully.'), "showreport.php?bugid=$bug[bugid]"); + } + else + { + $show['errors'] = true; + $_REQUEST['do'] = 'edit'; + $message->error_list_process(); + $comment['comment'] = $bugsys->in['comment']; + $comment['hidden'] = $bugsys->in['hidden']; } - - $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]" - ); - - // setup logging - require_once('./includes/class_history.php'); - $log = new History(); - $log->bugid = $bug['bugid']; - $log->commentid = $comment['commentid']; - $log->log($log->diff('comment ' . $comment['commentid'] . ' text', $comment['comment_parsed'], nl2br($bugsys->in['comment_parsed']))); - $log->log($log->diff('comment ' . $comment['commentid'] . ' hidden', $comment['hidden'], intval($bugsys->in['hidden']))); - - $lastgood = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC"); - $db->query(" - UPDATE " . TABLE_PREFIX . "bug - SET hiddenlastposttime = $lastgood[dateline], - hiddenlastpostby = $lastgood[userid] - WHERE bugid = $bug[bugid]" - ); - - $message->redirect($lang->string('The comment was modified successfully.'), "showreport.php?bugid=$bug[bugid]"); } // ################################################################### diff --git a/templates/editcomment.tpl b/templates/editcomment.tpl index 3990549..e75c2e4 100644 --- a/templates/editcomment.tpl +++ b/templates/editcomment.tpl @@ -10,6 +10,13 @@ $headinclude $header + +
+ {@"The following errors occurred"}: + {$message->process} +
+
+
-- 2.43.5