You are here

function comment_delete_form in Comment Delete 6

Confirmation form for deleting a comment.

1 string reference to 'comment_delete_form'
comment_delete_menu_alter in ./comment_delete.module
Implementation of hook_menu_alter().

File

./comment_delete.module, line 92

Code

function comment_delete_form($form_state, $cid) {
  $comment = _comment_load($cid);
  if ($comment->cid) {

    // Store the comment ID for the submit processor.
    $form['cid'] = array(
      '#type' => 'hidden',
      '#value' => $cid,
    );

    // Allow permissible users to determine how replies of this comment should be handled when
    // it is deleted. Users without permissions to change this will use the default setting.
    if ($actions = comment_delete_reply_actions()) {
      $form['replies'] = array(
        '#type' => 'select',
        '#title' => t('Action for replies'),
        '#description' => t('Specify how replies should be handled when deleting a comment.'),
        '#options' => $actions,
        '#required' => TRUE,
        '#default_value' => variable_get('comment_delete_replies', 0),
      );
    }
    else {
      $form['replies'] = array(
        '#type' => 'hidden',
        '#value' => variable_get('comment_delete_replies', 0),
      );
    }

    // Return the form as a confirmation.
    $msg = t("Are you sure you want to delete the comment %title?", array(
      '%title' => $comment->subject,
    ));
    return confirm_form($form, $msg, "node/{$comment->nid}", NULL, t('Delete'));
  }
  else {
    drupal_set_message(t('This comment no longer exists.'));
    drupal_goto('');
  }
}