You are here

function og_vocab_init in OG Vocabulary 5

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

File

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

Code

function og_vocab_init() {
  if (function_exists('drupal_set_content')) {

    // set group context if we own this term
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
      $sql = "SELECT ogv.nid FROM {term_data} td INNER JOIN {og_vocab} ogv ON td.vid = ogv.vid WHERE td.tid = %d";

      // arg(2) is known numeric. see 2 lines above
      if ($gid = db_result(db_query($sql, arg(2)))) {
        og_set_group_context(node_load($gid));

        // again, breadcrumb is not correct here but menu system hasn't built yet.
      }
    }
  }
}