_comment_form_submit

Definition

_comment_form_submit(&$comment_values)
modules/comment/comment.module, line 1504

Description

Prepare a comment for submission.

Parameters

$comment_values An associative array containing the comment data.

Code

<?php
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'] = trim(truncate_utf8(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)');
    }
  }
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.