You are here

function oa_files_get_vocab_options in Open Atrium Files 7.2

Helper function to determine which vocabularies are allowed on this content type

1 call to oa_files_get_vocab_options()
oa_files_treeview_settings_form in plugins/content_types/oa_files_treeview.inc
Empty config form

File

plugins/content_types/oa_files_treeview.inc, line 1039

Code

function oa_files_get_vocab_options($type = 'oa_wiki_page') {
  $vids = array();
  $vocab_names = array();

  // first grab any taxonomy reference fields on the content type
  $field_info = field_info_fields();
  $fields = field_info_instances('node', $type);
  foreach ($fields as $key => $field) {
    $info = $field_info[$key];
    if ($info['module'] == 'taxonomy') {
      foreach ($info['settings']['allowed_values'] as $index => $item) {
        $vocab_names[] = $item['vocabulary'];
      }
    }
  }

  // if using og_vocab, grab the valid vocab ids.
  if (module_exists('og_vocab')) {
    $vids = og_vocab_get_accessible_vocabs('node', $type, OG_VOCAB_FIELD);
  }
  $result = array();
  foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
    if (in_array($vid, $vids) || in_array($vocab->machine_name, $vocab_names)) {
      $result[$vid] = $vocab->name;
    }
  }
  return $result;
}