comment_delete

5 comment.module comment_delete($cid = NULL)
6 comment.admin.inc comment_delete($cid = NULL)
7 comment.module comment_delete($cid)
8 comment.module comment_delete($cid)

Menu callback; delete a comment.

1 string reference to 'comment_delete'

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;
}
Login or register to post comments