contact_mail_page_submit
modules/contact/contact.module, строка 504
- Версии
- 5
contact_mail_page_submit(
$form_id,$form_values)- 6
contact_mail_page_submit($form, &$form_state)
Process the site-wide contact page form submission.
Код
<?php
function contact_mail_page_submit($form_id, $form_values) {
// E-mail address of the sender: as the form field is a text field,
// all instances of \r and \n have been automatically stripped from it.
$from = $form_values['mail'];
// Compose the body:
$message[] = t("!name sent a message using the contact form at !form.", array('!name' => $form_values['name'], '!form' => url($_GET['q'], NULL, NULL, TRUE)));
$message[] = $form_values['message'];
// Tidy up the body:
foreach ($message as $key => $value) {
$message[$key] = wordwrap($value);
}
// Load the category information:
$contact = db_fetch_object(db_query("SELECT * FROM {contact} WHERE cid = %d", $form_values['cid']));
// Format the category:
$subject = t('[!category] !subject', array('!category' => $contact->category, '!subject' => $form_values['subject']));
// Prepare the body:
$body = implode("\n\n", $message);
// Send the e-mail to the recipients:
drupal_mail('contact-page-mail', $contact->recipients, $subject, $body, $from);
// If the user requests it, send a copy.
if ($form_values['copy']) {
drupal_mail('contact-page-copy', $from, $subject, $body, $from);
}
// Send an auto-reply if necessary:
if ($contact->reply) {
drupal_mail('contact-page-autoreply', $from, $subject, wordwrap($contact->reply), $contact->recipients);
}
// Log the operation:
flood_register_event('contact');
watchdog('mail', t('%name-from sent an e-mail regarding %category.', array('%name-from' => $form_values['name'] ." <$from>", '%category' => $contact->category)));
// Update user:
drupal_set_message(t('Your message has been sent.'));
// Jump to home page rather than back to contact page to avoid contradictory messages if flood control has been activated.
return '';
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии