You are here

function comment_goodness_form_submit in Comment goodness 7

Form submit handler.

See also

comment_goodness_form_comment_form_alter().

1 string reference to 'comment_goodness_form_submit'
comment_goodness_form_comment_form_alter in ./comment_goodness.module
Implements hook_form_FORM_ID_alter().

File

./comment_goodness.module, line 447
Comment goodness provides newest to oldest comment sorting

Code

function comment_goodness_form_submit($form, &$form_state) {
  $node = $form['#node'];
  $comment = $form_state['comment'];
  if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) {

    // Find the current display page for this comment.
    $query = array();
    $page = comment_goodness_get_display_page($comment->cid, $node->type);
    if ($page > 0) {
      $query['page'] = $page;
    }

    // Redirect to the newly posted comment.
    $form_state['redirect'] = array(
      'node/' . $node->nid,
      array(
        'query' => $query,
        'fragment' => 'comment-' . $comment->cid,
      ),
    );
  }
}