You are here

function _taxonomy_manager_tree_get_selected_terms in Taxonomy Manager 7

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \_taxonomy_manager_tree_get_selected_terms()
  2. 6.2 taxonomy_manager.module \_taxonomy_manager_tree_get_selected_terms()
  3. 6 taxonomy_manager.module \_taxonomy_manager_tree_get_selected_terms()

returns term ids of selected checkboxes

goes through nested form array recursivly

Parameters

$form_values:

Return value

an array with ids of selected terms

1 call to _taxonomy_manager_tree_get_selected_terms()
taxonomy_manager_tree_validate in ./taxonomy_manager.module
validates submitted form values checks if selected terms really belong to initial voc, if not --> form_set_error

File

./taxonomy_manager.module, line 967
Taxonomy Manager

Code

function _taxonomy_manager_tree_get_selected_terms($form_values, &$direct_parents = array(), $direct_parent = 0) {
  $tids = array();
  if (is_array($form_values)) {
    foreach ($form_values as $tid => $form_value) {
      if (isset($form_value['checkbox']) && $tid && $tid == $form_value['checkbox']) {
        $tids[$tid] = $tid;
        if ($direct_parent) {
          $direct_parents[$tid] = $direct_parent;
        }
      }
      if (isset($form_value['children']) && is_array($form_value['children'])) {
        $tids += _taxonomy_manager_tree_get_selected_terms($form_value['children'], $direct_parents, $tid);
      }
    }
  }
  return $tids;
}