/**
  * @see	\wcf\system\message\quote\AbstractMessageQuoteHandler::getMessages()
  */
 protected function getMessages(array $data)
 {
     // read messages
     $messageList = new ConversationMessageList();
     $messageList->getConditionBuilder()->add("conversation_message.messageID IN (?)", array(array_keys($data)));
     $messageList->readObjects();
     $messages = $messageList->getObjects();
     // read conversations
     $conversationIDs = $validMessageIDs = array();
     foreach ($messages as $message) {
         $conversationIDs[] = $message->conversationID;
         $validMessageIDs[] = $message->messageID;
     }
     $quotedMessages = array();
     if (!empty($conversationIDs)) {
         $conversationList = new ConversationList();
         $conversationList->getConditionBuilder()->add("conversation.conversationID IN (?)", array($conversationIDs));
         $conversationList->readObjects();
         $conversations = $conversationList->getObjects();
         // create QuotedMessage objects
         foreach ($messages as $conversationMessage) {
             $conversationMessage->setConversation($conversations[$conversationMessage->conversationID]);
             $message = new QuotedMessage($conversationMessage);
             foreach (array_keys($data[$conversationMessage->messageID]) as $quoteID) {
                 $message->addQuote($quoteID, MessageQuoteManager::getInstance()->getQuote($quoteID, false), MessageQuoteManager::getInstance()->getQuote($quoteID, true));
             }
             $quotedMessages[] = $message;
         }
     }
     // check for orphaned quotes
     if (count($validMessageIDs) != count($data)) {
         $orphanedQuoteIDs = array();
         foreach ($data as $messageID => $quoteIDs) {
             if (!in_array($messageID, $validMessageIDs)) {
                 foreach (array_keys($quoteIDs) as $quoteID) {
                     $orphanedQuoteIDs[] = $quoteID;
                 }
             }
         }
         MessageQuoteManager::getInstance()->removeOrphanedQuotes($orphanedQuoteIDs);
     }
     return $quotedMessages;
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     WCF::getTPL()->assign(array('messageID' => $this->messageID, 'message' => $this->message, 'conversationID' => $this->conversationID, 'conversation' => $this->conversation, 'isFirstMessage' => $this->isFirstMessage, 'items' => $this->messageList->countObjects(), 'messages' => $this->messageList->getObjects(), 'attachmentList' => $this->messageList->getAttachmentList()));
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     MessageQuoteManager::getInstance()->assignVariables();
     WCF::getTPL()->assign(array('conversation' => $this->conversation, 'conversationID' => $this->conversationID, 'items' => $this->messageList->countObjects(), 'messages' => $this->messageList->getObjects(), 'attachmentList' => $this->messageList->getAttachmentList()));
 }
 /**
  * @see	\wcf\system\attachment\IAttachmentObjectType::cacheObjects()
  */
 public function cacheObjects(array $objectIDs)
 {
     $messageList = new ConversationMessageList();
     $messageList->setObjectIDs($objectIDs);
     $messageList->readObjects();
     $conversationIDs = array();
     foreach ($messageList as $message) {
         $conversationIDs[] = $message->conversationID;
     }
     if (!empty($conversationIDs)) {
         $conversations = Conversation::getUserConversations($conversationIDs, WCF::getUser()->userID);
         foreach ($messageList as $message) {
             if (isset($conversations[$message->conversationID])) {
                 $message->setConversation($conversations[$message->conversationID]);
             }
         }
     }
     foreach ($messageList->getObjects() as $objectID => $object) {
         $this->cachedObjects[$objectID] = $object;
     }
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::populate()
  */
 public function populate(array $queues)
 {
     $objectIDs = array();
     foreach ($queues as $object) {
         $objectIDs[] = $object->objectID;
     }
     // fetch messages
     $messageList = new ConversationMessageList();
     $messageList->setObjectIDs($objectIDs);
     $messageList->readObjects();
     $messages = $messageList->getObjects();
     // set orphaned queues
     foreach ($queues as $queue) {
         if (!isset($messages[$queue->objectID])) {
             $queue->setIsOrphaned();
         }
     }
     // fetch conversations
     $conversationIDs = array();
     foreach ($messages as $message) {
         $conversationIDs[] = $message->conversationID;
     }
     if (!empty($conversationIDs)) {
         $conversationList = new ConversationList();
         $conversationList->setObjectIDs($conversationIDs);
         $conversationList->readObjects();
         $conversations = $conversationList->getObjects();
         foreach ($queues as $object) {
             if (isset($messages[$object->objectID])) {
                 $message = $messages[$object->objectID];
                 $message->setConversation($conversations[$message->conversationID]);
                 $object->setAffectedObject($message);
             }
         }
     }
 }