- Patch #16590 by kbahey: usability improvement: add 'subject' form to contact form.

4.6.x
Dries Buytaert 2005-02-18 18:50:11 +00:00
parent 4f79fafb3c
commit 9e8d74b490
2 changed files with 22 additions and 4 deletions

View File

@ -74,6 +74,9 @@ function contact_mail_user() {
if (!$edit['message']) {
form_set_error('message', t('You must enter a message.'));
}
if (!$edit['subject']) {
form_set_error('subject', t('You must enter a subject.'));
}
if (!form_get_errors()) {
// Compose the body:
@ -86,12 +89,17 @@ function contact_mail_user() {
// Tidy up the body:
foreach ($message as $key => $value) {
$message[$key] = wordwrap(strip_tags($value));
}
// Prepare all fields:
$to = $account->mail;
$from = $user->mail;
$subject = '['. variable_get('site_name', 'drupal') .'] '. t('message from %name', array('%name' => $user->name));
// Format the subject:
$subject = '['. variable_get('site_name', 'drupal') .'] '. $edit['subject'];
// Prepare the body:
$body = implode("\n\n", $message);
// Send the e-mail:
@ -114,6 +122,7 @@ function contact_mail_user() {
$output = form_item(t('From'), $user->name .' <'. $user->mail .'>');
$output .= form_item(t('To'), $account->name);
$output .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 8, NULL, NULL, TRUE);
$output .= form_textarea(t('Message'), 'message', $edit['message'], 70, 8, NULL, NULL, TRUE);
$output .= form_submit(t('Send e-mail'));
$output = form($output);

View File

@ -74,6 +74,9 @@ function contact_mail_user() {
if (!$edit['message']) {
form_set_error('message', t('You must enter a message.'));
}
if (!$edit['subject']) {
form_set_error('subject', t('You must enter a subject.'));
}
if (!form_get_errors()) {
// Compose the body:
@ -86,12 +89,17 @@ function contact_mail_user() {
// Tidy up the body:
foreach ($message as $key => $value) {
$message[$key] = wordwrap(strip_tags($value));
}
// Prepare all fields:
$to = $account->mail;
$from = $user->mail;
$subject = '['. variable_get('site_name', 'drupal') .'] '. t('message from %name', array('%name' => $user->name));
// Format the subject:
$subject = '['. variable_get('site_name', 'drupal') .'] '. $edit['subject'];
// Prepare the body:
$body = implode("\n\n", $message);
// Send the e-mail:
@ -114,6 +122,7 @@ function contact_mail_user() {
$output = form_item(t('From'), $user->name .' <'. $user->mail .'>');
$output .= form_item(t('To'), $account->name);
$output .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 8, NULL, NULL, TRUE);
$output .= form_textarea(t('Message'), 'message', $edit['message'], 70, 8, NULL, NULL, TRUE);
$output .= form_submit(t('Send e-mail'));
$output = form($output);