function hs_taxonomy_hierarchical_select_root_level in Hierarchical Select 7.3
Same name and namespace in other branches
- 5.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_root_level()
- 6.3 modules/hs_taxonomy.module \hs_taxonomy_hierarchical_select_root_level()
Implementation of hook_hierarchical_select_root_level().
File
- modules/
hs_taxonomy.module, line 620 - Implementation of the Hierarchical Select API for the Taxonomy module.
Code
function hs_taxonomy_hierarchical_select_root_level($params) {
if (!isset($params['vid'])) {
return array();
}
// TODO: support multiple parents, i.e. support "save lineage".
$vocabulary = taxonomy_vocabulary_load($params['vid']);
$terms = _hs_taxonomy_hierarchical_select_get_tree($params['vid'], 0, -1, 1);
// If the root_term parameter is enabled, then prepend a fake "<root>" term.
if (isset($params['root_term']) && $params['root_term'] === TRUE) {
$root_term = new StdClass();
$root_term->tid = 0;
$root_term->name = '<' . t('root') . '>';
$terms = array_merge(array(
$root_term,
), $terms);
}
// Unset the term that's being excluded, if it is among the terms.
if (isset($params['exclude_tid'])) {
foreach ($terms as $key => $term) {
if ($term->tid == $params['exclude_tid']) {
unset($terms[$key]);
}
}
}
// If the Term Permissions module is installed, honor its settings.
if (module_exists('term_permissions')) {
global $user;
foreach ($terms as $key => $term) {
if (!term_permissions_allowed($term->tid, $user)) {
unset($terms[$key]);
}
}
}
return _hs_taxonomy_hierarchical_select_terms_to_options($terms);
}