You are here

function _mass_contact_prepare_bodies in Mass Contact 7

Prepares the message's body.

Parameters

array $form_values: The values returned from the message sending form.

string $format: The input text format the message was created with.

Return value

array The prepared body, including any possible addons.

1 call to _mass_contact_prepare_bodies()
mass_contact_mail_page_submit in ./mass_contact.page.inc
Processes the main Mass Contact mail form.

File

./mass_contact.page.inc, line 862
The main form for creating and sending the messages.

Code

function _mass_contact_prepare_bodies(array $form_values, $format) {
  $body = array();
  if (!empty($format) && $format == 'plain_text') {

    // Start with the message prefix.
    $body[] = _mass_contact_prepare_message_addon('prefix', 'plain text');

    // Add in the actual message.
    if (is_array($form_values['message'])) {
      $body[] = wordwrap(check_plain($form_values['message']['value']));
    }
    else {
      $body[] = wordwrap(check_plain($form_values['message']));
    }

    // End with the message suffix.
    $body[] = _mass_contact_prepare_message_addon('suffix', 'plain text');
  }
  elseif (module_exists('mimemail')) {

    // Start with the message prefix.
    $body[] = _mass_contact_prepare_message_addon('prefix', 'html');
    global $language;

    // Add in the actual message.
    if (is_array($form_values['message'])) {
      $body[] = check_markup($form_values['message']['value'], $format, $language ? $language->language : LANGUAGE_NONE);
    }
    else {
      $body[] = check_markup($form_values['message'], $format, $language ? $language->language : LANGUAGE_NONE);
    }

    // End with the message suffix.
    $body[] = _mass_contact_prepare_message_addon('suffix', 'html');
  }
  else {

    // Start with the message prefix.
    $body[] = _mass_contact_prepare_message_addon('prefix', 'converted');

    // Add in the actual message.
    if (is_array($form_values['message'])) {
      $body[] = wordwrap(check_plain($form_values['message']['value']));
    }
    else {
      $body[] = wordwrap(check_plain($form_values['message']));
    }

    // End with the message suffix.
    $body[] = _mass_contact_prepare_message_addon('suffix', 'converted');
  }
  return $body;
}