function bulkdelete_form_submit in Bulk Delete 6
Same name and namespace in other branches
- 7 bulkdelete.admin.inc \bulkdelete_form_submit()
File
- ./bulkdelete.admin.inc, line 48
Code
function bulkdelete_form_submit($form, &$form_state) {
$quick = $form_state['values']['quick'];
$types = array_filter($form_state['values']['types']);
if (count($types) > 0) {
if ($quick) {
$node_deletes = array();
foreach (module_list() as $module) {
foreach ($types as $type) {
$node = array(
'type' => $type,
);
$module = node_get_types('module', $node);
if ($module === 'node') {
$module = 'node_content';
}
if ($hook = module_hook($module, 'delete')) {
$node_deletes[] = $hook;
}
}
}
}
$placeholders = implode(',', array_fill(0, count($types), "'%s'"));
$result = db_query("SELECT nid FROM {node} WHERE type IN ({$placeholders})", $types);
$operations = array();
$operations[] = array(
'trim',
array(
'',
),
);
$count = 0;
while ($row = db_fetch_object($result)) {
$nids[] = $row->nid;
++$count;
if ($count % 20 === 1) {
if ($quick) {
$operations[] = array(
'bulkdelete_node_delete_quick',
array(
$nids,
$node_deletes,
),
);
}
else {
$operations[] = array(
'bulkdelete_node_delete_standard',
array(
$nids,
$node_deletes,
),
);
}
$nids = array();
}
}
if ($quick) {
$operations[] = array(
'bulkdelete_node_delete_quick',
array(
$nids,
$node_deletes,
),
);
}
else {
$operations[] = array(
'bulkdelete_node_delete_standard',
array(
$nids,
$node_deletes,
),
);
}
$operations[] = array(
'cache_clear_all',
array(),
);
$count2 = count($operations);
$batch = array(
'operations' => $operations,
'finished' => '',
'title' => t('Deleting !count nodes in !count2 operations.', array(
'!count' => $count,
'!count2' => $count2,
)),
);
batch_set($batch);
batch_process();
}
}