You are here

function hs_taxonomy_hierarchical_select_valid_item in Hierarchical Select 6.3

Same name and namespace in other branches
  1. 5.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_valid_item()
  2. 7.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_valid_item()

Implementation of hook_hierarchical_select_valid_item().

1 call to hs_taxonomy_hierarchical_select_valid_item()
hs_taxonomy_views_hierarchical_select_valid_item in modules/hs_taxonomy_views.module
Implementation of hook_hierarchical_select_valid_item().

File

modules/hs_taxonomy.module, line 477
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;
  }
  else {
    if (!is_numeric($item) || $item < 1 || isset($params['exclude_tid']) && $item == $params['exclude_tid']) {
      return FALSE;
    }
  }
  $term = taxonomy_get_term($item);

  // If the Term Permissions module is installed, honor its settings.
  if (function_exists('term_permissions_allowed')) {
    global $user;
    if (!term_permissions_allowed($term->tid, $user)) {
      return FALSE;
    }
  }
  return $term->vid == $params['vid'];
}