You are here

function _pm_email_notify_token in Privatemsg 6.2

Same name and namespace in other branches
  1. 6 pm_email_notify/pm_email_notify.module \_pm_email_notify_token()

Return an array of token to value mappings for user e-mail messages.

Parameters

$message: The private message array being sent. Must contain at least the fields 'author', 'subject', 'thread_id' and 'body'.

Return value

Array of mappings from token names to values (for use with strtr()).

1 call to _pm_email_notify_token()
pm_email_notify_mail in pm_email_notify/pm_email_notify.module
Implements hook_mail().

File

pm_email_notify/pm_email_notify.module, line 267
Notifies users about new Private Messages via Email.

Code

function _pm_email_notify_token($recipient, $message, $language) {
  $tokens = array(
    '!author_uid' => $message['author']->uid,
    '!author' => privatemsg_recipient_format($message['author'], array(
      'plain' => TRUE,
    )),
    '!pm_subject' => trim(drupal_html_to_text(check_plain($message['subject']))),
    '!pm_body' => trim(drupal_html_to_text(check_markup($message['body'], $message['format'], FALSE))),
    '!thread' => $message['thread_id'],
    '!user_uid' => $recipient->uid,
    '!message' => url(privatemsg_get_dynamic_url_prefix($recipient->uid) . '/view/' . $message['thread_id'], array(
      'absolute' => TRUE,
      'language' => $language,
    )),
    '!settings' => url('user/' . $recipient->uid . '/edit', array(
      'absolute' => TRUE,
      'language' => $language,
    )),
  );

  // Allow other modules to alter the token mapping.
  drupal_alter('pm_email_notify_token', $tokens, $recipient, $message, $language);
  return $tokens;
}