function tft_delete_term_form in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 includes/tft.pages.inc \tft_delete_term_form()
Delete a term form
1 string reference to 'tft_delete_term_form'
- tft_menu in ./
tft.module - Implementation of hook_menu().
File
- ./
tft.admin.inc, line 515
Code
function tft_delete_term_form($form, $form_state, $tid) {
// Check that a vocabulary is set for Taxonomy File Tree
tft_check_vocabulary_setting();
if (!tft_term_access($tid)) {
drupal_set_message(t("You do not have access to this folder. You cannot modify or delete it."), 'error');
if ($destination = str_replace('%23', '#', $_GET['destination'])) {
drupal_goto($destination);
}
else {
drupal_goto();
}
}
if (tft_is_archive_folder($tid)) {
drupal_set_message(t("Archive folders cannot be deleted."), 'error');
if ($destination = str_replace('%23', '#', $_GET['destination'])) {
drupal_goto($destination);
}
else {
drupal_goto();
}
}
$name = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
// If no name was found
if (!$name) {
drupal_set_message(t("An error occured. The '@tid' folder could not be found. Please contac tthe site administrator.", array(
'@tid' => $tid,
)), 'error');
if ($destination = str_replace('%23', '#', $_GET['destination'])) {
drupal_goto($destination);
}
else {
drupal_goto();
}
}
// Check that this term has no child terms or files
if (tft_check_term_is_deletable($tid)) {
drupal_set_title(t("Are you sure you want to delete the folder @term ?", array(
'@term' => $name,
)));
$form['tid'] = array(
'#type' => 'hidden',
'#value' => $tid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t("Delete"),
'#attributes' => array(
'class' => array(
'delete-button',
),
),
);
$form['cancel'] = array(
'#markup' => '<a href="/' . str_replace('%23', '#', $_GET['destination']) . '">' . t("cancel") . '</a>',
);
return $form;
}
else {
drupal_set_message(t("<em>@name</em> contains files and/or child folders. Move or delete these before deleting this folder.", array(
'@name' => $name,
)), 'error');
if ($destination = str_replace('%23', '#', $_GET['destination'])) {
drupal_goto($destination);
}
else {
drupal_goto();
}
}
}