You are here

function og_vocab_init in OG Vocabulary 6

Same name and namespace in other branches
  1. 5 og_vocab.module \og_vocab_init()

Implementation of hook_init().

File

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

Code

function og_vocab_init() {

  // Load include files.
  $modules = array(
    'token',
    'services',
  );
  foreach ($modules as $module) {
    if (module_exists($module)) {
      module_load_include('inc', 'og_vocab', "og_vocab.{$module}");
    }
  }

  // Since this module has to run after taxonomy and before og_menu(),
  // we just set group context.
  $item = menu_get_item();
  if ($item['path'] == 'taxonomy/term/%') {

    // Get the term id from the menu item, and from it get the vocabulary.
    $term = taxonomy_get_term($item['page_arguments'][0]);

    // Check if the vocabulary is assoicated with a group.
    if ($gid = og_vocab_get_group($term->vid)) {

      // Set the group context.
      og_set_group_context(node_load($gid));
    }
  }
}