comment_delete_multiple

Versions
7
comment_delete_multiple($cids)

Delete comments and all their replies.

Parameters

$cids The comment to delete.

▾ 5 functions call comment_delete_multiple()

comment_delete in modules/comment/comment.module
Delete a comment and all its replies.
comment_delete_multiple in modules/comment/comment.module
Delete comments and all their replies.
comment_multiple_delete_confirm_submit in modules/comment/comment.admin.inc
Process comment_multiple_delete_confirm form submissions.
comment_node_delete in modules/comment/comment.module
Implement hook_node_delete().
comment_user_cancel in modules/comment/comment.module
Implement hook_user_cancel().

Code

modules/comment/comment.module, line 1414

<?php
function comment_delete_multiple($cids) {
  $comments = comment_load_multiple($cids);
  if ($comments) {

    // Delete the comments.
    db_delete('comment')
      ->condition('cid', array_keys($comments), 'IN')
      ->execute();
    foreach ($comments as $comment) {
      field_attach_delete('comment', $comment);
      module_invoke_all('comment_delete', $comment);

      // Delete the comment's replies.
      $child_cids = db_query('SELECT cid FROM {comment} WHERE pid = :cid', array(':cid' => $comment->cid))->fetchCol();
      comment_delete_multiple($child_cids);
      _comment_update_node_statistics($comment->nid);
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.