You are here

function ggroup_entity_insert in Group 7

Implements hook_entity_insert().

File

modules/ggroup/ggroup.entity.inc, line 64
Contains all Entity API functions for the Subgroup module.

Code

function ggroup_entity_insert($entity, $type) {

  // Check and run inheritance when a subgroup is created.
  if ($type == 'group' && !empty($entity->group)) {

    // Load the parent group.
    $parent = group_load($entity->group);

    // Run inheritance for all of the parent group's memberships.
    foreach ($parent
      ->getMembers() as $group_membership) {
      ggroup_run_member_inheritance($group_membership, array(
        $entity->gid,
      ));
    }
  }
  elseif ($type == 'group_membership') {

    // Run inheritance for the membership.
    ggroup_run_member_inheritance($entity);
  }
}