membership_delete.action.inc 724 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php

/**
 * @file
 * Action to set the state of a user in a group.
 */

function og_membership_delete_action_info() {
  return array('og_membership_delete_action' => array(
    'type' => 'og_membership',
11
    'label' => t('Remove from group'),
12
    'behavior' => array('deletes_property'),
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    'configurable' => FALSE,
  ));
}

function og_membership_delete_action($og_membership, $context) {
  $group_type = $og_membership->group_type;
  $gid = $og_membership->gid;

  // Don't process the group manager, if exists.
  $group = entity_load_single($group_type, $gid);
  if (!empty($group->uid) && $group->uid == $og_membership->etid && $og_membership->entity_type == 'user') {
    return;
  }

  $og_membership->delete();

}