Same name and namespace in other branches
  1. 4.6.x modules/comment.module \comment_delete()
  2. 5.x modules/comment/comment.module \comment_delete()
  3. 6.x modules/comment/comment.admin.inc \comment_delete()
  4. 7.x modules/comment/comment.module \comment_delete()

Menu callback; delete a comment.

1 string reference to 'comment_delete'
comment_menu in modules/comment.module
Implementation of hook_menu().

File

modules/comment.module, line 871
Enables users to comment on published content.

Code

function comment_delete($cid) {
  $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
  $output = '';
  if (is_object($comment) && is_numeric($comment->cid)) {
    $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
    $form = array();
    $form['comment'] = array(
      '#type' => 'value',
      '#value' => $comment,
    );
    $output = confirm_form('comment_confirm_delete', $form, t('Are you sure you want to delete the comment %title?', array(
      '%title' => theme('placeholder', $comment->subject),
    )), 'node/' . $comment->nid, t('Any replies to this comment will be lost. This action cannot be undone.'), t('Delete'), t('Cancel'));
  }
  else {
    drupal_set_message(t('The comment no longer exists.'));
  }
  return $output;
}