You are here

function ggroup_inheritance_revert in Group 7

Group membership revert inheritance callback.

See also

ggroup_group_member_operations()

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

File

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

Code

function ggroup_inheritance_revert($mids) {
  $count = 0;
  foreach (group_membership_load_multiple($mids) as $group_membership) {
    if ($group_membership->status == 'inherited-overridden') {
      $group_membership->status = 'inherited';
      $group_membership->roles = $group_membership->heritage['initial'];
      $group_membership->heritage['granted'] = array();
      $group_membership->heritage['revoked'] = array();
      $group_membership
        ->save();
      $count++;
    }
  }
  $message = format_plural($count, 'Reverted 1 membership.', 'Reverted @count memberships.');
  drupal_set_message($message);
}