function document_delete_types in Document 6
Same name and namespace in other branches
- 7 document.callback.inc \document_delete_types()
- 8.x document.callback.inc \document_delete_types()
1 string reference to 'document_delete_types'
- document_menu in ./
document.module - Implementation of hook_menu().
File
- ./
document.callback.inc, line 126
Code
function document_delete_types() {
try {
_document_headers();
_document_validate_token();
$ids = $_REQUEST['ids'];
if (!isset($ids)) {
die(t('Invalid input.'));
}
$ids = explode(',', $ids);
$types = document_get_types(TRUE);
foreach ($ids as $id) {
$count = db_result(db_query("SELECT COUNT(*) FROM document AS d WHERE d.type = '%s'", $types[$id]));
if ($count > 0) {
die(t('The type(s) have documents associated to them. Please delete the documents first before deleting the type.'));
}
}
foreach ($ids as $id) {
taxonomy_del_term($id);
}
cache_clear_all();
cache_clear_all('document_types', 'cache');
die;
} catch (Exception $e) {
die($e
->getMessage() + "\n" + $e
->getTraceAsString());
}
}