/**
  * @see	\wcf\system\message\quote\AbstractMessageQuoteHandler::getMessages()
  */
 protected function getMessages(array $data)
 {
     // read news entries
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.newsID IN (?)', array(array_keys($data)));
     $newsList->readObjects();
     $quotedMessages = $validNewsIDs = array();
     // create QuotedMessage objects
     foreach ($newsList->getObjects() as $news) {
         $validNewsIDs[] = $news->newsID;
         $message = new QuotedMessage($news);
         foreach (array_keys($data[$news->newsID]) as $quoteID) {
             $message->addQuote($quoteID, MessageQuoteManager::getInstance()->getQuote($quoteID, false), MessageQuoteManager::getInstance()->getQuote($quoteID, true));
         }
         $quotedMessages[] = $message;
     }
     // check for orphaned quotes
     if (count($validNewsIDs) != count($data)) {
         $orphanedQuoteIDs = array();
         foreach ($data as $newsID => $quoteIDs) {
             if (!in_array($newsID, $validNewsIDs)) {
                 foreach (array_keys($quoteIDs) as $quoteID) {
                     $orphanedQuoteIDs[] = $quoteID;
                 }
             }
         }
         MessageQuoteManager::getInstance()->removeOrphanedQuotes($orphanedQuoteIDs);
     }
     return $quotedMessages;
 }
 /**
  * Loads the news entries.
  */
 protected function loadNews()
 {
     $this->news = array();
     if (empty($this->newsIDs)) {
         return;
     }
     $this->newsIDs = array_unique($this->newsIDs);
     $categoryIDs = NewsCategory::getAccessibleCategoryIDs();
     if (empty($categoryIDs)) {
         return;
     }
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.newsID IN (?)', array($this->newsIDs));
     $newsList->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($categoryIDs));
     // default conditions
     if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) {
         $newsList->getConditionBuilder()->add('news.isActive = 1');
     }
     if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) {
         $newsList->getConditionBuilder()->add('news.isDeleted = 0');
     }
     if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) {
         if (WCF::getUser()->userID) {
             $newsList->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID));
         } else {
             $newsList->getConditionBuilder()->add('news.isPublished = 1');
         }
     }
     $newsList->readObjects();
     $this->news = $newsList->getObjects();
 }
 /**
  * @see	wcf\system\cronjob\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     // get delayed news
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.isPublished = 0');
     $newsList->getConditionBuilder()->add('news.publicationDate <= ?', array(TIME_NOW));
     $newsList->readObjects();
     if (count($newsList->getObjects())) {
         // publish news
         $action = new NewsAction($newsList->getObjects(), 'publish');
         $action->executeAction();
     }
     // get outdated news
     $newsList = new NewsList();
     $newsList->getConditionBuilder()->add('news.isArchived = 0');
     $newsList->getConditionBuilder()->add('news.archivingDate != 0 AND news.archivingDate <= ?', array(TIME_NOW));
     $newsList->readObjects();
     if (count($newsList->getObjects())) {
         // archivate news
         $action = new NewsAction($newsList->getObjects(), 'archive');
         $action->executeAction();
     }
 }