You are here

function oa_core_get_taxonomy_term_access in Open Atrium Core 7.2

Helper function to determine access to create nodes of certain taxonomy terms

Parameters

$tid:

null $gid:

string $vocab_name:

1 call to oa_core_get_taxonomy_term_access()
oa_core_get_allowed_space_terms in ./oa_core.module
Helper function to return list of space blueprint term ids allowed to be created.

File

includes/oa_core.access.inc, line 703
Code for Access Control functions for OpenAtrium spaces

Code

function oa_core_get_taxonomy_term_access($tid, $gid = NULL, $vocab_name = 'space_type') {
  global $user;
  $cache =& drupal_static('oa_core_get_taxonomy_term_access', array());
  $gid = isset($gid) ? $gid : oa_core_get_space_context();
  if (isset($cache[$tid][$gid][$vocab_name])) {
    return $cache[$tid][$gid][$vocab_name];
  }
  $result = FALSE;

  // 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') || $vocab_name == 'section_type' || user_access('administer group') || user_access('create oa_space content') || og_user_access('node', $gid, 'use any oa button space_type', NULL, FALSE, TRUE)) {
    $result = TRUE;
  }
  elseif ($gid && $user->uid) {
    $result = og_user_access('node', $gid, _oa_buttons_perm_name($vocab_name, $tid), NULL, FALSE, TRUE);
  }

  // Allow other modules to override access to terms.
  $context = array(
    'tid' => $tid,
    'gid' => $gid,
    'vocab_name' => $vocab_name,
  );
  drupal_alter('oa_core_get_taxonomy_term_access', $result, $context);
  $cache[$tid][$gid][$vocab_name] = $result;
  return $result;
}