function _hs_content_taxonomy_term_within_allowed_depth in Hierarchical Select 6.3
Same name and namespace in other branches
- 5.3 modules/hs_content_taxonomy.module \_hs_content_taxonomy_term_within_allowed_depth()
1 call to _hs_content_taxonomy_term_within_allowed_depth()
- hs_content_taxonomy_hierarchical_select_valid_item in modules/
hs_content_taxonomy.module - Implementation of hook_hierarchical_select_valid_item().
File
- modules/
hs_content_taxonomy.module, line 540 - Implementation of the Hierarchical Select API for the Content Taxonomy module.
Code
function _hs_content_taxonomy_term_within_allowed_depth($tid, $vid, $root_tid, $allowed_depth) {
// If the allowed depth is zero, then every term is allowed!
if ($allowed_depth == 0) {
return TRUE;
}
// Otherwise, only allow terms that are within the allowed depth.
static $valid_tids;
if (!isset($valid_tids[$vid][$root_tid][$allowed_depth])) {
$valid_tids[$vid][$root_tid][$allowed_depth] = array();
$tree = _hs_taxonomy_hierarchical_select_get_tree($vid, $root_tid);
foreach ($tree as $term) {
if ($term->depth < $allowed_depth) {
$valid_tids[$vid][$root_tid][$allowed_depth][] = $term->tid;
}
}
}
return in_array($tid, $valid_tids[$vid][$root_tid][$allowed_depth]);
}