function _comment_form_submit

Prepare a comment for submission.

Parameters

$comment_values: An associative array containing the comment data.

2 calls to _comment_form_submit()
comment_form_add_preview in drupal-6.x/modules/comment/comment.module
Form builder; Generate and validate a comment preview form.
comment_form_submit in drupal-6.x/modules/comment/comment.module
Process comment form submissions; prepare the comment, store it, and set a redirection target.

Archivo

drupal-6.x/modules/comment/comment.module, line 1508
Enables users to comment on published content.

Código

function _comment_form_submit(&$comment_values) {
  $comment_values += array('subject' => '');
  if (!isset($comment_values['date'])) {
    $comment_values['date'] = 'now';
  }
  $comment_values['timestamp'] = strtotime($comment_values['date']);
  if (isset($comment_values['author'])) {
    $account = user_load(array('name' => $comment_values['author']));
    $comment_values['uid'] = $account->uid;
    $comment_values['name'] = $comment_values['author'];
  }
  // Validate the comment's subject. If not specified, extract
  // one from the comment's body.
  if (trim($comment_values['subject']) == '') {
    // The body may be in any format, so we:
    // 1) Filter it into HTML
    // 2) Strip out all HTML tags
    // 3) Convert entities back to plain-text.
    // Note: format is checked by check_markup().
    $comment_values['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['format'])))), 29, TRUE);
    // Edge cases where the comment body is populated only by HTML tags will
    // require a default subject.
    if ($comment_values['subject'] == '') {
      $comment_values['subject'] = t('(No subject)');
    }
  }
}