/** * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare() */ public function prepare(array $events) { $responseIDs = array(); foreach ($events as $event) { $responseIDs[] = $event->objectID; } $responseList = new CommentResponseList(); $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs)); $responseList->readObjects(); $responses = $responseList->getObjects(); $commentIDs = $comments = array(); foreach ($responses as $response) { $commentIDs[] = $response->commentID; } if (!empty($commentIDs)) { $commentList = new CommentList(); $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs)); $commentList->readObjects(); $comments = $commentList->getObjects(); } // fetch news entries $newsIDs = $news = array(); foreach ($comments as $comment) { $newsIDs[] = $comment->objectID; } if (!empty($newsIDs)) { $newsList = new ViewableNewsList(); $newsList->getConditionBuilder()->add("news.newsID IN (?)", array($newsIDs)); $newsList->readObjects(); $news = $newsList->getObjects(); } $userIDs = $user = array(); foreach ($comments as $comment) { $userIDs[] = $comment->userID; } if (!empty($userIDs)) { $userList = new UserList(); $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs)); $userList->readObjects(); $users = $userList->getObjects(); } foreach ($events as $event) { if (isset($responses[$event->objectID])) { $response = $responses[$event->objectID]; $comment = $comments[$response->commentID]; if (isset($news[$comment->objectID]) && isset($users[$comment->userID])) { $newsEntry = $news[$comment->objectID]; if (!$newsEntry->canRead()) { continue; } $event->setIsAccessible(); $text = WCF::getLanguage()->getDynamicVariable('news.recentActivity.newsCommentResponse', array('commentAuthor' => $users[$comment->userID], 'news' => $newsEntry)); $event->setTitle($text); $event->setDescription($response->getExcerpt()); continue; } } $event->setIsOrphaned(); } }
/** * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare() */ public function prepare(array $events) { $newsIDs = array(); foreach ($events as $event) { $newsIDs[] = $event->objectID; } $newsList = new ViewableNewsList(); $newsList->getConditionBuilder()->add("news.newsID IN (?)", array($newsIDs)); $newsList->readObjects(); $newsEntries = $newsList->getObjects(); foreach ($events as $event) { if (isset($newsEntries[$event->objectID])) { $news = $newsEntries[$event->objectID]; if (!$news->canRead()) { continue; } $event->setIsAccessible(); $text = WCF::getLanguage()->getDynamicVariable('news.recentActivity.likedNews', array('news' => $news)); $event->setTitle($text); $event->setDescription($news->getExcerpt()); } else { $event->setIsOrphaned(); } } }
/** * @see \wcf\data\DatabaseObjectList::readObjects() */ public function readObjects() { if ($this->objectIDs === null) { $this->readObjectIDs(); } parent::readObjects(); }
/** * Creates a new NewsCategoryList object. * * @param array<integer> $categoryIDs */ public function __construct(array $categoryIDs) { ViewableNewsList::__construct(); // accessible news categories if (!empty($categoryIDs)) { $this->getConditionBuilder()->add('news_to_category.categoryID IN (?)', array($categoryIDs)); $this->getConditionBuilder()->add('news.newsID = news_to_category.newsID'); } else { $this->getConditionBuilder()->add('1=0'); } // default conditions if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) { $this->getConditionBuilder()->add('news.isActive = 1'); } if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) { $this->getConditionBuilder()->add('news.isDeleted = 0'); } if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) { if (WCF::getUser()->userID) { $this->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID)); } else { $this->getConditionBuilder()->add('news.isPublished = 1'); } } // apply language filter if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * Creates a new DeletedEntryList object. */ public function __construct() { parent::__construct(); // accessible news categories $accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs)); } else { $this->getConditionBuilder()->add('1=0'); } // load only deleted news $this->getConditionBuilder()->add('news.isDeleted = ?', array(1)); }
/** * Creates a new TaggedNewsList object. * * @param \wcf\data\tag\Tag $tag */ public function __construct(Tag $tag) { ViewableNewsList::__construct(); $this->getConditionBuilder()->add('tag_to_object.objectTypeID = ? AND tag_to_object.languageID = ? AND tag_to_object.tagID = ?', array(TagEngine::getInstance()->getObjectTypeID('de.voolia.news.entry'), $tag->languageID, $tag->tagID)); $this->getConditionBuilder()->add('news.newsID = tag_to_object.objectID'); // accessible news categories $accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array(NewsCategory::getAccessibleCategoryIDs())); } else { $this->getConditionBuilder()->add('1=0'); } }
/** * Gets a specific news entry as viewable news entry. * * @param integer $newsID * @return \wcf\data\news\ViewableNews */ public static function getViewableNews($newsID) { $list = new ViewableNewsList(); $list->enableAttachmentLoading(false); $list->setObjectIDs(array($newsID)); $list->readObjects(); $objects = $list->getObjects(); if (isset($objects[$newsID])) { return $objects[$newsID]; } return null; }