function og_menu_access_unsubscribe in Organic groups 6
Same name and namespace in other branches
- 6.2 og.module \og_menu_access_unsubscribe()
Check if current user may unsubscribe the specified user from the specified group.
Parameters
$group_node :
$account :
Return value
boolean
File
- ./
og.module, line 202
Code
function og_menu_access_unsubscribe($group_node, $account = NULL) {
global $user;
if (empty($account)) {
$account = $user;
}
// Unsubscribee must already be a member or pending member.
if (!og_is_group_member($group_node, FALSE, $account->uid)) {
// Check pending as well.
$subs = og_get_subscriptions($account->uid, 0);
foreach ($subs as $key => $sub) {
if ($group_node->nid == $key) {
$is_member = TRUE;
break;
}
}
if (empty($is_member)) {
return FALSE;
}
}
// Only admins can remove another member
if ($account->uid != $user->uid && !og_is_group_admin($group_node)) {
return FALSE;
}
// Regular users may not unsubscribe from CLOSED groups.
if ($group_node->og_selective == OG_CLOSED && !og_is_group_admin($group_node)) {
return FALSE;
}
// Group manager may not unsubscribe
if ($group_node->uid == $account->uid) {
return FALSE;
}
// Protect private groups.
if (!node_access('view', $group_node)) {
return FALSE;
}
return TRUE;
}