View source
<?php
function comment_delete_settings_form() {
$form['comment_delete_default'] = array(
'#type' => 'radios',
'#title' => t('Default Delete Option'),
'#description' => t('Choose the default option selected when a comments deleted.'),
'#options' => array(
0 => t('Delete comment and replies'),
1 => t('Delete comment and move replies up'),
2 => t('Delete comment and keep replies'),
),
'#required' => TRUE,
'#default_value' => variable_get('comment_delete_default', 0),
);
$form['comment_delete_soft'] = array(
'#type' => 'checkbox',
'#title' => t('Soft delete comments'),
'#description' => t('When enabled the comment subject+body is cleared but comment+author is retained.'),
'#default_value' => variable_get('comment_delete_soft', 0),
);
$form['comment_delete_threshold'] = array(
'#type' => 'textfield',
'#title' => t('Threshold Period'),
'#description' => t('Max allowable time comments can be deleted after creation. Enter zero (0) to disable.'),
'#size' => 10,
'#default_value' => variable_get('comment_delete_threshold', 0),
);
$form['comment_delete_message'] = array(
'#type' => 'textarea',
'#title' => t('Confirmation Message'),
'#description' => t('Customize confirmation message shown after comment has been deleted.'),
'#default_value' => variable_get('comment_delete_message', ''),
);
return system_settings_form($form);
}
function comment_delete_settings_form_validate($form, &$form_state) {
if (!is_numeric($form_state['values']['comment_delete_threshold'])) {
form_set_error('comment_delete_threshold', t('Threshold should be greater than or equal to zero (0).'));
}
if ($form_state['values']['comment_delete_threshold'] < 0) {
form_set_error('comment_delete_threshold', t('Threshold should be greater than or equal to zero (0).'));
}
if (preg_match('/\\./i', $form_state['values']['comment_delete_threshold'])) {
form_set_error('comment_delete_threshold', t('Threshold should not include decimals.'));
}
}