+++ node_import.module	2012-02-01 16:39:56.000000000 -0800
@@ -115,12 +115,23 @@
     'access arguments' => array(3),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('node_import_delete_form', 3),
     'file' => 'node_import.admin.inc',
   );
 
+  $items['admin/content/node_import/%node_import/abort'] = array(
+    'type' => MENU_LOCAL_TASK,
+    'title' => 'Abort',
+    'weight' => 10,
+    'access callback' => 'node_import_access',
+    'access arguments' => array(3),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('node_import_abort_form', 3),
+    'file' => 'node_import.admin.inc',
+  );
+
   //TODO: %node_import/clone ? %node_import/edit ?
 
   return $items;
 }
 
 /**


+++ node_import.inc	2012-02-01 16:39:37.000000000 -0800
@@ -1119,12 +1119,27 @@
   db_query("DELETE FROM {node_import_status} WHERE taskid = %d", $taskid);
 
   module_invoke_all('node_import_task', $taskid, 'delete');
 }
 
 /**
+ * Abort an import task.
+ *
+ * @param $taskid
+ *   Unique identifier.
+ *
+ * @return
+ *   Nothing.
+ */
+function node_import_abort_task($taskid) {
+  db_query("UPDATE {node_import_tasks} SET status = %d WHERE taskid = %d", NODE_IMPORT_STATUS_DONE, $taskid);
+
+  module_invoke_all('node_import_task', $taskid, 'abort');
+}
+
+/**
  * @}
  */
 
 /**
  * @defgroup node_import_preprocess Node import preprocess functions
  * @{


+++ node_import.admin.inc	2012-02-01 16:43:01.000000000 -0800
@@ -904,12 +904,19 @@
       '#type' => 'submit',
       '#value' => t('Delete'),
       '#disabled' => $task['status'] != NODE_IMPORT_STATUS_DONE,
       '#submit' => array('node_import_view_form_submit_delete'),
     ),
 
+    'abort_task_button' => array(
+      '#type' => 'submit',
+      '#value' => t('Abort'),
+      '#disabled' => $task['status'] != NODE_IMPORT_STATUS_PENDING,
+      '#submit' => array('node_import_view_form_submit_abort'),
+    ),
+
     'add_task_button' => array(
       '#type' => 'markup',
       '#value' => l(t('New import'), 'admin/content/node_import/add'),
     ),
   );
 
@@ -1034,12 +1041,59 @@
     node_import_delete_task($form_state['values']['taskid']);
   }
 
   $form_state['redirect'] = 'admin/content/node_import';
 }
 
+function node_import_view_form_submit_abort($form, &$form_state) {
+  $destination = '';
+  if (isset($_REQUEST['destination'])) {
+    $destination = drupal_get_destination();
+    unset($_REQUEST['destination']);
+  }
+  $task = $form['#task'];
+  $form_state['redirect'] = array('admin/content/node_import/'. $task['taskid'] .'/abort', $destination);
+}
+
+/**
+ * Abort a task.
+ */
+function node_import_abort_form(&$form_state, $task) {
+  $form = array();
+
+  if ($task['status'] != NODE_IMPORT_STATUS_PENDING) {
+    $form[] = array(
+      '#type' => 'markup',
+      '#value' => t('This import task cannnot be aborted as it has finished already.'),
+    );
+
+    return $form;
+  }
+
+  $form['taskid'] = array(
+    '#type' => 'value',
+    '#value' => $task['taskid'],
+  );
+
+  return confirm_form($form,
+    t('Are you sure you want to abort %title?', array('%title' => $task['name'])),
+    isset($_GET['destination']) ? $_GET['destination'] : 'admin/content/node_import/'. $task['taskid'],
+    t('This action cannot be undone.'),
+    t('Abort'),
+    t('Cancel')
+  );
+}
+
+function node_import_abort_form_submit($form, &$form_state) {
+  if ($form_state['values']['confirm']) {
+    node_import_abort_task($form_state['values']['taskid']);
+  }
+
+  $form_state['redirect'] = 'admin/content/node_import/'.$form_state['values']['taskid'];
+}
+
 /**
  * General settings for node_import module.
  */
 function node_import_settings_form(&$form_state) {
   $form = array();
 
