Filling up moderation dropdown with outstanding queues
authorAlexander Ebert <ebert@woltlab.com>
Fri, 12 Dec 2014 15:07:34 +0000 (16:07 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 12 Dec 2014 15:07:34 +0000 (16:07 +0100)
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php

index 692aa708f3b83769d5855536da26fd61e5108202..14699045c6d543632ba991205ff6d8818030d9f8 100644 (file)
@@ -134,23 +134,35 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction {
                        $queues = $queueList->getObjects();
                }
                
-               WCF::getTPL()->assign(array(
-                       'queues' => $queues
-               ));
-               
                // check if user storage is outdated
                $totalCount = ModerationQueueManager::getInstance()->getUnreadModerationCount();
                $count = count($queues);
-               if ($count < 5 && $count < $totalCount) {
-                       UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'outstandingModerationCount');
+               if ($count < 5) {
+                       // load more entries to fill up list
+                       $queueList = new ViewableModerationQueueList();
+                       $queueList->getConditionBuilder()->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
+                       $queueList->sqlOrderBy = "moderation_queue.lastChangeTime DESC";
+                       $queueList->sqlLimit = 5 - $count;
+                       $queueList->loadUserProfiles = true;
+                       $queueList->readObjects();
+                       $queues = array_merge($queues, $queueList->getObjects());
                        
-                       // check for orphaned queues
-                       $queueCount = ModerationQueueManager::getInstance()->getUnreadModerationCount();
-                       if (count($queues) < $queueCount) {
-                               ModerationQueueManager::getInstance()->identifyOrphans();
+                       // check if stored count is out of sync
+                       if($count < $totalCount) {
+                               UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'outstandingModerationCount');
+                               
+                               // check for orphaned queues
+                               $queueCount = ModerationQueueManager::getInstance()->getUnreadModerationCount();
+                               if (count($queues) < $queueCount) {
+                                       ModerationQueueManager::getInstance()->identifyOrphans();
+                               }
                        }
                }
                
+               WCF::getTPL()->assign(array(
+                       'queues' => $queues
+               ));
+               
                return array(
                        'template' => WCF::getTPL()->fetch('moderationQueueList'),
                        'totalCount' => $totalCount