You are here

function context_og_condition_member_role::execute in Context OG 7.2

File

plugins/context_og_condition_member_role.inc, line 43

Class

context_og_condition_member_role
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 current roles for the user.
  $roles = og_get_user_roles($group['group_type'], $group['gid'], $user->uid);
  if (!empty($roles)) {

    // Load all contexts that trigger on this context.
    foreach ($roles as $rid => $name) {
      $contexts = $this
        ->get_contexts($rid);
      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, $rid);
        }
      }
    }
  }
}