rework comment counter

This commit is contained in:
Garvin Hicking 2008-10-21 09:30:23 +00:00
parent 76d073762b
commit bed9db637b
2 changed files with 23 additions and 5 deletions

View File

@ -3,6 +3,10 @@
Version 1.4 ()
------------------------------------------------------------------------
* Recount trackbacks/comments when a new comment is made, instead
of carrying over an incrementing/decreminting counter for
entries, that might get off. (garvinhicking)
* Add new global config option to support OptIn confirmation for
comment subscriptions (garvinhicking)

View File

@ -652,11 +652,25 @@ function serendipity_approveComment($cid, $entry_id, $force = false, $moderate =
$lm = (int)$rs['entry_last_modified'];
}
if ($moderate) {
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field-1, last_modified=". $lm ." WHERE id='". (int)$entry_id ."'";
} else {
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field+1, last_modified=". $lm ." WHERE id='". (int)$entry_id ."'";
}
$counter_comments = serendipity_db_query("SELECT count(id) AS counter
FROM {$serendipity['dbPrefix']}comments
WHERE status = 'approved'
AND type = 'NORMAL'
AND entry_id = " . (int)$entry_id . "
GROUP BY entry_id", true);
$counter_tb = serendipity_db_query("SELECT count(id) AS counter
FROM {$serendipity['dbPrefix']}comments
WHERE status = 'approved'
AND type = 'TRACKBACK'
AND entry_id = " . (int)$entry_id . "
GROUP BY entry_id", true);
$query = "UPDATE {$serendipity['dbPrefix']}entries
SET comments = " . (int)$counter_comments['counter'] . ",
trackbacks = " . (int)$counter_comments['trackbacks'] . ",
last_modified = ". $lm ."
WHERE id = ". (int)$entry_id;
serendipity_db_query($query);
if (!$moderate) {