You are here

function og_vocab_vocabulary_access in OG Vocabulary 7

Access function to determine if a user has access to the menu item.

Parameters

$entity_type: The entity type.

$entity_id: The entity ID.

$perm: The permission to check is user has.

$vocabulary: Optional; The vocabulary ID.

Return value

TRUE if user has access to the menu item.

1 string reference to 'og_vocab_vocabulary_access'
og_vocab_menu_alter in ./og_vocab.module
Implements hook_menu_alter().

File

./og_vocab.module, line 1430
Give each group its own system controlled vocabularies.

Code

function og_vocab_vocabulary_access($entity_type, $entity_id, $perm, $vocabulary = NULL) {
  if (!($entity = entity_load_single($entity_type, $entity_id))) {
    return FALSE;
  }
  if ($vocabulary) {

    // Make sure vocabulary ID belongs to the group node.
    if (!($og_vocab = og_vocab_relation_get($vocabulary->vid))) {
      return FALSE;
    }

    // Check the group matches our passed group.
    if ($og_vocab->group_type != $entity_type || $og_vocab->gid != $entity_id) {
      return FALSE;
    }
  }
  return og_user_access($entity_type, $entity_id, $perm);
}