You are here

function heartbeat_activity_ahah in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 heartbeat.admin.inc \heartbeat_activity_ahah()
  2. 6.3 heartbeat.admin.inc \heartbeat_activity_ahah()

ahah callback

File

./heartbeat.pages.inc, line 329
Separate codefile for page displays

Code

function heartbeat_activity_ahah($element) {
  $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);
  $javascript = drupal_add_js(NULL, NULL, 'header');
  $_SESSION['messages'] = array();
  if (isset($form['hb_fields'][$element])) {
    $ahah_form = $form['hb_fields'][$element];
  }
  elseif (isset($form['fs_settings'][$element])) {
    $ahah_form = $form['fs_settings'][$element];
  }
  if ($ahah_form) {

    //drupal_set_message(_heartbeat_activity_get_time($form_state['values'][$element]));
    $ahah_form['#description'] = '<div class="status">' . t('Currently set ') . _heartbeat_activity_get_time($form_state['values'][$element]) . '</div>';
    unset($ahah_form['#prefix'], $ahah_form['#suffix']);

    // Prevent duplicate wrappers.
    drupal_json_output(array(
      'status' => TRUE,
      'data' => theme('status_messages') . drupal_render($ahah_form),
      'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
    ));
  }
  else {
    drupal_json_output(array(
      'status' => FALSE,
      'data' => t('Element not found: @element', array(
        '@element' => $element,
      )),
      'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
    ));
  }
  exit;
}