public function insertConversationAlert(array $conversation, array $alertUser, $action,
array $triggerUser = null, array $extraData = null, array &$messageInfo = null
)
{
if (!$triggerUser)
{
$triggerUser = array(
'user_id' => $conversation['last_message_user_id'],
'username' => $conversation['last_message_username']
);
}
if ($triggerUser['user_id'] == $alertUser['user_id'])
{
return;
}
if ($alertUser['email_on_conversation'] && $alertUser['user_state'] == 'valid')
{
if (!isset($conversation['titleCensored']))
{
$conversation['titleCensored'] = XenForo_Helper_String::censorString($conversation['title']);
}
if (isset($messageInfo['message']) && XenForo_Application::get('options')->emailConversationIncludeMessage)
{
if (!isset($messageInfo['messageText']))
{
$bbCodeParserText = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Text'));
$messageInfo['messageText'] = new XenForo_BbCode_TextWrapper($messageInfo['message'], $bbCodeParserText);
$bbCodeParserHtml = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('HtmlEmail'));
$messageInfo['messageHtml'] = new XenForo_BbCode_TextWrapper($messageInfo['message'], $bbCodeParserHtml);
}
$emailTemplate = "conversation_{$action}_messagetext";
}
else
{
$emailTemplate = "conversation_{$action}";
}
$mail = XenForo_Mail::create($emailTemplate, array(
'receiver' => $alertUser,
'sender' => $triggerUser,
'options' => XenForo_Application::get('options'),
'conversation' => $conversation,
'message' => $messageInfo,
), $alertUser['language_id']);
$mail->enableAllLanguagePreCache();
$mail->queue($alertUser['email'], $alertUser['username'], array(), 'from@mail.com', 'from name');
}
}