diff options
-rw-r--r-- | node_import_truncate.module | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/node_import_truncate.module b/node_import_truncate.module index 7d5abf9..c9a403c 100644 --- a/node_import_truncate.module +++ b/node_import_truncate.module @@ -33,9 +33,10 @@ function node_import_truncate_form(&$form_state, $taskid = null) { '#value' => $taskid, ); $form['mass_delete'] = array( - '#type' => 'checkbox', - '#title' => t('Pre-import mass deletion'), - '#description' => t('Delete old content before importing new data.'), + '#type' => 'checkbox', + '#title' => t('Pre-import mass deletion'), + '#description' => t('Delete old content before importing new data.'), + '#default_value' => variable_get('node_import_truncate', '0'), ); $form['submit'] = array( '#type' => 'submit', @@ -45,10 +46,20 @@ function node_import_truncate_form(&$form_state, $taskid = null) { } /** + * Implementation of hook_validate(); + */ +function node_import_truncate_form_validate($form, $form_state) { + if (!isset($form_state['values']['mass_delete'])) { + form_set_error('mass_delete', t('Please choose an option')); + } +} + +/** * Handle post-validation form-submission. */ function node_import_truncate_form_submit($form, &$form_state) { $mass_delete = $form_state['values']['mass_delete']; + variable_set('node_import_truncate', $mass_delete); if (isset($form_state['values']['taskid']['#value'])) { $taskid = $form_state['values']['taskid']['#value']; @@ -79,9 +90,9 @@ function node_import_truncate_form_submit($form, &$form_state) { /** * Implementation of hook_node_import_task(); * - * As the user is probably adding a spreadsheet containing - * old and new content, we need to make sure to remove all - * previous content to prevent duplicate data in the + * As the user may be adding a spreadsheet containing + * old and new content, we need to check whether to remove + * all previous content to prevent duplicate data in the * database. */ function node_import_truncate_node_import_task($task, $op) { |