Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.478
diff -u -F^f -r1.478 comment.module
--- modules/comment/comment.module	22 Aug 2006 11:13:03 -0000	1.478
+++ modules/comment/comment.module	22 Aug 2006 20:28:07 -0000
@@ -352,22 +352,7 @@ function comment_nodeapi(&$node, $op, $a
  * Provides signature customization for the user's comments.
  */
 function comment_user($type, $edit, &$user, $category = NULL) {
-  if ($type == 'form' && $category == 'account') {
-    // when user tries to edit his own data
-    $form['comment_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Comment settings'),
-      '#collapsible' => TRUE,
-      '#weight' => 4);
-    $form['comment_settings']['signature'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Signature'),
-      '#default_value' => $edit['signature'],
-      '#description' => t('Your signature will be publicly displayed at the end of your comments.'));
-
-    return $form;
-  }
-  elseif ($type == 'delete') {
+  if ($type == 'delete') {
     db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid);
     db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid);
   }
@@ -1390,7 +1375,7 @@ function comment_form($edit, $title = NU
     $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $edit['subject']);
   }
 
-  $form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE);
+  $form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'], '#required' => TRUE);
   $form['comment_filter']['format'] = filter_form($edit['format']);
 
   $form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.659
diff -u -F^f -r1.659 user.module
--- modules/user/user.module	20 Aug 2006 13:16:34 -0000	1.659
+++ modules/user/user.module	22 Aug 2006 20:28:11 -0000
@@ -1314,6 +1314,22 @@ function user_edit_form($uid, $edit, $re
     }
   }
 
+  // Signature:
+  foreach (node_get_types() as $type => $details) {
+    $form['signature_settings'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Signature settings'),
+      '#weight' => 1,
+    );
+    $form['signature_settings']['signature'] = array(
+      '#type' => 'textarea',
+      '#title' => t('Signature'),
+      '#default_value' => $edit['signature'],
+      '#description' => t('Your signature will be publicly displayed at the end of your posts and comments.'),
+    );
+    break;
+  }
+
   // Picture/avatar:
   if (variable_get('user_pictures', 0)) {
     $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
@@ -2212,6 +2228,17 @@ function user_admin_settings() {
   $form['email']['user_mail_pass_subject'] = array('#type' => 'textfield', '#title' => t('Subject of password recovery e-mail'), '#default_value' => _user_mail_text('pass_subject'), '#maxlength' => 180, '#description' => t('Customize the Subject of your forgotten password e-mail.') .' '. t('Available variables are:') .' !username, !site, !login_url, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri.');
   $form['email']['user_mail_pass_body'] = array('#type' => 'textarea', '#title' => t('Body of password recovery e-mail'), '#default_value' => _user_mail_text('pass_body'), '#rows' => 15, '#description' => t('Customize the body of the forgotten password e-mail.') .' '. t('Available variables are:') .' !username, !site, !login_url, !uri, !uri_brief, !mailto, !login_uri, !edit_uri.');
 
+  $form['signatures'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Signatures'),
+  );
+  $form['signatures']['user_signatures_separator'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Signature separator'),
+    '#default_value' => variable_get('user_signatures_separator', "\n\n-- \n%signature"),
+    '#description' => t('Customize the separator between user cotent and their signature.'),
+  );
+
   // If picture support is enabled, check whether the picture directory exists:
   if (variable_get('user_pictures', 0)) {
     $picture_path = file_create_path(variable_get('user_picture_path', 'pictures'));
@@ -2563,9 +2590,43 @@ function user_filter_form_submit($form_i
 
 
 function user_forms() {
-  $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';+
+  $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';
   $forms['user_admin_access_edit_form']['callback'] = 'user_admin_access_form';
   $forms['user_admin_new_role']['callback'] = 'user_admin_role';
   return $forms;
 }
 
+/**
+ * Implementation of hook_form_alter().
+ */
+function user_form_alter($form_id, &$form) {
+  // Append signatures to new comments, and to new nodes that have comments enabled.
+  if ($form_id == 'comment_form' && !$form['cid']['#value']) {
+    $form['#submit'] = array_merge(array('user_signature_append' => array('comment')), $form['#submit']);
+  }
+  elseif (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && !$form['nid']['#value'] && variable_get("comment_$node->type", 2)) {
+    $form['#submit'] = array_merge(array('user_signature_append' => array('post')), $form['#submit']);
+  }
+}
+
+/**
+ * Form submit callback; append user signature to new post or comment.
+ *
+ * @param $type
+ *   Which type of signature is being appended; 'post' or 'comment'.
+ */
+function user_signature_append($form_id, &$form_values, $type) {
+  $separator = variable_get('user_signatures_separator', "\n\n-- \n%signature");
+
+  if ($type == 'comment') {
+    $author = user_load(array('name' => $form_values['author']));
+    $signature = str_replace('%signature', $author->signature, $separator);
+    $form_values['comment'] .= $signature;
+  }
+  elseif ($type == 'post') {
+    $author = user_load(array('uid' => $form_values['uid']));
+    $signature = str_replace('%signature', $author->signature, $separator);
+    $form_values['body'] .= $signature;
+  }
+}
+
