_comment_delete_thread
- Versions
- 4.6 – 6
_comment_delete_thread($comment)
Code
modules/comment.module, line 1623
<?php
function _comment_delete_thread($comment) {
if (!is_object($comment) || !is_numeric($comment->cid)) {
watchdog('content', t('Can not delete non-existent comment.'), WATCHDOG_WARNING);
return;
}
// Delete the comment:
db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
watchdog('content', t('Comment: deleted %subject.', array('%subject' => theme('placeholder', $comment->subject))));
comment_invoke_comment($comment, 'delete');
// Delete the comment's replies
$result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
_comment_delete_thread($comment);
}
}
?>Login or register to post comments 