og_approve

Versions
5
og_approve($gid, $uid)
6
og_approve($node, $account, $token)

Code

contributions/og/og.module, line 651

<?php
function og_approve($node, $account, $token) {
  if (!og_check_token($token, $node->nid)) {
    drupal_set_message(t('Bad token. You seem to have followed an invalid link.'), 'error');
    drupal_access_denied();
    return;
  }
  
  if (og_is_group_member($node, FALSE, $account->uid)) {
    drupal_set_message(t('!name already approved to group %group.', array('!name' => theme('username', $account), '%group' => $node->title)), 'error');
    return '';
  }
  else {
    og_save_subscription($node->nid, $account->uid, array('is_active' => 1));
    drupal_set_message(t('Membership request approved.'));
         
    $variables = array(
      '@title' => $node->title,
      '!group_url'=> url("node/$node->nid", array('absolute' => TRUE))
    );
    $message = array(
      'subject' => _og_mail_text('og_approve_user_subject', $variables),
      'body' => _og_mail_text('og_approve_user_body', $variables)
    );

    module_invoke_all('og', 'user approve', $node->nid, $account->uid, $message);
    drupal_goto("node/$node->nid");
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.