public static function sendAddMessage($messageData, $taskData, $fromUser, $toUsers, array $eventData = array()) { IncludeModuleLangFile(__FILE__); $user = CTaskNotifications::getUser($fromUser); $messageTemplate = CTaskNotifications::getGenderMessage($fromUser, "TASKS_COMMENT_MESSAGE_ADD"); //$strMsgEditComment = CTaskNotifications::getGenderMessage($occurAsUserId, "TASKS_COMMENT_MESSAGE_EDIT"); $messageTemplatePush = CTaskNotifications::getGenderMessage($fromUser, "TASKS_COMMENT_MESSAGE_ADD_PUSH"); // in comment messages we can get BBCODEs that are not supported by IM. rip them out. also limit text length to 100 $message = CTaskNotifications::clearNotificationText($messageData['POST_MESSAGE']); $messageCropped = self::cropMessage($message); CTaskNotifications::SendMessageEx($taskData["ID"], $fromUser, $toUsers, array('INSTANT' => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($taskData["TITLE"], '[COLOR=#000000]' . $messageCropped . '[/COLOR]'), $messageTemplate), 'EMAIL' => str_replace(array("#TASK_TITLE#", "#TASK_COMMENT_TEXT#"), array($taskData["TITLE"], $message), $messageTemplate), 'PUSH' => CTaskNotifications::cropMessage($messageTemplatePush, array('USER_NAME' => CUser::FormatName(CSite::GetNameFormat(false), $user), 'TASK_TITLE' => $taskData["TITLE"], 'TASK_COMMENT_TEXT' => html_entity_decode(CTextParser::clearAllTags($message))), CTaskNotifications::PUSH_MESSAGE_MAX_LENGTH)), array('ENTITY_CODE' => 'COMMENT', 'EVENT_DATA' => $eventData, 'NOTIFY_EVENT' => 'comment', 'NOTIFY_ANSWER' => true, 'TASK_URL' => array('PARAMETERS' => array('MID' => $messageData['ID']), 'HASH' => 'message' . $messageData['ID']))); }
public static function getGenderMessage($userId, $messageCode) { $user = CTaskNotifications::getUser($userId); if ($user['PERSONAL_GENDER'] == 'M' || $user['PERSONAL_GENDER'] == 'F') { $message = GetMessage($messageCode . '_' . $user['PERSONAL_GENDER']); if ((string) $message == '') { $message = GetMessage($messageCode); } } else { // no gender? try to get neutral $message = GetMessage($messageCode); if ((string) $message == '') { $message = GetMessage($messageCode . '_M'); } } return $message; }