delete

// See this thread for more info: http://drupal.org/node/92861

// Display our form
print "

Note that it may take several minutes if you are deleting a lot of nodes.

";
print drupal_get_form('form_del_all_by_node_type');

// Our form for deleteing nodes of given type
function form_del_all_by_node_type() {
$form['node_type'] = array(
'#type' => 'textfield',
'#title' => t('Content Type to delete:'),
'#description' => t('Enter the type of content to delete. This must be the exact content name used in the database.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete now'),
);
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
'id' => ' form_del_all_by_node_type',
);
return $form;
}

// We do no validation
function form_del_all_by_node_type_validate($form_id, $form_values) {
// left blank
}

// Function to delete all nodes
function form_del_all_by_node_type_submit($form_id, $form_values) {
$node_type = $form_values['values']['node_type'];

if(user_access('administer nodes')) {
$aquery = db_query("SELECT n.nid FROM {node} n WHERE n.type = '" . $node_type . "'");
$deleted_count = 0;
while ($n = db_fetch_object($aquery)) {
set_time_limit(5);
node_delete($n->nid);
$deleted_count += 1;
}
drupal_get_messages();
drupal_set_message( $deleted_count . ' nodes of type "' . $node_type . '" were found and deleted.');
}
else {
drupal_set_message(t('You do not have permission to perform this operation'));
}

}
?>