function _comment_delete_thread in Drupal 6
Same name and namespace in other branches
- 4 modules/comment.module \_comment_delete_thread()
- 5 modules/comment/comment.module \_comment_delete_thread()
Perform the actual deletion of a comment and all its replies.
Parameters
$comment: An associative array describing the comment to be deleted.
2 calls to _comment_delete_thread()
- comment_confirm_delete_submit in modules/
comment/ comment.admin.inc - Process comment_confirm_delete form submissions.
- comment_multiple_delete_confirm_submit in modules/
comment/ comment.admin.inc - Process comment_multiple_delete_confirm form submissions.
File
- modules/
comment/ comment.admin.inc, line 276 - Admin page callbacks for the comment module.
Code
function _comment_delete_thread($comment) {
if (!is_object($comment) || !is_numeric($comment->cid)) {
watchdog('content', 'Cannot delete non-existent comment.', array(), WATCHDOG_WARNING);
return;
}
// Delete the comment:
db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
watchdog('content', 'Comment: deleted %subject.', array(
'%subject' => $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);
}
}