You are here

function print_mail_form_submit in Printer, email and PDF versions 5.3

Same name and namespace in other branches
  1. 5.4 print_mail/print_mail.inc \print_mail_form_submit()
  2. 6 print_mail/print_mail.inc \print_mail_form_submit()
  3. 7.2 print_mail/print_mail.inc \print_mail_form_submit()
  4. 7 print_mail/print_mail.inc \print_mail_form_submit()
  5. 5.x print_mail/print_mail.inc \print_mail_form_submit()

Process the send by-email form submission.

File

print_mail/print_mail.inc, line 210

Code

function print_mail_form_submit($form_id, $form_values) {
  if (!array_key_exists('cancel', $form_values)) {
    if (!empty($form_values['fld_from_name'])) {
      $from = '"' . $form_values['fld_from_name'] . '" <' . $form_values['fld_from_addr'] . '>';
    }
    else {
      $from = $form_values['fld_from_addr'];
    }
    $to = $form_values['txt_to_addrs'];
    $params = array();
    $params['subject'] = $form_values['fld_subject'];
    $params['message'] = $form_values['txt_message'];
    $params['path'] = $form_values['path'];
    $params['cid'] = isset($form_values['cid']) ? $form_values['cid'] : '';
    $params['teaser'] = $form_values['chk_teaser'];
    print_mail_mail('sendpage', $message, $params);
    $ret = drupal_mail('print_mail_sendpage', $to, $message['subject'], $message['body'], $from, $message['headers']);
    if ($ret) {
      flood_register_event('print_mail');
      watchdog('print_mail', $form_values['fld_from_name'] . ' [' . $form_values['fld_from_addr'] . '] sent ' . $form_values['path'] . ' to [' . $to . ']');
      $site_name = variable_get('site_name', t('us'));
      drupal_set_message(t('Thank you for spreading the word about !site.', array(
        '!site' => $site_name,
      )));
    }
  }
  return preg_replace('!^book/export/html/!', 'node/', $form_values['path']);
}