function og_approve in Organic groups 5
Same name and namespace in other branches
- 5.8 og.module \og_approve()
- 5.2 og.module \og_approve()
- 5.3 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 462
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),
);
$from = variable_get('site_mail', ini_get('sendmail_from'));
$account = user_load(array(
'uid' => $uid,
));
drupal_mail('og_approve', $account->mail, _og_user_mail_text('og_approve_user_subject', $variables), _og_user_mail_text('og_approve_user_body', $variables), $from);
drupal_goto("node/{$gid}");
}
}
else {
drupal_access_denied();
}
}