You are here

function advanced_forum_forum_context_create_forum in Advanced Forum 6.2

Same name and namespace in other branches
  1. 7.2 plugins/contexts/forum.inc \advanced_forum_forum_context_create_forum()

It's important to remember that $conf is optional here, because contexts are not always created from the UI.

1 string reference to 'advanced_forum_forum_context_create_forum'
advanced_forum_forum_ctools_contexts in plugins/contexts/forum.inc
Implementation of specially named hook_advanced_forum_forum_contexts().

File

plugins/contexts/forum.inc, line 34
Plugin to provide a user context

Code

function advanced_forum_forum_context_create_forum($empty, $data = NULL, $conf = FALSE) {
  $context = new ctools_context(array(
    'forum',
    'term',
  ));
  $context->plugin = 'forum';
  if ($empty) {
    return $context;
  }
  if ($conf) {
    if ($data['tid']) {
      $data = taxonomy_get_term($data['tid']);
    }
    else {
      $data = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', ''));
      $data->tid = 0;
    }
  }
  if (!empty($data)) {
    $data->container = !$data->tid || in_array($data->tid, variable_get('forum_containers', array()));
    $context->data = drupal_clone($data);
    $context->title = $data->name;
    $context->argument = $data->tid;
    $context->vid = variable_get('forum_nav_vocabulary', '');
    $context->vocabulary = taxonomy_vocabulary_load($context->vid);
    if ($data->tid) {
      $context->parents = taxonomy_get_parents_all($data->tid);
    }
    return $context;
  }
}