aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-10-08 16:20:00 -0300
committerSilvio <silvio@devlet.com.br>2010-10-08 16:20:00 -0300
commit0ab063b89c69227012492fcc88173a42cdcfd083 (patch)
tree9b9955675a0c98763067bd85c600c0c8c565e97b
parent50d19224d34e2d1da0dae3093bcdd21f1d71aff2 (diff)
downloadnode_import_truncate-0ab063b89c69227012492fcc88173a42cdcfd083.tar.gz
node_import_truncate-0ab063b89c69227012492fcc88173a42cdcfd083.tar.bz2
Using node_truncate as a dependency
-rw-r--r--node_import_truncate.info3
-rw-r--r--node_import_truncate.module43
2 files changed, 4 insertions, 42 deletions
diff --git a/node_import_truncate.info b/node_import_truncate.info
index fa3dc9e..28b2a08 100644
--- a/node_import_truncate.info
+++ b/node_import_truncate.info
@@ -3,5 +3,6 @@ name = Node Import Truncate
description = Allow to truncate a content type before importing data.
package = Development
core = 6.x
+version = "6.x-0.2"
dependencies[] = node_import
-version = "6.x-0.1"
+dependencies[] = node_truncate
diff --git a/node_import_truncate.module b/node_import_truncate.module
index 9a88fb1..ac75a71 100644
--- a/node_import_truncate.module
+++ b/node_import_truncate.module
@@ -83,9 +83,9 @@ function node_import_truncate_form_submit($form, &$form_state) {
$batch = array(
'title' => t('Deleting old data.'),
'operations' => array(
- array('node_import_truncate', array($type)),
+ array('node_truncate', array($type)),
),
- 'finished' => 'node_import_truncate_callback',
+ 'finished' => 'node_truncate_callback',
);
batch_set($batch);
@@ -108,42 +108,3 @@ function node_import_truncate_node_import_task($task, $op) {
drupal_goto('admin/content/node_import/truncate/' . $task['taskid']);
}
}
-
-/**
- * Mass deletion of content.
- */
-function node_import_truncate($type, &$context) {
- $type = 'WHERE type = "' . $type . '"';
- if (empty($context['sandbox'])) {
- $context['sandbox']['progress'] = 0;
- $context['sandbox']['current_node'] = 0;
- $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node} ' . $type));
- }
- $limit = 5;
- $result = db_query_range('SELECT nid FROM {node} ' . $type, $context['sandbox']['current_node'], 0, $limit);
- while ($row = db_fetch_array($result)) {
- $node = node_delete($row['nid'], NULL, TRUE);
- $context['sandbox']['progress']++;
- $context['sandbox']['current_node'] = $node->nid;
- $context['results'][] = $node->nid .' : '. $node->title;
- $context['message'] = $node->title;
- }
- if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
- $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
- }
-}
-
-/**
- * Callback for node_import_truncate();
- */
-function node_import_truncate_callback($success, $results, $operations) {
- if ($success) {
- if ($results > 0) {
- $message = format_plural(count($results), t('One old post processed.'), t('@count old posts processed.'));
- }
- }
- else {
- $message = t('Finished with an error.');
- }
- drupal_set_message($message);
-}