You are here

function _taxonomy_access_get_descendants in Taxonomy Access Control 6

Same name and namespace in other branches
  1. 7 taxonomy_access.module \_taxonomy_access_get_descendants()

Get term IDs for all descendants of the given term.

Parameters

$tid: The term ID for which to fetch children

Return value

An array of the IDs of the term's descendants.

2 calls to _taxonomy_access_get_descendants()
taxonomy_access_taxonomy in ./taxonomy_access.module
Implements hook_taxonomy().
_taxonomy_access_get_nodes_for_term in ./taxonomy_access.module
Gets node ids associated with a given term.

File

./taxonomy_access.module, line 677
Allows administrators to specify how each category (in the taxonomy) can be used by various roles.

Code

function _taxonomy_access_get_descendants($tid) {
  static $descendants = array();
  if (!isset($descendants[$tid])) {
    $descendants[$tid] = array();
    $term = taxonomy_get_term($tid);
    $tree = taxonomy_get_tree($term->vid, $tid);
    foreach ($tree as $term) {
      $descendants[$tid][] = $term->tid;
    }
  }
  return $descendants[$tid];
}