You are here

function oa_core_get_allowed_space_terms in Open Atrium Core 7.2

Helper function to return list of space blueprint term ids allowed to be created.

Parameters

int $gid (optional):

Return value

array of tids ($tid => $term->name). If NULL, all tids are allowed.

4 calls to oa_core_get_allowed_space_terms()
oa_core_create_space_access in ./oa_core.module
Menu access callback for creating space types
oa_core_form_node_form_alter in ./oa_core.module
Implements hook_form_FORM_ID_alter() node_form.
oa_core_get_allowed_space_types in ./oa_core.module
Allowed values callback for using particular space types.
oa_core_views_query_alter in ./oa_core.module
Implements hook_views_query_alter().

File

./oa_core.module, line 1529

Code

function oa_core_get_allowed_space_terms($gid = NULL, $vocab_name = 'space_type') {
  global $user;
  $gid = isset($gid) ? $gid : oa_core_get_space_context();
  $tids = array();

  // When checking OG Permission, don't let Admin Group override this since all
  // Space admins typically have Admin Group but we want to limit types of subspaces
  // to be created.
  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', NULL, FALSE, TRUE)) {
    return NULL;
  }
  if ($gid && $user->uid) {
    if ($vocabulary = oa_core_taxonomy_vocabulary($vocab_name)) {
      if ($terms = taxonomy_get_tree($vocabulary->vid)) {
        foreach ($terms as $term) {
          if (oa_core_get_taxonomy_term_access($term->tid, $gid, $vocab_name)) {
            $tids[$term->tid] = str_repeat('-', $term->depth) . $term->name;
          }
        }
      }
    }
  }
  return $tids;
}