function contact_attach_contact_mail_user_submit in Contact Attach 6
Same name and namespace in other branches
- 5 contact_attach.module \contact_attach_contact_mail_user_submit()
Override contact_mail_user_submit().
Parameters
form: An associative array containing the structure of the form.
form_state: A keyed array containing the current state of the form.
1 string reference to 'contact_attach_contact_mail_user_submit'
- contact_attach_form_alter in ./
contact_attach.module - Implementation of hook_form_alter().
File
- ./
contact_attach.module, line 235 - Allows attaching files to e-mails sent using the site-wide contact form.
Code
function contact_attach_contact_mail_user_submit($form, &$form_state) {
global $user, $language;
$account = $form_state['values']['recipient'];
// Send from the current user to the requested user.
$to = $account->mail;
$from = $user->mail;
// Save both users and all form values for email composition.
$values = $form_state['values'];
$values['account'] = $account;
$values['user'] = $user;
// Send the e-mail in the requested user language.
$results[0] = drupal_mail('contact_attach', 'contact_user_mail', $to, user_preferred_language($account), $values, $from);
// Send a copy if requested, using current page language.
if ($form_state['values']['copy']) {
$results[1] = drupal_mail('contact_attach', 'contact_user_copy', $from, $language, $values, $from);
}
for ($i = 0; $i < 2; $i++) {
if (!empty($results[$i])) {
if (!$results[$i]['result']) {
watchdog('mail', '%name-from attempted to send %name-to an e-mail, but was unsuccessful.', array(
'%name-from' => $user->name,
'%name-to' => $account->name,
));
drupal_set_message(t('The message has NOT been sent.'));
}
else {
flood_register_event('contact');
watchdog('mail', '%name-from sent %name-to an e-mail.', array(
'%name-from' => $user->name,
'%name-to' => $account->name,
));
drupal_set_message(t('The message has been sent.'));
}
}
}
// Back to the requested users profile page.
$form_state['redirect'] = "user/{$account->uid}";
}