You are here

class og_subgroups_context_condition_node_below_og in Subgroups for Organic groups 6

Enable OG Subgroups to trigger a condition based on node's position below the OG defined in the condition.

Hierarchy

Expanded class hierarchy of og_subgroups_context_condition_node_below_og

2 string references to 'og_subgroups_context_condition_node_below_og'
og_subgroups_context_context_plugins in modules/og_subgroups_context/og_subgroups_context.module
Implementation of hook_context_plugins()
og_subgroups_context_context_registry in modules/og_subgroups_context/og_subgroups_context.module
Implementation of hook_context_registry()

File

modules/og_subgroups_context/plugins/og_subgroups_context_condition_node_below_og.inc, line 7

View source
class og_subgroups_context_condition_node_below_og extends context_condition {

  /**
   * Condition values
   */
  function condition_values() {
    og_subgroups_include('form');

    // Load the options with hierarchy indents
    $values = og_subgroups_group_select_options();

    // Remove the default first option (no group)
    if (isset($values[0])) {
      unset($values[0]);
    }
    return $values;
  }

  /**
   * Execute the plugin
   */
  function execute() {
    if ($this
      ->condition_used()) {

      // Determine the group we're in
      if ($group = og_subgroups_context_current_group()) {
        foreach ($this
          ->get_contexts($value) as $context) {
          og_subgroups_include('tree');

          // Get groups selected in our conditions when context was defined.
          $selected = $context->conditions['og_subgroups_context_condition_node_below_og']['values'];

          // Iterate each of the selected groups
          foreach ($selected as $pid) {

            // Build a parent object to pass
            $parent = new stdClass();
            $parent->nid = $pid;

            // See if the current group is a child of the parent
            if (og_subgroups_group_is_child($parent, $group)) {

              // Activate the context
              $this
                ->condition_met($context, $parent->nid);

              // Stop here
              break;
            }
          }
        }
      }
    }
  }

}

Members