You are here

function group_membership_cancel_form in Group 7

Group membership cancel form.

1 string reference to 'group_membership_cancel_form'
GroupMembershipUIController::hook_menu in classes/group_membership.ui_controller.inc
Provides definitions for implementing hook_menu().

File

admin/group_membership.inc, line 493
Group membership overview admin UI.

Code

function group_membership_cancel_form($form, &$form_state, GroupMembership $group_membership) {
  global $user;
  $account = user_load($group_membership->uid);
  $group = group_load($group_membership->gid);
  $unsubscribe_self = $user->uid == $group_membership->uid;
  $message = $unsubscribe_self ? 'Are you sure you want to unsubscribe from %group?' : 'Are you sure you want to unsubscribe %user from %group?';
  $confirm = $unsubscribe_self ? 'Yes, cancel my membership' : 'Yes, cancel the membership';
  $replace = array(
    '%user' => format_username($account),
    '%group' => $group
      ->label(),
  );
  $redirect = $unsubscribe_self ? "group/{$group->gid}" : "group/{$group->gid}/member";
  return confirm_form($form, t($message, $replace), $redirect, NULL, t($confirm), t('No, take me back!'));
}