Same name and namespace in other branches
- 4.7.x modules/comment.module \comment_delete()
- 5.x modules/comment/comment.module \comment_delete()
- 6.x modules/comment/comment.admin.inc \comment_delete()
- 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 960 - 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));
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$output = '';
// We'll only delete if the user has confirmed the
// deletion using the form in our else clause below.
if ($comment->cid && $_POST['edit']['confirm']) {
drupal_set_message(t('The comment and all its replies have been deleted.'));
// Delete comment and its replies.
_comment_delete_thread($comment);
_comment_update_node_statistics($comment->nid);
// Clear the cache so an anonymous user sees that his comment was deleted.
cache_clear_all();
drupal_goto("node/{$comment->nid}");
}
else {
if ($comment->cid) {
$output = theme('confirm', 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'));
// Show comment that is being deleted
$comment->comment = check_output($comment->comment, $comment->format);
$output .= theme('comment', $comment);
}
else {
drupal_set_message(t('The comment no longer exists.'));
}
}
print theme('page', $output);
}