From c162d6baaf0a5ac8265f9a332cedc99dfb7aa34d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 14 Aug 2006 05:07:41 +0000 Subject: [PATCH] r1031: Update lastpost info after comment->delete() --- docs/changes.txt | 1 + editcomment.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index b7eb560..ef65bb5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,6 +1,7 @@ 1.1.0 Beta 1 ================== - Array casting to remove foreach() warnings [editreport.php#132] +- Update last post information after deleting a comment (http://bugs.bluestatic.org/showreport.php?bugid=25) 1.1.0 ================== diff --git a/editcomment.php b/editcomment.php index 61b7556..4064eba 100644 --- a/editcomment.php +++ b/editcomment.php @@ -63,8 +63,42 @@ if ($_POST['do'] == 'kill') $message->error_permission(); } + // 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"); + $commentapi->delete(); + // check to see if we need to rebuild the lastpost information + if ($lastpost['commentid'] == $comment['commentid']) + { + $lastgoodpublic = $db->query_first(" + SELECT comment.* AS comment, user.displayname AS username + FROM " . TABLE_PREFIX . "comment + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (user.userid = comment.userid) + WHERE bugid = $bug[bugid] + AND !hidden ORDER BY dateline DESC + "); + $lastgoodprivate = $db->query_first(" + SELECT comment.* AS comment, user.displayname AS username + FROM " . TABLE_PREFIX . "comment + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (user.userid = comment.userid) + WHERE bugid = $bug[bugid] + ORDER BY dateline DESC + "); + $db->query(" + UPDATE " . TABLE_PREFIX . "bug + SET hiddenlastposttime = $lastgoodpublic[dateline], + hiddenlastpostby = $lastgoodpublic[userid], + hiddenlastpostbyname = '" . $db->escape_string($lastgoodpublic['username']) . "', + lastposttime = $lastgoodprivate[dateline], + lastpostby = $lastgoodprivate[userid], + lastpostbyname = '" . $db->escape_string($lastgoodprivate['username']) . "' + WHERE bugid = $bug[bugid]" + ); + } + $message->redirect($lang->string('The comment has been deleted. You will be redirected back to the bug.'), 'showreport.php?bugid=' . $bug['bugid']); } -- 2.43.5