You are here

function ajax_comments_dispatch in AJAX Comments 5

2 string references to 'ajax_comments_dispatch'
ajax_comments_form_alter in ./ajax_comments.module
ajax_comments_menu in ./ajax_comments.module

File

./ajax_comments.module, line 130

Code

function ajax_comments_dispatch($form_id = NULL, $form = NULL) {
  $js_enabled = $form['js_enabled']['#value'];
  if (module_exists('captcha')) {
    captcha_form_alter('comment_form', $form_c);
    captcha_pre_render('comment_form', $form_c);
    $form_c = array();
    $form_c['captcha']['captcha_token']['#id'] = 'edit-captcha-token';
    $form_c['captcha']['captcha_response']['#id'] = 'edit-captcha-response';
    $form_c['captcha']['captcha_token']['#name'] = 'captcha_token';
    $form_c['captcha']['captcha_response']['#name'] = 'captcha_response';
    $captcha = @drupal_render($form_c);
  }
  $result = array(
    'status' => TRUE,
    'data' => array(
      'errors' => form_get_errors(),
      'message' => theme('status_messages'),
      'preview' => isset($form[arg(0) . '_preview']) && !empty($form[arg(0) . '_preview']['#value']) ? $form[arg(0) . '_preview']['#value'] : NULL,
      'destination' => '',
      'captcha' => $captcha,
    ),
  );
  if ($js_enabled != 1) {
    if ($form['form_id']['#post']['op'] != t('Preview comment')) {
      drupal_goto($js_enabled);
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#weight' => 19,
    );
    return $form;
  }
  print drupal_to_js($result);
  exit;
}