You are here

function comment_multiple_delete_confirm in Drupal 4

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

List the selected comments and verify that the admin really wants to delete them.

1 call to comment_multiple_delete_confirm()
comment_admin_overview in modules/comment.module
Menu callback; present an administrative comment listing.

File

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

Code

function comment_multiple_delete_confirm() {
  $edit = $_POST['edit'];
  $form['comments'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );

  // array_filter() returns only elements with actual values
  $comment_counter = 0;
  foreach (array_filter($edit['comments']) as $cid => $value) {
    $comment = _comment_load($cid);
    if (is_object($comment) && is_numeric($comment->cid)) {
      $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid));
      $form['comments'][$cid] = array(
        '#type' => 'hidden',
        '#value' => $cid,
        '#prefix' => '<li>',
        '#suffix' => check_plain($subject) . '</li>',
      );
      $comment_counter++;
    }
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );
  if (!$comment_counter) {
    drupal_set_message(t('There do not appear to be any comments to delete or your selected comment was deleted by another administrator.'));
    drupal_goto('admin/comment');
  }
  else {
    return confirm_form('comment_multiple_delete_confirm', $form, t('Are you sure you want to delete these comments and all their children?'), 'admin/comment', t('This action cannot be undone.'), t('Delete comments'), t('Cancel'));
  }
}