You are here

function heartbeat_activity_rules_action_message_id_js in Heartbeat 6.3

Same name and namespace in other branches
  1. 6.4 modules/heartbeat_rules/hrules.module \heartbeat_activity_rules_action_message_id_js()

Callback function to add variables to the user activity actions forms

1 string reference to 'heartbeat_activity_rules_action_message_id_js'
heartbeat_menu in ./heartbeat.module
Implementation of hook_menu().

File

./heartbeat.admin.inc, line 416

Code

function heartbeat_activity_rules_action_message_id_js() {

  // The form is generated in an include file which we need to include manually.
  module_load_include('inc', 'rules', 'rules.input_evaluators');
  module_load_include('inc', 'rules_admin', 'rules_admin');

  // We're starting in step #3, preparing for #4.
  $form_state = array(
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Step #4.
  $form = form_get_cache($form_build_id, $form_state);

  // Preparing for #5.
  $args = $form['#parameters'];
  $form_id = array_shift($args);
  $form_state['post'] = $form['#post'] = $_POST;
  $form['#programmed'] = $form['#redirect'] = FALSE;

  // Step #5.
  drupal_process_form($form_id, $form, $form_state);

  // Step #6 and #7 and #8.
  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

  // Step #9.
  $hm_form = $form['settings']['variables_param'];
  unset($hm_form['#prefix'], $hm_form['#suffix']);
  $output = drupal_render($hm_form);

  // Updating the drupal settings to be able to do one ahah request after another
  $javascript = drupal_add_js(NULL, NULL, 'header');

  // Final rendering callback.
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
    'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
  ));
}