You are here

function og_get_group_membership in Organic groups 7

Get the group membership entity by User ID and group ID.

Parameters

$uid: User ID.

$gid: Group ID.

Return value

The OgMembership object if found, or FALSE.

9 calls to og_get_group_membership()
OgGroupMembership::testGroupMembershipCrud in ./og.test
Test group group membership create, update and delete.
OgUiSubscribeTestCase::testOgUiAddPeople in og_ui/og_ui.test
Testing adding people via group/[entity_type]/[etid]/admin/people/add-user.
og_entity_delete in ./og.module
Implements hook_entity_delete().
og_group in ./og.module
Set an association (e.g. subscribe) an entity to a group.
og_membership_create in ./og.module
Creates a new OG membership.

... See full list

1 string reference to 'og_get_group_membership'
og_group_membership_invalidate_cache in ./og.module
Reset static cache related to group membership.

File

./og.module, line 1142
Enable users to create and manage groups with roles and permissions.

Code

function og_get_group_membership($gid, $entity_type, $etid) {
  $return =& drupal_static(__FUNCTION__, array());
  $identifier = $gid . ':' . $entity_type . ':' . $etid;
  if (!isset($return[$identifier])) {
    $query = new EntityFieldQuery();
    $result = $query
      ->entityCondition('entity_type', 'og_membership')
      ->propertyCondition('entity_type', $entity_type, '=')
      ->propertyCondition('etid', $etid, '=')
      ->propertyCondition('gid', $gid, '=')
      ->execute();
    if (!empty($result['og_membership'])) {
      $key = key($result['og_membership']);
      $return[$identifier] = og_membership_load($key);
    }
  }
  return !empty($return[$identifier]) ? $return[$identifier] : FALSE;
}