Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.349 diff -u -F^f -r1.349 comment.module --- modules/comment.module 8 Apr 2005 13:34:10 -0000 1.349 +++ modules/comment.module 14 Apr 2005 01:08:29 -0000 @@ -429,16 +429,6 @@ function comment_reply($nid, $pid = NULL function comment_validate_form($edit) { global $user; - // Validate the comment's subject. If not specified, extract - // one from the comment's body. - if (trim($edit['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. - $edit['subject'] = truncate_utf8(decode_entities(strip_tags(check_output($edit['comment'], $edit['format']))), 29, TRUE); - } - // Validate the comment's body. if ($edit['comment'] == '') { form_set_error('comment', t('The body of your comment is empty.')); @@ -1382,27 +1372,37 @@ function comment_already_moderated($uid, function theme_comment_form($edit, $title) { global $user; - $form .= "\n"; - // contact information: if ($user->uid) { $form .= form_item(t('Your name'), format_name($user)); } - else if (variable_get('comment_anonymous', 0) == 1) { - $form .= form_textfield(t('Your name'), 'name', $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous') , 20, 60); - $form .= form_textfield(t('E-mail'), 'mail', $edit['mail'], 20, 64, t('The content of this field is kept private and will not be shown publicly.')); - $form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 20, 255); - } - else if (variable_get('comment_anonymous', 0) == 2) { - $form .= form_textfield(t('Your name'), 'name', $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous') , 20, 60, NULL, NULL, TRUE); - $form .= form_textfield(t('E-mail'), 'mail', $edit['mail'], 20, 64, t('The content of this field is kept private and will not be shown publicly.'), NULL, TRUE); + else { + $form .= form_textfield(t('Your name'), 'name', $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous') , 20, 60, NULL, NULL, variable_get('comment_anonymous', 0) == 2); + $form .= form_textfield(t('E-mail'), 'mail', $edit['mail'], 20, 64, t('The content of this field is kept private and will not be shown publicly.'), NULL, variable_get('comment_anonymous', 0) == 2); $form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 20, 255); } // subject field: + if (!$edit['subject']) { + // Set the subject to 'Re: parent's subject' + // no 'Re:' will be added in front of an existing 'Re:' + if ($edit['pid']) { + $parent = db_fetch_object(db_query('SELECT subject FROM {comments} WHERE cid = %d', $edit['pid'])); + } + else { + $parent = db_fetch_object(db_query('SELECT title AS subject FROM {node} WHERE nid = %d', $edit['nid'])); + } + $edit['subject'] = $parent->subject; + if (strpos($edit['subject'], 'Re:') !== 0) { + $edit['subject'] = t('Re: %subject', array('%subject' => $edit['subject'])); + } + } if (variable_get('comment_subject_field', 1)) { $form .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 64); } + else { + form_hidden('subject', $edit['subject']); + } // comment field: $form .= form_textarea(t('Comment'), 'comment', $edit['comment'] ? $edit['comment'] : $user->signature, 70, 10, '', NULL, TRUE); @@ -1424,7 +1424,7 @@ function theme_comment_form($edit, $titl $form .= form_submit(t('Post comment')); } - return theme('box', $title, form($form, 'post', url('comment/reply/'. $edit['nid']))); + return theme('box', $title, form($form, 'post', url('comment/reply/'. $edit['nid']), array('id' => 'comment-form'))); } function theme_comment_view($comment, $links = '', $visible = 1) {