You are here

function oa_core_add_member in Open Atrium Core 7.2

Menu callback to add user to group Mostly taken from og_ui_subscribe in og_ui_pages.inc

Parameters

$group_type:

$gid:

$uid:

3 string references to 'oa_core_add_member'
oa_core_default_page_manager_pages in ./oa_core.pages_default.inc
Implements hook_default_page_manager_pages().
oa_core_menu in ./oa_core.module
Implements hook_menu().
oa_layouts_panelizer_defaults in modules/oa_layouts/oa_layouts.panelizer.inc
Implements hook_panelizer_defaults().

File

./oa_core.module, line 941

Code

function oa_core_add_member($group_type, $gid, $uid, $field_name = NULL, $type = 'nojs') {
  global $user;
  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $group_type . '_' . $gid . '_' . $uid)) {
    return MENU_ACCESS_DENIED;
  }
  $account = user_load($uid);
  $is_user = $user->uid == $account->uid && $user->uid != 1;
  if (module_exists('og_ui') && $type != 'ajax' && $is_user) {
    module_load_include('inc', 'og_ui', 'og_ui.pages');

    // user is requesting their own membership, so show the confirmation form
    if (og_user_access('node', $gid, 'subscribe', $account) || og_user_access('node', $gid, 'subscribe without approval', $account)) {

      // Show the user a subscription confirmation.
      return drupal_get_form('og_ui_confirm_subscribe', 'node', $gid, $account, $field_name);
    }
    drupal_access_denied();
  }
  oa_core_add_member_api($group_type, $gid, $uid, !$is_user);
  if ($type != 'ajax') {
    drupal_goto();
  }
  else {
    $commands = array();
    $commands[] = ajax_command_append('#oa-core-messages', theme('status_messages'));
    $page = array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
    ajax_deliver($page);
  }
  return NULL;
}