You are here

function pm_block_user_js in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 pm_block_user/pm_block_user.admin.inc \pm_block_user_js()
  2. 7.2 pm_block_user/pm_block_user.admin.inc \pm_block_user_js()
  3. 7 pm_block_user/pm_block_user.admin.inc \pm_block_user_js()

Menu callback for AHAH handling.

1 string reference to 'pm_block_user_js'
pm_block_user_menu in pm_block_user/pm_block_user.module
Implements hook_menu().

File

pm_block_user/pm_block_user.module, line 284
Allows users to block other users from sending them any messages

Code

function pm_block_user_js() {

  // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
  $form_state = array(
    'storage' => NULL,
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];
  $form = form_get_cache($form_build_id, $form_state);
  $args = $form['#parameters'];
  $form_id = array_shift($args);
  $form['#post'] = $_POST;
  $form['#redirect'] = FALSE;
  $form['#programmed'] = FALSE;
  $form_state['post'] = $_POST;
  drupal_process_form($form_id, $form, $form_state);
  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
  $output_form = $form['block_actions'];
  unset($output_form['#prefix'], $output_form['#suffix']);

  // Prevent duplicate wrappers.
  $output = theme('status_messages') . drupal_render($output_form);

  // Hack to make behaviours attach to new HTML controls (delete buttons in
  // this case).
  $javascript = drupal_add_js(NULL, NULL, 'header');
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}