Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.533 diff -u -p -r1.533 comment.module --- modules/comment/comment.module 30 Mar 2007 07:45:19 -0000 1.533 +++ modules/comment/comment.module 30 Mar 2007 15:32:05 -0000 @@ -641,7 +641,7 @@ function comment_reply($node, $pid = NUL // Display the parent comment $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - $comment->signature = check_markup($comment->signature, $comment->format); + $comment->type = $node->type; $output .= theme('comment_view', $comment); } else { @@ -946,7 +946,7 @@ function comment_render($node, $cid = 0) if ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - $comment->signature = check_markup($comment->signature, $comment->format); + $comment->type = $node->type; $links = module_invoke_all('link', 'comment', $comment, 1); drupal_alter('link', $links, $node); @@ -1001,7 +1001,7 @@ function comment_render($node, $cid = 0) while ($comment = db_fetch_object($result)) { $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - $comment->signature = check_markup($comment->signature, $comment->format); + $comment->type = $node->type; $comment->depth = count(explode('.', $comment->thread)) - 1; if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) { @@ -1600,12 +1600,14 @@ function comment_form_add_preview($form, if ($account) { $comment->uid = $account->uid; $comment->name = check_plain($account->name); - $comment->signature = check_markup($account->signature, $comment->format); + $comment->signature = $account->signature; } else { $comment->name = variable_get('anonymous', t('Anonymous')); $comment->signature = ''; } + $node = node_load($comment->nid); + $comment->type = $node->type; $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time(); $output .= theme('comment_view', $comment); } @@ -1622,7 +1624,7 @@ function comment_form_add_preview($form, $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - $comment->signature = check_markup($comment->signature, $comment->format); + $comment->type = $node->type; $output .= theme('comment_view', $comment); } else { @@ -1776,7 +1778,6 @@ function theme_comment($comment, $links $output .= '
'. l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) . ' ' . theme('mark', $comment->new) ."
\n"; $output .= '
'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."
\n"; $output .= '
'. $comment->comment .'
'; - $output .= '
'. $comment->signature .'
'; $output .= ''; $output .= ''; return $output; Index: modules/forum/forum.install =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v retrieving revision 1.6 diff -u -p -r1.6 forum.install --- modules/forum/forum.install 1 Sep 2006 07:40:08 -0000 1.6 +++ modules/forum/forum.install 30 Mar 2007 15:32:05 -0000 @@ -28,6 +28,9 @@ function forum_install() { db_query("CREATE INDEX {forum}_tid_idx ON {forum} (tid)"); break; } + + // Turn on signatures. + variable_set('user_signature_forum', 1); } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.794 diff -u -p -r1.794 node.module --- modules/node/node.module 27 Mar 2007 05:13:54 -0000 1.794 +++ modules/node/node.module 30 Mar 2007 15:32:06 -0000 @@ -521,10 +521,10 @@ function node_load($param = array(), $re // No db_rewrite_sql is applied so as to get complete indexing for search. if ($revision) { array_unshift($arguments, $revision); - $node = db_fetch_object(db_query('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.signature, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments)); } else { - $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.signature, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments)); } if ($node->nid) { Index: modules/user/user.css =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.css,v retrieving revision 1.4 diff -u -p -r1.4 user.css --- modules/user/user.css 30 Dec 2006 07:45:31 -0000 1.4 +++ modules/user/user.css 30 Mar 2007 15:32:07 -0000 @@ -47,3 +47,7 @@ .profile dd { margin:0; } + +.user-signature { + border-top: 1px solid #ccc; +} Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.763 diff -u -p -r1.763 user.module --- modules/user/user.module 30 Mar 2007 07:45:19 -0000 1.763 +++ modules/user/user.module 30 Mar 2007 15:32:09 -0000 @@ -1437,17 +1437,20 @@ function user_edit_form($uid, $edit, $re // Signature: if (module_exists('comment') && !$register) { - $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 comments.'), - ); + $types = user_get_signature_enabled_types(); + if (!empty($types)) { + $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 comments.'), + ); + } } // Picture/avatar: @@ -2773,3 +2776,83 @@ function user_forms() { return $forms; } +/** + * Implementation of hook_form_alter(). + */ +function user_form_alter(&$form, $form_id) { + // Add checkbox for settings to the node type form. + if ($form_id == 'node_type_form') { + $form['workflow']['user_signature'] = array( + '#type' => 'checkbox', + '#title' => t('Show user signatures for content type.'), + '#default_value' => variable_get('user_signature_'. $form['#node_type']->type, 0), + '#description' => t("If enabled, users' signatures will be appended to the end of all posts of this type."), + ); + } +} + +/** + * Retrieves list of signature-enabled node types. + * + * @return array + * An array of node type names, e.g. array('forum', 'story') + */ +function user_get_signature_enabled_types() { + $enabled = array(); + $types = node_get_types(); + foreach ($types as $type) { + if (variable_get('user_signature_'. $type->orig_type, 0)) { + $enabled[] = $type; + } + } + return $enabled; +} + +/** + * Implementation of hook_nodeapi(). + */ +function user_nodeapi(&$node, $op, $teaser, $page) { + if ($op == 'view' && $page) { + if (variable_get('user_signature_'. $node->type, 0)) { + $signature = check_markup($node->signature, $node->format); + $node->content['user_signature'] = array( + '#value' => theme('user_signature', $signature), + '#weight' => 10, + ); + } + } +} + +/** + * Implementation of hook_comment(). + * + * Adds a signature property to comments if signatures are enabled for + * a given node type. + */ +function user_comment($comment, $op) { + if ($op == 'view') { + if (variable_get('user_signature_'. $comment->type, 0)) { + $comment->signature = check_markup($comment->signature, $comment->format);; + } + else { + $comment->signature = ''; + } + } +} + +/** + * Theme output of signature. + * + * @ingroup themeable + */ +function theme_user_signature($signature) { + $output = ''; + if ($signature) { + $output .= '
'; + $output .= $signature; + $output .= '
'; + } + + return $output; +} +