You are here

function webform2pdf_preprocess_webform_mail_message in Webform2PDF 6

Implementation of template_preprocess_webform_mail_message()

File

./webform2pdf.module, line 128

Code

function webform2pdf_preprocess_webform_mail_message(&$vars) {
  global $webform2pdf_send2pdf;
  $webform2pdf = _webform2pdf_get_template($vars['node']->nid);
  if ($webform2pdf['enabled'] && $webform2pdf['pdf_send_email']) {
    $nopdf = array();
    if (!empty($webform2pdf['no_send_email_addr'])) {
      $no_mail = unserialize($default['no_send_email_addr']);
    }
    else {
      $no_mail = array();
    }
    if (is_array($no_mail)) {
      $no_mail = array_diff($no_mail, array(
        0,
      ));
      if (!empty($no_mail)) {
        if ($no_mail['email'] == 'email') {
          unset($no_mail['email']);
          $nopdf[] = $vars['node']->webform['email'];
        }
        if ($attach_pdf) {
          foreach ($no_mail as $cid) {
            $SQL = "SELECT data FROM {webform_submitted_data} WHERE nid = %d AND sid = %d AND cid = %d";
            $result = db_query($SQL, $webform2pdf_send2pdf['nid'], $webform2pdf_send2pdf['sid'], $cid);
            $no_mail_addr = db_fetch_array($result);
            $nopdf[] = $no_mail_addr['data'];
          }
        }
      }
    }

    // Check for a multi-page form that is not yet complete.
    $webform2pdf_send2pdf = array(
      'nid' => $vars['node']->nid,
      'sid' => $vars['sid'],
      'nopdf' => $nopdf,
    );
  }
}