You are here

function oa_core_block_member in Open Atrium Core 7.2

Menu callback to block a user from group

Parameters

$group_type:

$gid:

$uid:

1 string reference to 'oa_core_block_member'
oa_core_menu in ./oa_core.module
Implements hook_menu().

File

./oa_core.module, line 1023

Code

function oa_core_block_member($group_type, $gid, $uid, $type = 'nojs') {
  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $group_type . '_' . $gid . '_' . $uid)) {
    return MENU_ACCESS_DENIED;
  }
  $account = user_load($uid);
  $group = entity_load_single($group_type, $gid);
  $label = entity_label($group_type, $group);
  og_ungroup('node', $group->nid, 'user', $account);

  // add user to group
  og_group('node', $group->nid, array(
    'entity' => $account,
    'state' => OG_STATE_BLOCKED,
  ));
  drupal_set_message(t('%user has been blocked.', array(
    '%user' => format_username($account),
    '%title' => $label,
  )));
  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;
}