function og_approve in Organic groups 5.3
Same name and namespace in other branches
- 5.8 og.module \og_approve()
- 5 og.module \og_approve()
- 5.2 og.module \og_approve()
- 5.7 og.module \og_approve()
- 6.2 og.module \og_approve()
- 6 og.module \og_approve()
File
- ./
og.module, line 453
Code
function og_approve($gid, $uid) {
$node = node_load($gid);
if (og_is_node_admin($node)) {
$account = user_load(array(
'uid' => (int) $uid,
));
if ($account === FALSE) {
drupal_set_message(t("User approval failed, user no longer available on website."), 'error');
return '';
}
if (in_array($gid, array_keys($account->og_groups))) {
drupal_set_message(t("!name already approved to group %group.", array(
'!name' => theme('username', $account),
'%group' => $node->title,
)), 'error');
return '';
}
else {
og_save_subscription($gid, $uid, array(
'is_active' => 1,
));
drupal_set_message(t('Membership request approved.'));
$variables = array(
'@title' => $node->title,
'!group_url' => url("node/{$node->nid}", NULL, NULL, TRUE),
);
$message = array(
'subject' => _og_user_mail_text('og_approve_user_subject', $variables),
'body' => _og_user_mail_text('og_approve_user_body', $variables),
);
module_invoke_all('og', 'user approve', $gid, $uid, $message);
drupal_goto("node/{$gid}");
}
}
else {
drupal_access_denied();
}
}