You are here

function advanced_forum_argument_forum_id_context in Advanced Forum 6.2

Same name and namespace in other branches
  1. 7.2 plugins/arguments/forum_id.inc \advanced_forum_argument_forum_id_context()

Discover if this argument gives us the user we crave.

1 string reference to 'advanced_forum_argument_forum_id_context'
advanced_forum_forum_id_ctools_arguments in plugins/arguments/forum_id.inc
Implementation of specially named hook_ctools_arguments().

File

plugins/arguments/forum_id.inc, line 32
Plugin to provide an argument handler for a user id

Code

function advanced_forum_argument_forum_id_context($arg = NULL, $conf = NULL, $empty = FALSE) {

  // If unset it wants a generic, unfilled context.
  if ($empty) {
    return ctools_context_create_empty('forum');
  }
  if (!is_numeric($arg)) {
    return NULL;
  }
  if ($arg != 0) {
    $term = taxonomy_get_term($arg);
  }
  if ($arg == 0 || empty($term) || $term->vid != variable_get('forum_nav_vocabulary', '')) {
    $term = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', ''));
    $term->tid = 0;
  }
  if (!$term) {
    return NULL;
  }
  return ctools_context_create('forum', $term);
}