You are here

function og_confirm_unsubscribe_submit in Organic groups 6.2

Same name and namespace in other branches
  1. 5.8 og.module \og_confirm_unsubscribe_submit()
  2. 5 og.module \og_confirm_unsubscribe_submit()
  3. 5.2 og.module \og_confirm_unsubscribe_submit()
  4. 5.3 og.module \og_confirm_unsubscribe_submit()
  5. 5.7 og.module \og_confirm_unsubscribe_submit()
  6. 6 og.module \og_confirm_unsubscribe_submit()

Confirm og unsubscription submit handler

File

./og.pages.inc, line 383
Page callbacks for Organic groups.

Code

function og_confirm_unsubscribe_submit($form, &$form_state) {
  global $user;
  $group_node = $form_state['values']['group_node'];
  $account = $form_state['values']['account'];
  og_delete_subscription($group_node->nid, $account->uid);

  // If needed, reload user object to reflect unsubscribed group.
  if ($user->uid == $account->uid) {
    og_get_subscriptions($account->uid, 1, TRUE);

    // Clear cache.
    $user = user_load(array(
      'uid' => $user->uid,
    ));
    $message = t('You left the group %group.', array(
      '%group' => $group_node->title,
    ));
  }
  else {
    $message = t('%user removed from %group.', array(
      '%user' => $account->name,
      '%group' => $group_node->title,
    ));
  }
  drupal_set_message($message);

  // Determine where to go next. GHP if accessible, or else site front page.
  $form_state['redirect'] = node_access('view', $group_node) ? "node/" . $group_node->nid : '';
}