public function getConversationItem($mode, $convId) { $userId = OW::getUser()->getId(); $conversation = $this->conversationDao->getConversationItem($convId); $conversationRead = 0; $conversationHasReply = false; switch ($userId) { case $conversation['initiatorId']: $conversationOpponentId = $conversation['interlocutorId']; if ((int) $conversation['read'] & MAILBOX_BOL_ConversationDao::READ_INITIATOR) { $conversationRead = 1; } break; case $conversation['interlocutorId']: $conversationOpponentId = $conversation['initiatorId']; if ((int) $conversation['read'] & MAILBOX_BOL_ConversationDao::READ_INTERLOCUTOR) { $conversationRead = 1; } break; } switch ($userId) { case $conversation['lastMessageSenderId']: $conversationHasReply = false; break; case $conversation['lastMessageRecipientId']: $conversationHasReply = true; break; } $conversation['opponentId'] = $conversationOpponentId; $conversation['conversationRead'] = $conversationRead; $conversation['mode'] = $mode; $profileDisplayname = BOL_UserService::getInstance()->getDisplayName($conversationOpponentId); $profileDisplayname = empty($profileDisplayname) ? BOL_UserService::getInstance()->getUserName($conversationOpponentId) : $profileDisplayname; $profileUrl = BOL_UserService::getInstance()->getUserUrl($conversationOpponentId); $avatarUrl = BOL_AvatarService::getInstance()->getAvatarUrl($conversationOpponentId); $profileAvatarUrl = empty($avatarUrl) ? BOL_AvatarService::getInstance()->getDefaultAvatarUrl() : $avatarUrl; $convDate = empty($conversation['timeStamp']) ? '' : UTIL_DateTime::formatDate((int) $conversation['timeStamp'], true); $convPreview = $this->getConversationPreviewText($conversation); $item = array(); $item['conversationId'] = (int) $convId; $item['opponentId'] = (int) $conversationOpponentId; $item['mode'] = $mode; $item['conversationRead'] = (int) $conversationRead; $item['profileUrl'] = $profileUrl; $item['avatarUrl'] = $profileAvatarUrl; $avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($conversationOpponentId)); $item['avatarLabel'] = !empty($avatarData[$conversationOpponentId]) ? mb_substr($avatarData[$conversationOpponentId]['label'], 0, 1) : ' '; $item['displayName'] = $profileDisplayname; $item['dateLabel'] = $convDate; $item['previewText'] = $convPreview; $item['lastMessageTimestamp'] = (int) $conversation['timeStamp']; $item['reply'] = $conversationHasReply; $item['newMessageCount'] = $this->countUnreadMessagesForConversation($convId, $userId); if ((int) $conversation['initiatorId'] == OW::getUser()->getId()) { $item['conversationViewed'] = (bool) ((int) $conversation['viewed'] & MAILBOX_BOL_ConversationDao::VIEW_INITIATOR); } if ((int) $conversation['interlocutorId'] == OW::getUser()->getId()) { $item['conversationViewed'] = (bool) ((int) $conversation['viewed'] & MAILBOX_BOL_ConversationDao::VIEW_INTERLOCUTOR); } if ($mode == 'chat') { $item['url'] = OW::getRouter()->urlForRoute('mailbox_chat_conversation', array('userId' => $conversationOpponentId)); } if ($mode == 'mail') { $item['url'] = OW::getRouter()->urlForRoute('mailbox_mail_conversation', array('convId' => $convId)); } return $item; }