You are here

function activity_comments_comment_insert in Activity 6.2

Insert comments menu callback.

1 string reference to 'activity_comments_comment_insert'
activity_comments_menu in activity_comments/activity_comments.module
Implementation of hook_menu().

File

activity_comments/activity_comments.module, line 79
Provides comment handling for activity messages

Code

function activity_comments_comment_insert() {

  // We're starting in step #3, preparing for #4.
  $form_state = array(
    'storage' => NULL,
    '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.
  // search for activity_comments_wrap and remove it from the pre render
  $key = array_search('activity_comments_wrap', $form['#pre_render']);
  if ($key !== FALSE) {
    unset($form['#pre_render'][$key]);
  }
  $output = theme('status_messages') . drupal_render($form);

  // Final rendering callback.
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}