function contact_attach_og_contact_mail_page_submit in Contact Attach 5
Override og_contact_mail_page_submit().
Parameters
form_id: A unique string identifying the form.
form_values: The contents of the form fields.
Return value
The group page to go to.
File
- ./
contact_attach.module, line 364 - This is the main code file for the Contact attach module. This module gives users the ability of attaching one or more files to e-mails sent using the site-wide contact form.
Code
function contact_attach_og_contact_mail_page_submit($form_id, $form_values) {
$name = og_contact_get_group_name($form_values['gid']);
// 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 group information:
$group = db_fetch_object(db_query("SELECT * FROM {og_contact} WHERE gid = %d", $form_values['gid']));
// Format the category:
$subject = $form_values['subject'];
// Attachment processing begins here.
$return_message = _contact_attach_process_attachments($message);
if (!empty($return_message)) {
$headers = $return_message['headers'];
$body = $return_message['body'];
}
else {
$headers = array();
// Prepare the body:
$body = implode("\n\n", $message);
}
// Send the e-mail to the recipients:
$recipients = og_contact_get_recipients($form_values['gid']);
drupal_mail('og-contact-page-mail', $recipients, $subject, $body, $from, $headers);
// If the user requests it, send a copy.
if ($form_values['copy']) {
drupal_mail('og-contact-page-copy', $from, $subject, $body, $from, $headers);
}
// Send an auto-reply if necessary:
if ($group->reply) {
drupal_mail('og-contact-page-autoreply', $from, $subject, wordwrap(check_plain($contact->reply)), $contact->recipients);
}
// Log the operation:
flood_register_event('og-contact');
watchdog('mail', t('%name-from sent an e-mail regarding %category.', array(
'%name-from' => $form_values['name'] . " <{$from}>",
'%category' => $name,
)));
// Update user:
drupal_set_message(t('Your message has been sent.'));
// Jump to group page rather than back to contact page to avoid
// contradictory messages if flood control has been activated.
return 'node/' . $group->gid;
}