function delete_all_content_confirm_submit in Delete all 7
Same name and namespace in other branches
- 6 delete_all.module \delete_all_content_confirm_submit()
File
- ./
delete_all.module, line 275 - Delete all 7.x module
Code
function delete_all_content_confirm_submit($form, &$form_state) {
$types = array();
$vocabularies = array();
$keys = array_filter(array_keys($form_state['values']), "_delete_all_type_keys");
foreach ($keys as $key) {
$types[] = $form_state['values'][$key];
}
if (isset($form_state['values']['taxonomy'])) {
$vocabulary_info = array();
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$vocabularies[$vocabulary->machine_name] = $vocabulary->vid;
}
}
$vkeys = array_filter(array_keys($form_state['values']), "_delete_all_vocabulary_keys");
foreach ($vkeys as $key) {
$vocabularies[] = $form_state['values'][$key];
}
switch ($form_state['values']['method']) {
case 'normal':
$count = _delete_all_normal($form_state['values']['all'], $types, $vocabularies);
break;
case 'quick':
// the quick method doesn't support an all option,
// so just get all the content types and delete all of those
if ($form_state['values']['all']) {
$result = db_query("SELECT DISTINCT type FROM {node}");
foreach ($result as $data) {
// while ($data = db_fetch_object($result)) {
$types[] = $type;
}
if ($form_state['values']['taxonomy']) {
$result = db_query("SELECT DISTINCT machine_name FROM {taxonomy_vocabulary}");
foreach ($result as $data) {
$vocabularies[] = $type;
}
}
}
$count = _delete_all_quick($types, $vocabularies);
break;
}
if (!$types) {
// Delete the URL aliases
db_query("DELETE FROM {url_alias} WHERE source LIKE 'node/%%'");
drupal_set_message(t('All nodes, comments and URL aliases have been deleted. Number of nodes deleted: !count_nodes.', array(
'!count' => check_plain($count['nodes']),
)));
if ($count['terms']) {
drupal_set_message(t('All taxonomy terms deleted. Number of terms deleted: !count_terms.', array(
'!count' => check_plain($count['terms']),
)));
}
if ($form_state['values']['reset']) {
db_query("ALTER TABLE node AUTO_INCREMENT=1");
db_query("ALTER TABLE node_revision AUTO_INCREMENT=1");
if (module_exists('comment')) {
db_query("ALTER TABLE comment AUTO_INCREMENT=1");
drupal_set_message(t('All node, revision and comment counts have been reset.'));
}
else {
drupal_set_message(t('All node and revision counts have been reset.'));
}
}
}
else {
drupal_set_message(t('Nodes and comments of type @type have been deleted. Number of nodes deleted: !count.', array(
'!count' => check_plain($count),
'@type' => implode(', ', $types),
)));
}
drupal_goto('admin');
}