You are here

function og_ui_delete_membership in Organic groups 7.2

Delete a single membership from group.

1 string reference to 'og_ui_delete_membership'
og_ui_menu in og_ui/og_ui.module
Implements hook_menu().

File

og_ui/og_ui.admin.inc, line 385
Admin settings for Organic groups module.

Code

function og_ui_delete_membership($form, &$form_state, $group_type, $gid, $og_membership) {
  og_set_breadcrumb($group_type, $gid, array(
    l(t('Group'), "{$group_type}/{$gid}/group"),
  ));
  $group = entity_load_single($group_type, $gid);
  $label = entity_label($group_type, $group);
  $account = user_load($og_membership->etid);

  // You can't delete the group manager.
  if (isset($group->uid) && $group->uid == $account->uid) {
    drupal_set_message(t("You can't remove membership of the group manager"));
    drupal_goto('group/' . $group_type . '/' . $gid . '/admin/people');
  }

  // Add group membership form. We still don't have the user or state.
  $form_state['og_membership'] = $og_membership;
  return confirm_form($form, t('Remove membership in group @group', array(
    '@group' => $label,
  )), 'group/' . $group_type . '/' . $gid . '/admin/people', t('Are you sure you would like to remove the membership for the user @user?', array(
    '@user' => $account->name,
  )), t('Remove'), t('Cancel'));
}