You are here

function ggroup_inheritance_break in Group 7

Group membership break inheritance callback.

See also

ggroup_group_member_operations()

1 string reference to 'ggroup_inheritance_break'
ggroup_group_member_operations in modules/ggroup/ggroup.group.inc
Implements hook_group_member_operations().

File

modules/ggroup/ggroup.module, line 328
Contains Subgroup functionality for the Group module.

Code

function ggroup_inheritance_break($mids) {
  $count = 0;
  foreach (group_membership_load_multiple($mids) as $group_membership) {
    if (in_array($group_membership->status, array(
      'inherited',
      'inherited-overridden',
    ))) {
      $group_membership->status = 'active';
      $group_membership->heritage = NULL;
      $group_membership->parent_mid = NULL;
      $group_membership
        ->save();
      $count++;
    }
  }
  $message = format_plural($count, 'Broke heritage of 1 membership.', 'Broke heritage of @count memberships.');
  drupal_set_message($message);
}