You are here

function opigno_load_og_membership in Opigno 7

1 string reference to 'opigno_load_og_membership'
opigno_rules_action_info in ./opigno.rules.inc

File

./opigno.rules.inc, line 250

Code

function opigno_load_og_membership($user, EntityDrupalWrapper $group, $settings) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'og_membership', '=')
    ->propertyCondition('gid', $group
    ->getIdentifier(), '=')
    ->propertyCondition('group_type', $group
    ->type(), '=')
    ->propertyCondition('entity_type', 'user', '=')
    ->propertyCondition('etid', $user->uid, '=');
  $result = $query
    ->execute();
  if (!empty($result['og_membership'])) {
    $og_membership = og_membership_load(current($result['og_membership'])->id);
  }
  else {
    $og_membership = NULL;
  }
  return array(
    'og_membership' => $og_membership,
  );
}