You are here

function heartbeat_comments_multiple_delete_confirm in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 modules/heartbeat_comments/heartbeat_comments.admin.inc \heartbeat_comments_multiple_delete_confirm()

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

Parameters

$form_state: An associative array containing the current state of the form.

Return value

TRUE if the comments should be deleted, FALSE otherwise.

See also

heartbeat_comments_multiple_delete_confirm_submit()

1 string reference to 'heartbeat_comments_multiple_delete_confirm'
heartbeat_comments_admin in modules/heartbeat_comments/heartbeat_comments.admin.inc
Menu callback; present an administrative comment listing.

File

modules/heartbeat_comments/heartbeat_comments.admin.inc, line 163
Admin page callbacks for the heartbeat comments module.

Code

function heartbeat_comments_multiple_delete_confirm(&$form_state) {
  $edit = $form_state['post'];
  $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 = _heartbeat_comment_load($cid);
    $form['comments'][$cid] = array(
      '#type' => 'hidden',
      '#value' => $cid,
      '#prefix' => '<li>',
      '#suffix' => check_plain(strip_tags($comment->message)) . '</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/content/heartbeat/comments');
  }
  else {
    return confirm_form($form, t('Are you sure you want to delete these comments?'), 'admin/content/heartbeat/comments', t('This action cannot be undone.'), t('Delete heartbeat comments'), t('Cancel'));
  }
}