You are here

function _mass_contact_prepare_message_addon in Mass Contact 7

Prepares a message addon (prefix or suffix).

Parameters

string $addon: Specifies the addon part to process. There are two possible values: 'prefix' and 'suffix'.

string $style: Indicates how to process the addon. There are three possible values:

  • 'plain text': Indicates that the returned addon should be in plain text format.
  • 'html': Indicates that the returned addon should be in HTML format.
  • 'converted': Indicates that the returned addon is HTML but should be converted into plain text format.

Return value

string The prepared message addon.

1 call to _mass_contact_prepare_message_addon()
_mass_contact_prepare_bodies in ./mass_contact.page.inc
Prepares the message's body.

File

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

Code

function _mass_contact_prepare_message_addon($addon, $style) {
  $token_module_exists = module_exists('token');
  $message = '';
  switch ($addon) {
    case 'prefix':
      if ($token_module_exists) {
        $message_addon = variable_get('mass_contact_message_prefix', t('[current-user:name] has sent you a group email from [site:name].'));
      }
      else {
        $message_addon = variable_get('mass_contact_message_prefix', t('You were sent a group email from @site.', array(
          '@site' => url(NULL, array(
            'absolute' => TRUE,
          )),
        )));
      }
      break;
    case 'suffix':
      if ($token_module_exists) {
        $message_addon = variable_get('mass_contact_message_suffix', '');
      }
      else {
        $message_addon = variable_get('mass_contact_message_suffix', '');
      }
      break;
  }
  if (is_array($message_addon)) {
    $message_addon_text = $message_addon['value'];
  }
  else {
    $message_addon_text = $message_addon;
  }
  if (!empty($message_addon_text)) {
    switch ($style) {
      case 'plain text':
        if ($token_module_exists) {
          $message .= wordwrap(check_plain(token_replace($message_addon_text)));
        }
        else {
          $message .= wordwrap(check_plain($message_addon_text));
        }
        break;
      case 'html':
        global $language;
        if (is_array($message_addon)) {
          if ($token_module_exists) {
            $message .= check_markup(token_replace($message_addon_text), $message_addon['format'], $language ? $language->language : LANGUAGE_NONE);
          }
          else {
            $message .= check_markup($message_addon_text, $message_addon['format'], $language ? $language->language : LANGUAGE_NONE);
          }
        }
        else {
          if ($token_module_exists) {
            $message .= check_markup(token_replace($message_addon_text), filter_fallback_format(), $language ? $language->language : LANGUAGE_NONE);
          }
          else {
            $message .= check_markup($message_addon_text, filter_fallback_format(), $language ? $language->language : LANGUAGE_NONE);
          }
        }
        break;
      case 'converted':
        if ($token_module_exists) {
          $message .= drupal_html_to_text(token_replace($message_addon_text));
        }
        else {
          $message .= drupal_html_to_text($message_addon_text);
        }
        break;
    }
  }
  return $message;
}