aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2009-09-28 14:30:41 -0300
committerSilvio <silvio@socioambiental.org>2009-09-28 14:30:41 -0300
commitfefcc322e4b9c1e01cfe3e0b11dd1d407ff5468b (patch)
tree58aecbacac437da5260fdcae3306b8530de86393
parent2cdde905f5f8692ba4bcad2bd66642663f1572b3 (diff)
downloadnode_truncate-fefcc322e4b9c1e01cfe3e0b11dd1d407ff5468b.tar.gz
node_truncate-fefcc322e4b9c1e01cfe3e0b11dd1d407ff5468b.tar.bz2
Saving form option
-rw-r--r--node_import_truncate.module23
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) {