Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.468 diff -u -F^f -r1.468 comment.module --- modules/comment/comment.module 19 Jul 2006 07:15:34 -0000 1.468 +++ modules/comment/comment.module 29 Jul 2006 04:18:05 -0000 @@ -339,26 +339,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); } @@ -1377,7 +1360,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.641 diff -u -F^f -r1.641 user.module --- modules/user/user.module 27 Jul 2006 08:07:04 -0000 1.641 +++ modules/user/user.module 29 Jul 2006 04:18:06 -0000 @@ -1284,6 +1284,16 @@ function user_edit_form($uid, $edit, $re } } + // Signature: + if (variable_get('user_signatures', 1)) { + $form['signature'] = array( + '#type' => 'textarea', + '#title' => t('Signature'), + '#default_value' => $user->signature, + '#description' => t('Your signature will be publicly displayed at the end of your comments.') + ); + } + // Picture/avatar: if (variable_get('user_pictures', 0)) { $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1); @@ -1909,6 +1919,12 @@ function user_admin_settings() { $form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.'))); $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_enable'] = array('#type' => 'checkbox', '#title' => t('Enable signatures'), '#default_value' => variable_get('user_signature_enable', 1), '#description' => t('If enabled, users may append their own custom text to the bottom of their posts and comments.')); + $form['signatures']['user_signatures_separator'] = array('#type' => 'textarea', '#title' => t('Signature separator'), '#default_value' => variable_get('user_signature_separator', "\n---\n%signature"), '#description' => t('Separation between the body of the post and the signature. Use %signature to indicate where the signature should be displayed.')); + $form['signatures']['user_signatures_format'] = filter_form(variable_get('user_signatures_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.'); @@ -2075,3 +2091,54 @@ 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 (variable_get('user_signatures_enable', 1)) { + 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 of this type."), + ); + } + } +} + +/** + * Implementation of hook_nodeapi(). + * + * Append signatures to allowed node types on node view. + */ +function user_nodeapi(&$node, $op, $arg = 0) { + switch ($op) { + case 'view': + if (variable_get('user_signatures_enable', 1) && variable_get('user_signatures_'. $node->type, 0)) { + $author = user_load(array('uid' => $node->uid)); + $node->body .= check_markup(str_replace('%signature', $author->signature, variable_get('user_signatures_separator', "\n---\n%signature")), variable_get('user_signatures_format', 1)); + } + break; + } +} + +/** + * Implementation of hook_comment(). + * + * Append signatures to comments. + */ +function user_comment($comment, $op) { + switch ($op) { + case 'view': + if (variable_get('user_signatures_enable', 1)) { + $author = user_load(array('uid' => $comment->uid)); + $comment->comment .= check_markup(str_replace('%signature', $author->signature, variable_get('user_signatures_separator', "\n---\n%signature")), variable_get('user_signatures_format', 1)); + } + break; + } +} +