You are here

function oa_core_get_allowed_space_types in Open Atrium Core 7.2

Allowed values callback for using particular space types.

Parameters

array $field: Field instance array for the given field.

Return value

array Associative array keyed by Taxonomy term id containing the term names.

1 string reference to 'oa_core_get_allowed_space_types'
oa_core_field_default_field_bases in ./oa_core.features.field_base.inc
Implements hook_field_default_field_bases().

File

./oa_core.module, line 1508

Code

function oa_core_get_allowed_space_types($field) {
  $options = array();
  $gid = oa_core_get_space_context();

  // If no gid, may be using this as a filter or such.
  // @see oa_subspaces_form_node_form_alter().
  if (!$gid || !module_exists('oa_subspaces') || user_access('administer group') || user_access('create oa_space content') || og_user_access('node', $gid, 'use any oa button space_type')) {
    return taxonomy_allowed_values($field);
  }
  if ($gid) {
    foreach ($field['settings']['allowed_values'] as $tree) {
      $options = $options + oa_core_get_allowed_space_terms($gid, $tree['vocabulary']);
    }
  }
  return $options;
}