Fixes #43
authorMatthias Schmidt <gravatronics@live.com>
Wed, 9 Jan 2013 15:05:29 +0000 (16:05 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 9 Jan 2013 15:05:29 +0000 (16:05 +0100)
files/lib/system/moderation/queue/report/ConversationMessageModerationQueueReportHandler.class.php

index 95f76306675046b6d93751f8018f2f1604f59acd..e1fc4d01ed2300f44d106d01d491868f1d6c769b 100644 (file)
@@ -128,29 +128,36 @@ class ConversationMessageModerationQueueReportHandler implements IModerationQueu
                
                // fetch messages
                $messageList = new ConversationMessageList();
-               $messageList->getConditionBuilder()->add("conversation_message.messageID IN (?)", array($objectIDs));
-               $messageList->sqlLimit = 0;
+               $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;
                }
                
-               $conversationList = new ConversationList();
-               $conversationList->getConditionBuilder()->add("conversation.conversationID IN (?)", array($conversationIDs));
-               $conversationList->sqlLimit = 0;
-               $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);
+               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);
+                               }
                        }
                }
        }