function hs_taxonomy_hierarchical_select_valid_item in Hierarchical Select 7.3
Same name and namespace in other branches
- 5.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_valid_item()
- 6.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_valid_item()
Implements hook_hierarchical_select_valid_item().
File
- modules/
hs_taxonomy.module, line 738 - Implementation of the Hierarchical Select API for the Taxonomy module.
Code
function hs_taxonomy_hierarchical_select_valid_item($item, $params) {
if (isset($params['root_term']) && $params['root_term'] && $item == 0) {
return TRUE;
}
if (!is_numeric($item) || $item < 1 || isset($params['exclude_tid']) && $item == $params['exclude_tid']) {
return FALSE;
}
$term = taxonomy_term_load($item);
if (!$term) {
return FALSE;
}
// If the Term Permissions module is installed, honor its settings.
if (module_exists('term_permissions')) {
global $user;
if (!term_permissions_allowed($term->tid, $user)) {
return FALSE;
}
}
if (!isset($params['root_term'])) {
$params['root_term'] = NULL;
}
if (!isset($params['allowed_max_depth'])) {
$params['allowed_max_depth'] = 0;
}
return $term->vid == $params['vid'] && _hs_taxonomy_term_within_allowed_depth($term->tid, $term->vid, $params['root_term'], $params['allowed_max_depth']);
}