From: garvinhicking Date: Thu, 30 Mar 2006 09:18:03 +0000 (+0000) Subject: Fix decreasing comment count when tracbkack is deleted X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=615683e34588039e575dda492a7b8602c8817f97;p=s9y.git Fix decreasing comment count when tracbkack is deleted --- diff --git a/docs/NEWS b/docs/NEWS index 7a131cf..dbb9487 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -45,6 +45,9 @@ Version 1.1-alpha1() Version 1.0 () ------------------------------------------------------------------------ + * Fix messing up comment count when deleting a trackback from admin + panel (garvinhicking) + * Fix missing UTF-8 encoding of date locales on Windows setups (garvinhicking) diff --git a/include/admin/comments.inc.php b/include/admin/comments.inc.php index f467700..fd2fca5 100644 --- a/include/admin/comments.inc.php +++ b/include/admin/comments.inc.php @@ -171,7 +171,7 @@ function FT_toggle(id) { if ( document.getElementById(id + '_full').style.display == '' ) { document.getElementById(id + '_full').style.display='none'; document.getElementById(id + '_summary').style.display=''; - document.getElementById(id + '_text').innerHTML = ''; + document.getElementById(id + '_text').innerHTML = ''; } else { document.getElementById(id + '_full').style.display=''; document.getElementById(id + '_summary').style.display='none'; @@ -387,9 +387,9 @@ foreach ($sql as $rs) { <?php echo APPROVE ?> - <?php echo VIEW; ?> + <?php echo TOGGLE_ALL; ?> - <?php echo EDIT; ?> + <?php echo VIEW; ?> <?php echo EDIT; ?> ")' title="" class="serendipityIconLink"><?php echo DELETE; ?> diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php index 11bc34f..e292926 100644 --- a/include/functions_comments.inc.php +++ b/include/functions_comments.inc.php @@ -297,6 +297,12 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace function serendipity_deleteComment($id, $entry_id, $type='comments') { global $serendipity; + $id = (int)$id; + $entry_id = (int)$entry_id; + if ($id < 1 OR $entry_id < 1) { + return false; + } + if ($_SESSION['serendipityAuthedUser'] === true) { $admin = ''; if (!serendipity_checkPermission('adminEntriesMaintainOthers')) { @@ -305,10 +311,9 @@ function serendipity_deleteComment($id, $entry_id, $type='comments') { /* We have to figure out if the comment we are about to delete, is awaiting approval, if so - we should *not* subtract it from the entries table */ - $sql = serendipity_db_query("SELECT status, parent_id, body FROM {$serendipity['dbPrefix']}comments - WHERE entry_id = ". (int)$entry_id ." - AND id = ". (int)$id ." - $admin", true); + $sql = serendipity_db_query("SELECT type, status, parent_id, body FROM {$serendipity['dbPrefix']}comments + WHERE entry_id = ". $entry_id ." + AND id = ". $id, true); /* Check to see if the comment has children @@ -316,26 +321,30 @@ function serendipity_deleteComment($id, $entry_id, $type='comments') { to delete a tree, delete children first */ $has_parent = serendipity_db_query("SELECT count(id) AS count FROM {$serendipity['dbPrefix']}comments - WHERE parent_id = ". (int)$id . " + WHERE parent_id = ". $id . " LIMIT 1", true); if (is_array($has_parent) && isset($has_parent['count']) && $has_parent['count'] > 0 && $sql['body'] != 'COMMENT_DELETED') { // Comment has childs, so don't delete it. serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET body = 'COMMENT_DELETED' - WHERE id = " . (int)$id); + WHERE id = " . $id); } else { // Comment has no childs or had already been deleted., it can be safely removed. serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}comments - WHERE entry_id = '". (int)$entry_id ."' - AND id = '". (int)$id ."' - $admin"); + WHERE entry_id = ". $entry_id ." + AND id = ". $id); if (is_array($sql) && $sql['status'] !== 'pending') { - serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = '". (int)$entry_id ."' $admin"); + if (!empty($sql['type']) && $sql['type'] != 'NORMAL') { + $type = 'trackbacks'; + } else { + $type = 'comments'; + } + serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id ." $admin"); } - serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = '" . (int)$id . "'"); + serendipity_db_query("UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = " . $id); } return true; } else {