rework comment counter
This commit is contained in:
parent
76d073762b
commit
bed9db637b
@ -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)
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user