? files
? sites/localhost.user_signatures
Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.390
diff -u -r1.390 comment.module
--- modules/comment.module 15 Nov 2005 07:29:47 -0000 1.390
+++ modules/comment.module 20 Nov 2005 08:19:11 -0000
@@ -290,21 +290,6 @@
}
/**
- * 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['comment_settings']['signature'], '#description' => ('Your signature will be publicly displayed at the end of your comments.'));
-
- return $form;
- }
-}
-
-/**
* Menu callback; presents the comment settings page.
*/
function comment_configure() {
@@ -1195,7 +1180,7 @@
$form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $edit['subject']);
}
- $form['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE
+ $form['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'], '#required' => TRUE
);
$form = array_merge($form, filter_form($node->format));
Index: modules/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user.module,v
retrieving revision 1.531
diff -u -r1.531 user.module
--- modules/user.module 15 Nov 2005 20:47:06 -0000 1.531
+++ modules/user.module 21 Nov 2005 04:07:55 -0000
@@ -1152,25 +1152,90 @@
function user_edit_form($uid, $edit) {
// Account information:
- $form['account'] = array('#type' => 'fieldset', '#title' => t('Account information'), '#weight' => 0);
- $form['account']['name'] = array('#type' => 'textfield', '#title' => t('Username'), '#default_value' => $edit['name'], '#maxlength' => 55, '#description' => t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'), '#required' => TRUE);
- $form['account']['mail'] = array('#type' => 'textfield', '#title' => t('E-mail address'), '#default_value' => $edit['mail'], '#maxlength' => 55, '#description' => t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), '#required' => TRUE);
- $form['account']['pass'] = array('#type' => 'item', '#title' => t('Password'), '#value' => ' ', '#required' => true);
+ $form['account'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Account information'),
+ '#weight' => 0,
+ );
+ $form['account']['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Username'),
+ '#default_value' => $edit['name'],
+ '#maxlength' => 55,
+ '#description' => t('Your full name or your preferred username: only letters, numbers and spaces are allowed.'),
+ '#required' => TRUE,
+ );
+ $form['account']['mail'] = array(
+ '#type' => 'textfield',
+ '#title' => t('E-mail address'),
+ '#default_value' => $edit['mail'],
+ '#maxlength' => 55,
+ '#description' => t('Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
+ '#required' => TRUE,
+ );
+ $form['account']['pass'] = array(
+ '#type' => 'item',
+ '#title' => t('Password'),
+ '#value' => ' ',
+ '#required' => true,
+ );
if (user_access('administer users')) {
- $form['account']['status'] = array('#type' => 'radios', '#title' => t('Status'), '#default_value' => $edit['status'], '#options' => array(t('Blocked'), t('Active')));
+ $form['account']['status'] = array(
+ '#type' => 'radios',
+ '#title' => t('Status'),
+ '#default_value' => $edit['status'],
+ '#options' => array(t('Blocked'), t('Active')),
+ );
}
if (user_access('administer access control')) {
- $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => array_keys($edit['roles']), '#options' => user_roles(1), '#description' => t('Select at least one role. The user receives the combined permissions of all of the selected roles.'), '#required' => TRUE);
- }
+ $form['account']['roles'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Roles'),
+ '#default_value' => array_keys($edit['roles']),
+ '#options' => user_roles(1),
+ '#description' => t('Select at least one role. The user receives the combined permissions of all of the selected roles.'),
+ '#required' => TRUE,
+ );
+ }
+
+ // Signature:
+ $form['signature'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Signature settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $form['signature']['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 where the administrator has enabled them.'),
+ );
// Picture/avatar:
if (variable_get('user_pictures', 0)) {
- $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
+ $form['picture'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Picture'),
+ '#weight' => 1,
+ );
if ($edit['picture'] && ($picture = theme('user_picture', array2object($edit)))) {
- $form['picture']['current_picture'] = array('#type' => 'markup', '#value' => $picture);
- $form['picture']['picture_delete'] = array('#type' => 'checkbox', '#title' => t('Delete picture'), '#description' => t('Check this box to delete your current picture.'));
- }
- $form['picture']['picture'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));
+ $form['picture']['current_picture'] = array(
+ '#type' => 'markup',
+ '#value' => $picture,
+ );
+ $form['picture']['picture_delete'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete picture'),
+ '#description' => t('Check this box to delete your current picture.'),
+ );
+ }
+ $form['picture']['picture'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload picture'),
+ '#size' => 48,
+ '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''),
+ );
}
return $form;
@@ -1761,18 +1826,92 @@
function user_configure() {
// User registration settings.
- $form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration 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.'));
+ $form['registration'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User registration 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.'),
+ );
+
+ // User signature settings.
+ $form['signature'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User signature settings'),
+ );
+ $defaults = array_keys(variable_get('signature_node_types', array()), '1');
+ $form['signature']['signature_node_types'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Types'),
+ '#options' => node_get_types(),
+ '#default_value' => $defaults,
+ '#description' => t('Selected content types will display signatures at the bottom of all posts and comments'),
+ );
+ $form['signature']['signature_template'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Signature template'),
+ '#default_value' => variable_get('signature_template', '--
%s
'),
+ '#description' => t('Use HTML to establish a template for signatures. %s represents the signature text.'),
+ );
// User e-mail settings.
- $form['email'] = array('#type' => 'fieldset', '#title' => t('User email 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.');
- $form['email']['user_mail_welcome_body'] = array('#type' => 'textarea', '#title' => t('Body of welcome e-mail'), '#default_value' => _user_mail_text('welcome_body'), '#rows' => 15, '#description' => t('Customize the body of the welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' %username, %site, %password, %uri, %uri_brief, %mailto, %login_uri, %edit_uri, %login_url.');
- $form['email']['user_mail_approval_subject'] = array('#type' => 'textfield', '#title' => t('Subject of welcome e-mail (awaiting admin approval)'), '#default_value' => _user_mail_text('approval_subject'), '#maxlength' => 180, '#description' => t('Customize the subject of your awaiting approval 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.');
- $form['email']['user_mail_approval_body'] = array('#type' => 'textarea', '#title' => t('Body of welcome e-mail (awaiting admin approval)'), '#default_value' => _user_mail_text('approval_body'), '#rows' => 15, '#description' => t('Customize the body of the awaiting approval welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' %username, %site, %password, %uri, %uri_brief, %mailto, %login_uri, %edit_uri, %login_url.');
- $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['email'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User email 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.',
+ );
+ $form['email']['user_mail_welcome_body'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Body of welcome e-mail'),
+ '#default_value' => _user_mail_text('welcome_body'),
+ '#rows' => 15,
+ '#description' => t('Customize the body of the welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' %username, %site, %password, %uri, %uri_brief, %mailto, %login_uri, %edit_uri, %login_url.',
+ );
+ $form['email']['user_mail_approval_subject'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Subject of welcome e-mail (awaiting admin approval)'),
+ '#default_value' => _user_mail_text('approval_subject'),
+ '#maxlength' => 180,
+ '#description' => t('Customize the subject of your awaiting approval 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.',
+ );
+ $form['email']['user_mail_approval_body'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Body of welcome e-mail (awaiting admin approval)'),
+ '#default_value' => _user_mail_text('approval_body'),
+ '#rows' => 15,
+ '#description' => t('Customize the body of the awaiting approval welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' %username, %site, %password, %uri, %uri_brief, %mailto, %login_uri, %edit_uri, %login_url.',
+ );
+ $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.',
+ );
// If picture support is enabled, check whether the picture directory exists:
if (variable_get('user_pictures', 0)) {
@@ -1780,13 +1919,54 @@
file_check_directory($picture_path, 1, 'user_picture_path');
}
- $form['pictures'] = array('#type' => 'fieldset', '#title' => t('Pictures'));
- $form['pictures']['user_pictures'] = array('#type' => 'radios', '#title' => t('Picture support'), '#default_value' => variable_get('user_pictures', 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable picture support.'));
- $form['pictures']['user_picture_path'] = array('#type' => 'textfield', '#title' => t('Picture image path'), '#default_value' => variable_get('user_picture_path', 'pictures'), '#size' => 30, '#maxlength' => 255, '#description' => t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => file_directory_path() .'/')));
- $form['pictures']['user_picture_default'] = array('#type' => 'textfield', '#title' => t('Default picture'), '#default_value' => variable_get('user_picture_default', ''), '#size' => 30, '#maxlength' => 255, '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'));
- $form['pictures']['user_picture_dimensions'] = array('#type' => 'textfield', '#title' => t('Picture maximum dimensions'), '#default_value' => variable_get('user_picture_dimensions', '85x85'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum dimensions for pictures.'));
- $form['pictures']['user_picture_file_size'] = array('#type' => 'textfield', '#title' => t('Picture maximum file size'), '#default_value' => variable_get('user_picture_file_size', '30'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum file size for pictures, in kB.'));
- $form['pictures']['user_picture_guidelines'] = array('#type' => 'textarea', '#title' => t('Picture guidelines'), '#default_value' => variable_get('user_picture_guidelines', ''), '#description' => t('This text is displayed at the picture upload form in addition to the default guidelines. It\'s useful for helping or instructing your users.'));
+ $form['pictures'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Pictures'),
+ );
+ $form['pictures']['user_pictures'] = array(
+ '#type' => 'radios',
+ '#title' => t('Picture support'),
+ '#default_value' => variable_get('user_pictures', 0),
+ '#options' => array(t('Disabled'), t('Enabled')),
+ '#description' => t('Enable picture support.'),
+ );
+ $form['pictures']['user_picture_path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Picture image path'),
+ '#default_value' => variable_get('user_picture_path', 'pictures'),
+ '#size' => 30,
+ '#maxlength' => 255,
+ '#description' => t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => file_directory_path() .'/')),
+ );
+ $form['pictures']['user_picture_default'] = array(
+ '#type' => 'textfield', '#title' => t('Default picture'),
+ '#default_value' => variable_get('user_picture_default', ''),
+ '#size' => 30,
+ '#maxlength' => 255,
+ '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
+ );
+ $form['pictures']['user_picture_dimensions'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Picture maximum dimensions'),
+ '#default_value' => variable_get('user_picture_dimensions', '85x85'),
+ '#size' => 15,
+ '#maxlength' => 10,
+ '#description' => t('Maximum dimensions for pictures.'),
+ );
+ $form['pictures']['user_picture_file_size'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Picture maximum file size'),
+ '#default_value' => variable_get('user_picture_file_size', '30'),
+ '#size' => 15,
+ '#maxlength' => 10,
+ '#description' => t('Maximum file size for pictures, in kB.'),
+ );
+ $form['pictures']['user_picture_guidelines'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Picture guidelines'),
+ '#default_value' => variable_get('user_picture_guidelines', ''),
+ '#description' => t('This text is displayed at the picture upload form in addition to the default guidelines. It\'s useful for helping or instructing your users.'),
+ );
return system_settings_form('user_configure_settings', $form);
}
@@ -1933,4 +2113,56 @@
exit();
}
+/**
+ * Implementation of hook_comment().
+ */
+function user_comment($comment, $op) {
+ if ($op == 'view') {
+ $node = node_load($comment->nid);
+ if (signature_is_allowed($node->type)) {
+ $comment->signature = db_result(db_query('SELECT signature FROM {users} WHERE uid = %d', $comment->uid));
+ $comment->comment .= theme('signature', $comment->signature);
+ }
+ }
+
+ return $comment;
+}
+/**
+ * Implementation of hook_nodeapi().
+ */
+function user_nodeapi(&$node, $op, $arg = 0) {
+ if (signature_is_allowed($node->type)) {
+ switch ($op) {
+ case 'load':
+ $node->signature = db_result(db_query('SELECT signature FROM {users} WHERE uid = %d', $node->uid));
+ break;
+ case 'view':
+ $node->body .= theme('signature', $node->signature);
+ break;
+ }
+ }
+}
+
+/**
+ * Determines if signature type is allowed or not.
+ *
+ * @param $type
+ * A node type
+ * @return boolean
+ * Returns true if node type is allowed, false if it is not.
+ */
+function signature_is_allowed($type) {
+ $allowed_types = variable_get('signature_node_types', array());
+ return ($allowed_types[$type] == 1);
+}
+
+/**
+ * Format a signature
+ *
+ * @return string
+ * HTML output of signature
+ */
+function theme_signature($signature) {
+ return sprintf(variable_get('signature_template', '-- %s
'), $signature);
+}
\ No newline at end of file