You are here

function tft_check_term_is_deletable in Taxonomy File Tree 7

Same name and namespace in other branches
  1. 7.2 tft.module \tft_check_term_is_deletable()

Check if the term has no files or child terms

1 call to tft_check_term_is_deletable()
tft_delete_term_form in ./tft.admin.inc
Delete a term form

File

./tft.admin.inc, line 599

Code

function tft_check_term_is_deletable($tid) {
  $count = (int) db_query("SELECT COUNT(tid) FROM {taxonomy_term_hierarchy} WHERE parent = :tid", array(
    ':tid' => $tid,
  ))
    ->fetchField();
  if ($count) {
    return FALSE;
  }
  $count = (int) db_query("SELECT COUNT({taxonomy_index}.nid) FROM {taxonomy_index}\n                              RIGHT JOIN {node} ON {node}.nid = {taxonomy_index}.nid\n                            WHERE {taxonomy_index}.tid = :tid", array(
    ':tid' => $tid,
  ))
    ->fetchField();
  if ($count) {
    return FALSE;
  }
  return TRUE;
}