function og_subscribe in Organic groups 5.3
Same name and namespace in other branches
- 5.8 og.module \og_subscribe()
- 5 og.module \og_subscribe()
- 5.2 og.module \og_subscribe()
- 5.7 og.module \og_subscribe()
- 6.2 og.pages.inc \og_subscribe()
- 6 og.module \og_subscribe()
File
- ./
og.module, line 682
Code
function og_subscribe($gid, $uid = NULL) {
global $user;
if (is_null($uid)) {
if ($user->uid) {
$account = $user;
}
else {
drupal_set_message(t('In order to join this group, you must login or register a new account. After you have successfully done so, you will need to request membership again.'));
drupal_goto('user');
}
}
else {
$account = user_load(array(
'uid' => $uid,
));
}
$node = node_load($gid);
if ($node->og_selective >= OG_INVITE_ONLY || $node->status == 0 || !og_is_group_type($node->type)) {
drupal_access_denied();
exit;
}
// only admins can add another member
if ($account->uid != $user->uid && !og_is_node_admin($node)) {
drupal_access_denied();
exit;
}
else {
if (isset($account->og_groups[$node->nid])) {
drupal_set_message(t('@user is already a member the group @group', array(
'@user' => $account->name,
'@group' => $node->title,
)));
drupal_goto('node/' . $node->nid);
}
else {
return drupal_get_form('og_confirm_subscribe', $gid, $node, $account);
}
}
}