function _delete_all_normal in Delete all 7
Same name and namespace in other branches
- 5 delete_all.module \_delete_all_normal()
- 6 delete_all.module \_delete_all_normal()
2 calls to _delete_all_normal()
- delete_all_content_confirm_submit in ./
delete_all.module - delete_all_drush_delete in ./
delete_all.drush.inc - Drush callback to delete content
File
- ./
delete_all.module, line 345 - Delete all 7.x module
Code
function _delete_all_normal($all, $types, $vocabularies = NULL) {
$deleted = array(
'nodes' => 0,
'terms' => 0,
);
if (is_array($types) && count($types) > 0) {
foreach ($types as $type) {
$result = db_query('SELECT nid FROM {node} WHERE type = :type', array(
':type' => $type,
));
}
}
else {
$result = db_query('SELECT nid FROM {node}');
}
if ($result) {
foreach ($result as $data) {
set_time_limit(30);
node_delete($data->nid);
$deleted['nodes']++;
}
}
if ($vocabularies) {
$vocabulary_info = array();
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$vocabulary_info[$vocabulary->machine_name] = $vocabulary->vid;
}
foreach ($vocabularies as $vocabulary) {
foreach (taxonomy_get_tree($vocabulary_info[$vocabulary]) as $term) {
taxonomy_term_delete($term->tid);
$deleted['terms']++;
}
}
}
return $deleted;
}