Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.364 diff -u -r1.364 comment.module --- modules/comment.module 1 Aug 2005 05:14:05 -0000 1.364 +++ modules/comment.module 17 Aug 2005 12:47:37 -0000 @@ -434,7 +434,10 @@ function comment_validate($edit) { global $user; - + + // Invoke other validation handlers + module_invoke_all('comment', 'validate', $edit); + // only admins can change these fields if (!user_access('administer comments')) { $edit['uid'] = $user->uid; @@ -1414,6 +1417,9 @@ $form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 30, 255); } + // Prepend extra form additions + $form .= implode('', module_invoke_all('comment', 'form pre', $edit)); + if (variable_get('comment_subject_field', 1)) { $form .= form_textfield(t('Subject'), 'subject', $edit['subject'], 60, 64); } @@ -1421,6 +1427,10 @@ $form .= form_textarea(t('Comment'), 'comment', $edit['comment'] ? $edit['comment'] : $user->signature, 60, 15, '', NULL, TRUE); $form .= filter_form('format', $edit['format']); + + // Append extra form additions + $form .= implode('', module_invoke_all('comment', 'form post', $edit)); + $form .= form_hidden('cid', $edit['cid']); $form .= form_hidden('pid', $edit['pid']); $form .= form_hidden('nid', $edit['nid']); @@ -1435,8 +1445,15 @@ $form .= form_submit(t('Post comment')); } - $destination = $_REQUEST['destination'] ? 'destination='. $_REQUEST['destination'] : ''; - return theme('box', $title, form($form, 'post', url('comment/reply/'. $edit['nid'], $destination))); + $attributes = $_REQUEST['destination'] ? array('destination' => $_REQUEST['destination']) : array(); + $attributes = array('id' => 'comment-form'); + + $extra = module_invoke_all('comment', 'form param', $edit); + if (is_array($extra)) { + $attributes = array_merge($extra, $attributes); + } + + return theme('box', $title, form($form, 'post', url('comment/reply/'. $edit['nid'], $attributes))); } function theme_comment_preview($comment, $links = '', $visible = 1) { @@ -1459,6 +1476,10 @@ // Switch to folded/unfolded view of the comment if ($visible) { $comment->comment = check_markup($comment->comment, $comment->format, FALSE); + + // Comment API hook + $comment->comment .= implode('', module_invoke_all('comment', 'view', $comment)); + $output .= theme('comment', $comment, $links); } else { @@ -1685,4 +1706,4 @@ db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", 0, NULL, 0, 0, $nid); } } -?> +?> \ No newline at end of file