function _mail_edit_mail_alter in Mail Editor 7
Implements hook_mail_alter().
Parameters
array $message:
1 call to _mail_edit_mail_alter()
- mail_edit_mail_alter in ./
mail_edit.module - Implements hook_mail_alter().
File
- ./
mail_edit.alter.inc, line 77 - Implementation of hook_mail_alter() for the Mail Editor module.
Code
function _mail_edit_mail_alter(array &$message) {
//dpm($message, "BEFORE mail_edit_mail_alter({$message['id']})");
if (!($template = _mail_edit_load($message['id'], $message['language']))) {
return;
}
$data = isset($message['params']['data']) ? $message['params']['data'] : $message['params'];
$data['template'] = $template;
if (isset($message['params']['account']) && !isset($data['user'])) {
$data['user'] = $message['params']['account'];
}
$options = array(
'language' => $message['language'],
'clear' => TRUE,
);
if ($message['module'] == 'user') {
$options['callback'] = 'user_mail_tokens';
}
$subject = mail_edit_format($template['subject'], $data, $options);
// #2185909: Remove newline character introduced by _drupal_wrap_mail_line().
$message['subject'] = str_replace(array(
"\n",
), '', trim(drupal_html_to_text($subject)));
$context = isset($message['params']['context']['mail_edit']) ? $message['params']['context']['mail_edit'] : NULL;
$body = mail_edit_format($template['body'], $data, $options, $context);
// Remove trailing spaces because these may be interpreted as soft line
// breaks by the email client.
$message['body'] = array(
preg_replace('/ +(\\r?\\n)/', '\\1', $body),
);
/* Uncomment this line for debugging...
dpm($message, 'drupal_mail() is disabled in _mail_edit_mail_alter(), this would be sent');
$message['to'] = '';
/**/
}