You are here

function comment_delete_remove_replies in Comment Delete 7

Removes comment and all replies.

Parameters

object $comment: Fully loaded comment object.

1 call to comment_delete_remove_replies()
comment_delete_options_form_submit in ./comment_delete.module
Submission handler for comment deletion form.

File

./comment_delete.module, line 220
comment_delete.module

Code

function comment_delete_remove_replies($comment) {
  $soft = variable_get('comment_delete_soft', 0);

  // Permanantely delete comment and replies.
  if (!$soft) {
    comment_delete($comment->cid);
    return;
  }

  // Soft delete comment and replies.
  $query = db_select('comment', 'c')
    ->fields('c', array(
    'cid',
  ))
    ->condition('c.nid', $comment->nid);
  $db_or = db_or();
  $db_or
    ->condition('c.thread', $comment->thread);
  $db_or
    ->condition('c.thread', str_replace('/', '.', $comment->thread) . '%', 'LIKE');
  $query
    ->condition($db_or);
  foreach ($query
    ->execute() as $reply) {
    comment_delete_soft_remove(comment_load($reply->cid));
  }
}