You are here

function _taxonomy_access_get_vocabulary_terms in Taxonomy Access Control 7

Gets term IDs for all terms in the vocabulary

Parameters

int $vocab_id: The vocabulary ID for which to fetch children.

Return value

array An array of the IDs of the terms in in the vocabulary.

Related topics

File

./taxonomy_access.module, line 890
Allows administrators to specify access control for taxonomy categories.

Code

function _taxonomy_access_get_vocabulary_terms($vocab_id) {
  static $descendants = array();
  if (!isset($descendants[$vocab_id])) {

    // Preserve the original state of the list flag.
    $flag_state = taxonomy_access_list_enabled();

    // Enforce that list grants do not filter the results.
    taxonomy_access_disable_list();
    $descendants[$vocab_id] = array();
    $tree = taxonomy_get_tree($vocab_id);
    foreach ($tree as $term) {
      $descendants[$vocab_id][] = $term->tid;
    }

    // Restore list flag to previous state.
    if ($flag_state) {
      taxonomy_access_enable_list();
    }
    unset($term);
    unset($tree);
  }
  return $descendants[$vocab_id];
}