function og_subscribe in Organic groups 6
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.3 og.module \og_subscribe()
- 5.7 og.module \og_subscribe()
- 6.2 og.pages.inc \og_subscribe()
File
- ./
og.module, line 944
Code
function og_subscribe($node, $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,
));
}
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_group_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', $node->nid, $node, $account);
}
}
}