public function consoleSendList(BASE_CLASS_EventCollector $event) { $params = $event->getParams(); $userIdList = $params['userIdList']; $conversationListByUserId = $this->service->getConversationListForConsoleNotificationMailer($userIdList); $conversationIdList = array(); foreach ($conversationListByUserId as $recipientId => $conversationList) { foreach ($conversationList as $conversation) { $conversationIdList[$conversation['id']] = $conversation['id']; } } $result = $this->service->getConversationListByIdList($conversationIdList); $conversationList = array(); foreach ($result as $conversation) { $conversationList[$conversation->id] = $conversation; } foreach ($conversationListByUserId as $recipientId => $list) { foreach ($list as $conversation) { $senderId = $conversation['initiatorId'] == $recipientId ? $conversation['interlocutorId'] : $conversation['initiatorId']; $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($senderId)); $avatar = $avatars[$senderId]; if ($conversation['subject'] == MAILBOX_BOL_ConversationService::CHAT_CONVERSATION_SUBJECT) { $actionName = 'mailbox-new_chat_message'; } else { $actionName = 'mailbox-new_message'; } $event->add(array('pluginKey' => 'mailbox', 'entityType' => 'mailbox-conversation', 'entityId' => $conversation['id'], 'userId' => $recipientId, 'action' => $actionName, 'time' => $conversation['timeStamp'], 'data' => array('avatar' => $avatar, 'string' => OW::getLanguage()->text('mailbox', 'email_notifications_comment', array('userName' => BOL_UserService::getInstance()->getDisplayName($senderId), 'userUrl' => BOL_UserService::getInstance()->getUserUrl($senderId), 'conversationUrl' => $this->service->getConversationUrl($conversation['id']))), 'content' => $conversation['text']))); if (!empty($conversationList[$conversation['id']])) { $conversationList[$conversation['id']]->notificationSent = 1; $this->service->saveConversation($conversationList[$conversation['id']]); } } } }
public function consoleSendList(BASE_CLASS_EventCollector $event) { $params = $event->getParams(); $userIdList = $params['userIdList']; $conversationListByUserId = $this->service->getConversationListForConsoleNotificationMailer($userIdList); $conversationIdList = array(); foreach ($conversationListByUserId as $recipientId => $conversationList) { foreach ($conversationList as $conversation) { $conversationIdList[$conversation['id']] = $conversation['id']; } } $result = $this->service->getConversationListByIdList($conversationIdList); $conversationList = array(); foreach ($result as $conversation) { $conversationList[$conversation->id] = $conversation; } foreach ($conversationListByUserId as $recipientId => $list) { foreach ($list as $conversation) { $senderId = $conversation['initiatorId'] == $recipientId ? $conversation['interlocutorId'] : $conversation['initiatorId']; $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($senderId)); $avatar = $avatars[$senderId]; if ($conversation['subject'] == MAILBOX_BOL_ConversationService::CHAT_CONVERSATION_SUBJECT) { $actionName = 'mailbox-new_chat_message'; $conversationUrl = OW::getRouter()->urlForRoute('mailbox_chat_conversation', array('userId' => $senderId)); } else { $actionName = 'mailbox-new_message'; $conversationUrl = $this->service->getConversationUrl($conversation['id']); } $trigger = true; $content = $conversation['text']; $contentImageSrc = null; $contentImageUrl = null; $contentImageTitle = null; // try to render the system message if ($conversation['isSystem']) { $textParams = json_decode($content, true); if ($textParams['entityType'] == 'mailbox' && $textParams['eventName'] == 'renderOembed') { $content = !empty($textParams['params']['message']) ? $textParams['params']['message'] : null; $contentImageSrc = !empty($textParams['params']['thumbnail_url']) ? $textParams['params']['thumbnail_url'] : null; $contentImageUrl = !empty($textParams['params']['href']) ? $textParams['params']['href'] : null; $contentImageTitle = !empty($textParams['params']['title']) ? $textParams['params']['title'] : null; } if (!$contentImageSrc) { $trigger = false; } } if ($trigger) { $event->add(array('pluginKey' => 'mailbox', 'entityType' => 'mailbox-conversation', 'entityId' => $conversation['id'], 'userId' => $recipientId, 'action' => $actionName, 'time' => $conversation['timeStamp'], 'data' => array('avatar' => $avatar, 'string' => OW::getLanguage()->text('mailbox', 'email_notifications_comment', array('userName' => BOL_UserService::getInstance()->getDisplayName($senderId), 'userUrl' => BOL_UserService::getInstance()->getUserUrl($senderId), 'conversationUrl' => $conversationUrl)), 'content' => $content, 'contentImage' => array('src' => $contentImageSrc, 'url' => $contentImageUrl, 'title' => $contentImageTitle)))); } if (!empty($conversationList[$conversation['id']])) { $conversationList[$conversation['id']]->notificationSent = 1; $this->service->saveConversation($conversationList[$conversation['id']]); } } } }