You are here

function og_approve in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.module \og_approve()
  2. 5 og.module \og_approve()
  3. 5.2 og.module \og_approve()
  4. 5.3 og.module \og_approve()
  5. 5.7 og.module \og_approve()
  6. 6.2 og.module \og_approve()
1 string reference to 'og_approve'
og_menu in ./og.module

File

./og.module, line 730

Code

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}");
  }
}