You are here

function og_vocab_menu in OG Vocabulary 5

Same name and namespace in other branches
  1. 6 og_vocab.module \og_vocab_menu()
  2. 7 og_vocab.module \og_vocab_menu()

Implementation of hook_menu().

File

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

Code

function og_vocab_menu($may_cache) {
  $items = array();
  global $user;
  if ($may_cache) {

    //
  }
  else {
    $gid = arg(1);
    if ($user->uid && arg(0) == 'node' && is_numeric($gid)) {
      $node = node_load($gid);
      if (og_is_group_type($node->type) && node_access('update', $node)) {
        $items[] = array(
          'path' => "node/{$gid}/og/vocab",
          'title' => t('Categories'),
          'callback' => 'og_vocab_overview_vocabularies',
          'callback arguments' => array(
            $gid,
          ),
          'weight' => 6,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => "node/{$gid}/og/vocab/add/vocabulary",
          'title' => t('Create vocabulary'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'taxonomy_form_vocabulary',
          ),
          'type' => MENU_CALLBACK,
        );
        foreach ($node->og_vocabularies as $vid => $vocabulary) {
          $items[] = array(
            'path' => "node/{$gid}/og/vocab/terms/{$vid}",
            'title' => $vocabulary->name,
            'callback' => 'taxonomy_overview_terms',
            'callback arguments' => array(
              $vid,
            ),
            'type' => MENU_CALLBACK,
            'weight' => -10,
          );
          $items[] = array(
            'path' => "node/{$gid}/og/vocab/terms/{$vid}/list",
            'title' => t('List'),
            'type' => MENU_DEFAULT_LOCAL_TASK,
            'weight' => -10,
          );
          $items[] = array(
            'path' => "node/{$gid}/og/vocab/terms/{$vid}/add/term",
            'title' => t('Add term'),
            'callback' => 'drupal_get_form',
            'callback arguments' => array(
              'taxonomy_form_term',
              'vid' => $vid,
            ),
            'type' => MENU_LOCAL_TASK,
          );
          $items[] = array(
            'path' => "node/{$gid}/og/vocab/edit/vocabulary/{$vid}",
            'title' => t('Edit vocabulary'),
            'callback' => 'taxonomy_admin_vocabulary_edit',
            'callback arguments' => array(
              $vid,
            ),
            'type' => MENU_CALLBACK,
          );
          $terms = taxonomy_get_tree($vid);
          foreach ($terms as $key => $term) {
            $items[] = array(
              'path' => "node/{$gid}/og/vocab/edit/term/" . $term->tid,
              'title' => t('Edit term'),
              'callback' => 'taxonomy_admin_term_edit',
              'callback arguments' => $term->tid,
              'type' => MENU_CALLBACK,
            );
          }
        }
      }
    }
  }
  return $items;
}