function og_unsubscribe in Organic groups 5.7
Same name and namespace in other branches
- 5.8 og.module \og_unsubscribe()
- 5 og.module \og_unsubscribe()
- 5.2 og.module \og_unsubscribe()
- 5.3 og.module \og_unsubscribe()
File
- ./
og.module, line 803
Code
function og_unsubscribe($gid, $uid = NULL) {
global $user;
if (is_null($uid)) {
$uid = $user->uid;
}
$node = node_load($gid);
$account = user_load(array(
'uid' => $uid,
));
if (!in_array($gid, array_keys($account->og_groups)) || $uid != $user->uid && !og_is_node_admin($node)) {
// Ubsubscribee must be a member.
// Only admins can remove another member.
drupal_access_denied();
exit;
}
if (!og_is_group_type($node->type) || $node->og_selective == OG_CLOSED && !og_is_node_admin($node) || $node->uid == $uid) {
// Regular users may not leave from a closed group
// Group manager may never leave (TODO: fix), such a link should never be generated
drupal_access_denied();
exit;
}
else {
return drupal_get_form('og_confirm_unsubscribe', $gid, $node, $uid);
}
}