You are here

function og_unsubscribe in Organic groups 5.2

Same name and namespace in other branches
  1. 5.8 og.module \og_unsubscribe()
  2. 5 og.module \og_unsubscribe()
  3. 5.3 og.module \og_unsubscribe()
  4. 5.7 og.module \og_unsubscribe()
1 string reference to 'og_unsubscribe'
og_menu in ./og.module

File

./og.module, line 785

Code

function og_unsubscribe($gid, $uid = NULL) {
  global $user;
  if (is_null($uid)) {
    $uid = $user->uid;
  }
  $node = node_load($gid);
  if ($uid != $user->uid && !node_access('update', $node)) {

    // only admins can unsubscribe another person
    drupal_access_denied();
  }
  if ($node->og_selective == OG_CLOSED && !node_access('update', $node) || $node->uid == $uid) {

    // Regular users may not unsubscribe from a closed group
    // Group manager may never unsubscribe (TODO: fix), such a link should never be generated
    drupal_access_denied();
  }
  else {
    return drupal_get_form('og_confirm_unsubscribe', $gid, $node, $uid);
  }
}