You are here

function context_og_condition_member_status::execute in Context OG 7.2

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

File

plugins/context_og_condition_member_status.inc, line 30

Class

context_og_condition_member_status
Expose organic groups member status as a context condition..

Code

function execute($group) {
  global $user;
  $node_form = arg(0) == 'node' && (is_numeric(arg(1)) && arg(2) == 'edit' || arg(1) == 'add');

  // load the og_membership corresponding to the current user and group
  $og_membership = og_get_membership($group['group_type'], $group['gid'], 'user', $user->uid);
  if (!empty($og_membership)) {

    // Load all contexts that trigger on this context.
    $contexts = $this
      ->get_contexts($og_membership->state);

    // iterate over all the states and trigger contexts for
    foreach ($contexts as $context) {
      $options = $this
        ->fetch_from_context($context, 'options');

      // Check node_Form status and trigger context accordingly.
      if (!$node_form || !empty($options['node_form'])) {
        $this
          ->condition_met($context, $og_membership->state);
      }
    }
  }
}