You are here

class context_og_reaction_set_group_context in Context OG 7

Same name and namespace in other branches
  1. 6.3 plugins/context_og_reaction_set_group_context.inc \context_og_reaction_set_group_context
  2. 7.2 plugins/context_og_reaction_set_group_context.inc \context_og_reaction_set_group_context

Expose organic groups as context reactions.

Hierarchy

Expanded class hierarchy of context_og_reaction_set_group_context

3 string references to 'context_og_reaction_set_group_context'
context_og_context_page_condition in ./context_og.module
Execute the "set group context" reaction here so that our conditions will work when they get executed. We want to come after organic groups' hook_init() so the context doesn't get switched out from under us.
context_og_context_plugins in ./context_og.module
context_og_context_registry in ./context_og.module
Implementation of hook_context_registry().

File

plugins/context_og_reaction_set_group_context.inc, line 6

View source
class context_og_reaction_set_group_context extends context_reaction {

  /**
   * Choose a group whose OG context will be set for this reaction.
   */
  function options_form($context) {
    $result = context_og_query_og_nodes();
    $options = array();
    foreach ($result as $group) {
      $type = node_type_get_name($group->type);
      $options[$group->gid] = $type . ': ' . $group->title;
    }
    $values = $this
      ->fetch_from_context($context);
    $form = array(
      'group' => array(
        '#title' => t('Group'),
        '#description' => t('Set the group context to the selected group.'),
        '#type' => 'select',
        '#multiple' => FALSE,
        '#options' => $options,
        '#default_value' => isset($values['group']) ? $values['group'] : '',
      ),
    );
    return $form;
  }
  function execute() {
    $contexts = context_active_contexts();

    //dpm($contexts);
    foreach ($contexts as $k => $v) {
      if (!empty($v->reactions[$this->plugin]['group'])) {
        $group = og_load($v->reactions[$this->plugin]['group']);
        og_context($group);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_og_reaction_set_group_context::execute function
context_og_reaction_set_group_context::options_form function Choose a group whose OG context will be set for this reaction. Overrides context_reaction::options_form
context_reaction::$description property
context_reaction::$plugin property
context_reaction::$title property
context_reaction::fetch_from_context function Retrieve options from the context provided. 1
context_reaction::get_contexts function Retrieve active contexts that have values for this reaction.
context_reaction::options_form_submit function Options form submit handler. 3
context_reaction::settings_form function Settings form. Provide variable settings for your reaction. 2
context_reaction::__clone function Clone our references when we're being cloned.
context_reaction::__construct function Constructor. Do not override.