You are here

function og_get_entity_state in Organic groups 7

Get the state of an entity in a group.

Parameters

$entity_type: The entity type.

$entity: The entity object.

$gid: The group ID.

Return value

The state value, or FALSE is entity is not associated with group.

1 call to og_get_entity_state()
og_ui_og_user_access_alter in og_ui/og_ui.module
Implements hook_og_user_access_alter().

File

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

Code

function og_get_entity_state($gid, $entity_type, $entity) {
  $state = FALSE;
  $entity = og_load_entity($entity_type, $entity);
  $property = OG_AUDIENCE_FIELD;
  $wrapper =& $entity->{$property}[LANGUAGE_NONE];
  if (!empty($wrapper)) {
    foreach ($wrapper as $key => $value) {
      if ($value['gid'] == $gid) {
        $state = $value['state'];
        break;
      }
    }
  }
  return $state;
}