You are here

function og_vocab_uri in OG Vocabulary 7

URI callback.

Return the link of admin/structure/taxonomy for privileged users, otherwise the group's admin link. If user can't access any of these, return nothing.

1 string reference to 'og_vocab_uri'
og_vocab_entity_info in ./og_vocab.module
Implements hook_entity_info().

File

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

Code

function og_vocab_uri($og_vocab) {
  $url = array();
  $vocab = taxonomy_vocabulary_load($og_vocab->vid);
  if (user_access('administer taxonomy')) {

    // URL to taxonomy administration.
    $url = array(
      'path' => "admin/structure/taxonomy/{$vocab->machine_name}/edit",
    );
  }
  else {
    $relation = og_vocab_relation_get($og_vocab->vid);
    if (og_user_access($relation->group_type, $relation->gid, 'administer taxonomy')) {

      // URL to taxonomy administration in the group context.
      $url = array(
        'path' => "group/{$relation->group_type}/{$relation->gid}/admin/taxonomy/{$vocab->machine_name}/edit",
      );
    }
  }
  if ($url) {
    $entity_type = $og_vocab->entity_type;
    $bundle = $og_vocab->bundle;
    $url['options']['fragment'] = drupal_clean_css_identifier("og-vocab-{$entity_type}-{$bundle}");
  }
  return $url;
}