function comment_delete_options_form in Comment Delete 7
Comment deletion options and confirmation form.
Parameters
int $cid: Unique comment identification number.
1 string reference to 'comment_delete_options_form'
- comment_delete_menu_alter in ./
comment_delete.module - Implements hook_menu_alter().
File
- ./
comment_delete.module, line 126 - comment_delete.module
Code
function comment_delete_options_form($form, &$form_state, $cid) {
$comment = comment_load($cid);
if (!isset($comment->cid)) {
drupal_goto('<front>');
}
$form_state['storage']['comment'] = $comment;
$default = variable_get('comment_delete_default', 0);
$options = array();
// Define available comment deletion options.
if (user_access('delete comment replies')) {
$options[0] = t('Delete comment and replies');
}
if (user_access('move comment replies')) {
$options[1] = t('Delete comment and move replies up');
}
$options[2] = t('Delete comment and keep replies');
// Provide comment deletion radio options.
if (count($options) > 1) {
$form['action'] = array(
'#type' => 'radios',
'#title' => t('How should replies to this comment be handled?'),
'#options' => $options,
'#required' => TRUE,
'#default_value' => isset($options[$default]) ? $default : 2,
);
}
else {
$form['action'] = array(
'#type' => 'hidden',
'#value' => 2,
);
}
// Return delete comment confirmation form.
$message = t('Are you sure you want to delete the comment %title?', array(
'%title' => $comment->subject,
));
return confirm_form($form, $message, "node/{$comment->nid}", NULL, t('Delete'));
}