Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.112 diff -u -p -r1.112 contact.module --- modules/contact/contact.module 8 Mar 2009 05:08:22 -0000 1.112 +++ modules/contact/contact.module 20 Apr 2009 23:24:18 -0000 @@ -116,15 +116,11 @@ function contact_menu() { */ function _contact_user_tab_access($account) { global $user; - if (!isset($account->contact)) { - $account->contact = FALSE; - } - return - $account && $user->uid && - ( - ($user->uid != $account->uid && $account->contact) || - user_access('administer users') - ); + + // The user's contact form can be accessed if the current user is logged in, + // and the contacting user has enabled their contact form or the current user + // has the 'administer users' permission. + return $user->uid && (!empty($account->contact) || user_access('administer users')); } /** @@ -141,15 +137,17 @@ function contact_load($cid) { */ function contact_user_form(&$edit, &$user, $category = NULL) { if ($category == 'account') { - $form['contact'] = array('#type' => 'fieldset', + $form['contact'] = array( + '#type' => 'fieldset', '#title' => t('Contact settings'), '#weight' => 5, '#collapsible' => TRUE, ); - $form['contact']['contact'] = array('#type' => 'checkbox', + $form['contact']['contact'] = array( + '#type' => 'checkbox', '#title' => t('Personal contact form'), - '#default_value' => !empty($edit['contact']) ? $edit['contact'] : FALSE, - '#description' => t('Allow other users to contact you by e-mail via your personal contact form. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('@url' => url("user/$user->uid/contact"))), + '#default_value' => !empty($edit['contact']), + '#description' => t('Allow other users to contact you by e-mail via your personal contact form. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.'), ); return $form; } Index: modules/contact/contact.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v retrieving revision 1.16 diff -u -p -r1.16 contact.pages.inc --- modules/contact/contact.pages.inc 8 Mar 2009 05:08:22 -0000 1.16 +++ modules/contact/contact.pages.inc 20 Apr 2009 23:24:18 -0000 @@ -179,31 +179,53 @@ function contact_user_page($account) { function contact_mail_user(&$form_state, $recipient) { global $user; $form['#token'] = $user->name . $user->mail; - $form['recipient'] = array('#type' => 'value', '#value' => $recipient); - $form['from'] = array('#type' => 'item', + $form['recipient'] = array( + '#type' => 'value', + '#value' => $recipient, + ); + $form['from'] = array( + '#type' => 'item', '#title' => t('From'), '#markup' => check_plain($user->name) . ' <' . check_plain($user->mail) . '>', ); - $form['to'] = array('#type' => 'item', + $form['to'] = array( + '#type' => 'item', '#title' => t('To'), '#markup' => check_plain($recipient->name), ); - $form['subject'] = array('#type' => 'textfield', + $form['subject'] = array( + '#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 50, '#required' => TRUE, ); - $form['message'] = array('#type' => 'textarea', + $form['message'] = array( + '#type' => 'textarea', '#title' => t('Message'), '#rows' => 15, '#required' => TRUE, ); - $form['copy'] = array('#type' => 'checkbox', + $form['copy'] = array( + '#type' => 'checkbox', '#title' => t('Send yourself a copy.'), ); - $form['submit'] = array('#type' => 'submit', + $form['submit'] = array( + '#type' => 'submit', '#value' => t('Send e-mail'), ); + + // If the current and contacted users are the same, disable the form and + // display a warning. + if ($user->uid == $recipient->uid) { + $form['warning'] = array( + '#prefix' => '