diff options
author | Silvio <silvio@devlet.com.br> | 2011-02-11 12:46:37 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2011-02-11 12:46:37 -0200 |
commit | e51136b7524098d554114a971a2749b744455c2b (patch) | |
tree | d47669dcd50360a23d860a007d0aaadaebb9a2b1 | |
parent | 99e27e29847ab105e3a57c7d2aa409c8d0e9b35e (diff) | |
download | node_truncate-e51136b7524098d554114a971a2749b744455c2b.tar.gz node_truncate-e51136b7524098d554114a971a2749b744455c2b.tar.bz2 |
Converting do 7.x API
-rw-r--r-- | node_truncate.info | 4 | ||||
-rw-r--r-- | node_truncate.module | 21 |
2 files changed, 13 insertions, 12 deletions
diff --git a/node_truncate.info b/node_truncate.info index 6b0c838..0942e29 100644 --- a/node_truncate.info +++ b/node_truncate.info @@ -2,5 +2,5 @@ name = Node Truncate description = Delete all posts from content types. package = Development -core = 6.x -version = "6.x-0.1" +core = 7.x +version = "7.x-0.1" diff --git a/node_truncate.module b/node_truncate.module index a6fc829..a4f34fe 100644 --- a/node_truncate.module +++ b/node_truncate.module @@ -12,7 +12,7 @@ * Implementation of hook_menu(); */ function node_truncate_menu() { - $items['admin/content/node_truncate'] = array( + $items['admin/config/content/node_truncate'] = array( 'title' => 'Node Truncate', 'description' => 'Mass deletion page.', 'page callback' => 'node_truncate_page', @@ -27,15 +27,15 @@ function node_truncate_menu() { */ function node_truncate_page() { $output = t('Choose a content type to truncate.'); - $output .= drupal_get_form('node_truncate_form'); + $output .= drupal_render(drupal_get_form('node_truncate_form')); return $output; } /** * Mass deletion form. */ -function node_truncate_form(&$form_state) { - $node_types = node_get_types(); +function node_truncate_form($form, &$form_state) { + $node_types = node_type_get_types(); $node_codes = array(); foreach ($node_types as $item) { @@ -86,26 +86,27 @@ function node_truncate_form_submit($form, &$form_state) { ); batch_set($batch); - batch_process($redirect); + batch_process(); } /** * Mass deletion of content. */ function node_truncate($type, &$context) { - $type = 'WHERE type = "' . $type . '"'; + $where = '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)); + $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node} ' . $where, + array(':type' => $type))->fetchField(); } $limit = 5; - $result = db_query_range('SELECT nid FROM {node} ' . $type, $context['sandbox']['current_node'], 0, $limit); - while ($row = db_fetch_array($result)) { + $result = db_query_range('SELECT node.nid FROM {node} ' . $where, 0, $limit, array(':type' => $type)); + while ($row = $result->fetchAssoc()) { $node = node_delete($row['nid'], NULL, TRUE); $context['sandbox']['progress']++; $context['sandbox']['current_node'] = $node->nid; - $context['results'][] = $node->nid .' : '. check_plain($node->title); + $context['results'][] = $node->nid . ' : ' . check_plain($node->title); $context['message'] = check_plain($node->title); } if ($context['sandbox']['progress'] != $context['sandbox']['max']) { |