You are here

function context_og_condition_group_node::execute in Context OG 7.2

Same name and namespace in other branches
  1. 6.3 plugins/context_og_condition_group_node.inc \context_og_condition_group_node::execute()
  2. 7 plugins/context_og_condition_group_node.inc \context_og_condition_group_node::execute()

File

plugins/context_og_condition_group_node.inc, line 41

Class

context_og_condition_group_node
Expose organic groups group nodes as a context condition.

Code

function execute($group) {
  if (isset($group) && $group['group_type'] == 'node') {
    $node = entity_load_single($group['group_type'], $group['gid']);
    $node_form = arg(0) == 'node' && (is_numeric(arg(1)) && arg(2) == 'edit' || arg(1) == 'add');
    if (!empty($node->nid)) {
      $contexts = $this
        ->get_contexts($node->nid);
      $this->values[$node->nid] = array();
      foreach ($contexts as $context) {
        $options = $this
          ->fetch_from_context($context, 'options');

        // The condition is met unless we are looking at a node form
        // and the "Set on node form" option is unchecked.
        if (!$node_form || !empty($options['node_form'])) {
          $this
            ->condition_met($context, $group['gid']);
        }
      }
    }
  }
}