Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.369
diff -u -r1.369 comment.module
--- modules/comment.module	7 Sep 2005 20:45:53 -0000	1.369
+++ modules/comment.module	8 Sep 2005 03:47:33 -0000
@@ -434,6 +434,9 @@
 
 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')) {
@@ -586,7 +589,7 @@
         _comment_update_node_statistics($edit['nid']);
 
         // Allow modules to respond to the updating of a comment.
-        module_invoke_all('comment', 'update', $edit);
+        module_invoke_all('comment', 'update', $edit);
 
         // Add an entry to the watchdog log.
         watchdog('content', t('Comment: updated %subject.', array('%subject' => theme('placeholder', $edit['subject']))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
@@ -689,7 +692,7 @@
         _comment_update_node_statistics($edit['nid']);
 
         // Tell the other modules a new comment has been submitted.
-        module_invoke_all('comment', 'insert', $edit);
+        module_invoke_all('comment', 'insert', $edit);
 
         // Add an entry to the watchdog log.
         watchdog('content', t('Comment: added %subject.', array('%subject' => theme('placeholder', $edit['subject']))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
@@ -1413,6 +1416,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);
   }
@@ -1420,6 +1426,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']);
@@ -1434,8 +1444,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) {
@@ -1458,6 +1475,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 {
