You are here

function workbench_email_scheme_taxonomy_get_parents in Workbench Email 7.3

Function to get all the parents of the workbench access's section.

Parameters

array $sections: The available sections.

Return value

mixed The available sections.

1 call to workbench_email_scheme_taxonomy_get_parents()
workbench_email_get_workbench_access_editors in ./workbench_email.module
Get all the editors of workbench access section.

File

./workbench_email.module, line 864
Code for the Workbench Email Module.

Code

function workbench_email_scheme_taxonomy_get_parents($sections) {
  if (!is_array($sections)) {
    $value = $sections;
    $sections = array();
    $sections[] = $value;
  }
  $terms = taxonomy_term_load_multiple($sections);

  // Get all parents.
  foreach ($terms as $term) {
    $parents = taxonomy_get_parents_all($term->tid);
    if (!empty($parents)) {
      foreach ($parents as $parent) {
        $tid = $parent->tid;
        $voc_name = $parent->vocabulary_machine_name;
        if (!in_array($tid, $sections)) {
          $sections[$tid] = $tid;
        }
      }

      // Add the vocabulary name.
      $sections[$voc_name] = $voc_name;
    }
  }
  return $sections;
}