Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.470 diff -u -F^f -r1.470 comment.module --- modules/comment/comment.module 5 Aug 2006 00:26:35 -0000 1.470 +++ modules/comment/comment.module 5 Aug 2006 18:32:12 -0000 @@ -345,26 +345,9 @@ function comment_nodeapi(&$node, $op, $a /** * Implementation of hook_user(). - * - * 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); } @@ -1383,7 +1366,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.648 diff -u -F^f -r1.648 user.module --- modules/user/user.module 5 Aug 2006 00:26:36 -0000 1.648 +++ modules/user/user.module 5 Aug 2006 18:32:18 -0000 @@ -1304,6 +1304,20 @@ function user_edit_form($uid, $edit, $re } } + // Signature: + foreach (node_get_types() as $type => $name) { + // Only show signature textarea if at least one node type is signature-enabled. + if (variable_get('user_signatures_'. $type, 0)) { + $form['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.'), + ); + break; + } + } + // Picture/avatar: if (variable_get('user_pictures', 0)) { $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1); @@ -1930,6 +1944,16 @@ function user_admin_settings() { $form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into to the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.')); $form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t("This text is displayed at the top of the user registration form. It's useful for helping or instructing your users.")); + // Signature settings. + $form['signatures'] = array( + '#type' => 'fieldset', + '#title' => t('Signature settings'), + ); + $form['signatures']['user_signatures_format_description'] = array( + '#value' => '

'. t("Select which input format should be allowed on users' signatures:") .'

', + ); + $form['signatures']['user_signatures_format'] = filter_form(variable_get('user_signature_format', 1)); + // User e-mail settings. $form['email'] = array('#type' => 'fieldset', '#title' => t('User e-mail settings')); $form['email']['user_mail_welcome_subject'] = array('#type' => 'textfield', '#title' => t('Subject of welcome e-mail'), '#default_value' => _user_mail_text('welcome_subject'), '#maxlength' => 180, '#description' => t('Customize the subject of your welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' %username, %site, %password, %uri, %uri_brief, %mailto, %date, %login_uri, %edit_uri, %login_url.'); @@ -2092,3 +2116,65 @@ function user_autocomplete($string) { print drupal_to_js($matches); exit(); } + +/** + * Implementation of hook_form_alter(). + * + * Add user signature option to content type settings forms. + */ +function user_form_alter($form_id, &$form) { + if ($form['type']['#value'] .'_node_settings' == $form_id) { + $form['workflow']['user_signatures_'. $form['type']['#value']] = array( + '#type' => 'checkbox', + '#title' => t('Show user signatures on this node type.'), + '#default_value' => variable_get('user_signatures_'. $form['type']['#value'], 0), + '#description' => t("If enabled, users' signatures will be appended to the end of all posts and comments for this type."), + ); + } +} + +/** + * Implementation of hook_nodeapi(). + * + * Append signatures to signature-enabled node types. + */ +function user_nodeapi(&$node, $op, $arg = 0) { + if (variable_get('user_signatures_'. $node->type, 0)) { + if ($op == 'view') { + $author = user_load(array('uid' => $node->uid)); + $node->body .= theme('user_signature', $author->signature); + } + } +} + +/** + * Implementation of hook_comment(). + * + * Append signatures to comments, if the parent node type is signature-enabled. + */ +function user_comment($comment, $op) { + if ($op == 'view') { + $node = node_load($comment->nid); + if (variable_get('user_signatures_'. $node->type, 0)) { + $author = user_load(array('uid' => $comment->uid)); + $comment->comment .= theme('user_signature', $author->signature); + } + } +} + +/** + * Output a user's signature. + * + * @ingroup themeable + */ +function theme_user_signature($signature) { + $output = '
'; + // Note: check_markup is important, as without it people could enter potentially dangerous stuff like PHP. + $output .= check_markup(" +-- +$signature +", variable_get('user_signatures_format', 1)); + $output .= '
'; + + return $output; +}