/** * @see \wcf\system\like\IViewableLikeProvider::prepare() */ public function prepare(array $likes) { $entryIDs = array(); foreach ($likes as $like) { $entryIDs[] = $like->objectID; } // fetch entries $entryList = new EntryList(); $entryList->setObjectIDs($entryIDs); $entryList->readObjects(); $entries = $entryList->getObjects(); // set message foreach ($likes as $like) { if (isset($entries[$like->objectID])) { $entry = $entries[$like->objectID]; // check permissions if (!$entry->canRead()) { continue; } $like->setIsAccessible(); // short output $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.like.likeableNews', array('entry' => $entry, 'like' => $like)); $like->setTitle($text); // output $like->setDescription($entry->getExcerpt()); } } }
/** * @see \wcf\system\moderation\queue\IModerationQueueHandler::populate() */ public function populate(array $queues) { $objectIDs = array(); foreach ($queues as $object) { $objectIDs[] = $object->objectID; } // fetch news entries $entryList = new EntryList(); $entryList->setObjectIDs($objectIDs); $entryList->readObjects(); $entry = $entryList->getObjects(); foreach ($queues as $object) { if (isset($entry[$object->objectID])) { $object->setAffectedObject($entry[$object->objectID]); } } }
/** * @see \wcf\system\like\IViewableLikeProvider::prepare() */ public function prepare(array $likes) { if (!WCF::getSession()->getPermission('user.news.canReadEntry')) { return; } $commentLikeObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.like.likeableObject', 'com.woltlab.wcf.comment'); $commentIDs = $responseIDs = array(); foreach ($likes as $like) { if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) { $commentIDs[] = $like->objectID; } else { $responseIDs[] = $like->objectID; } } // fetch response $userIDs = $responses = array(); if (!empty($responseIDs)) { $responseList = new CommentResponseList(); $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array($responseIDs)); $responseList->readObjects(); $responses = $responseList->getObjects(); foreach ($responses as $response) { $commentIDs[] = $response->commentID; if ($response->userID) { $userIDs[] = $response->userID; } } } // fetch comments $commentList = new CommentList(); $commentList->getConditionBuilder()->add("comment.commentID IN (?)", array($commentIDs)); $commentList->readObjects(); $comments = $commentList->getObjects(); // fetch users $users = array(); $entryIDs = array(); foreach ($comments as $comment) { $entryIDs[] = $comment->objectID; if ($comment->userID) { $userIDs[] = $comment->userID; } } if (!empty($userIDs)) { $users = UserProfile::getUserProfiles(array_unique($userIDs)); } $entries = array(); if (!empty($entryIDs)) { $entryList = new EntryList(); $entryList->setObjectIDs($entryIDs); $entryList->readObjects(); $entries = $entryList->getObjects(); } // set message foreach ($likes as $like) { if ($like->objectTypeID == $commentLikeObjectType->objectTypeID) { // comment like if (isset($comments[$like->objectID])) { $comment = $comments[$like->objectID]; if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) { $like->setIsAccessible(); // short output $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment', array('commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like)); $like->setTitle($text); // output $like->setDescription($comment->getExcerpt()); } } } else { // response like if (isset($responses[$like->objectID])) { $response = $responses[$like->objectID]; $comment = $comments[$response->commentID]; if (isset($entries[$comment->objectID]) && $entries[$comment->objectID]->canRead()) { $like->setIsAccessible(); // short output $text = WCF::getLanguage()->getDynamicVariable('wcf.like.title.de.incendium.cms.news.comment.response', array('responseAuthor' => $comment->userID ? $users[$response->userID] : null, 'commentAuthor' => $comment->userID ? $users[$comment->userID] : null, 'entry' => $entries[$comment->objectID], 'like' => $like)); $like->setTitle($text); // output $like->setDescription($response->getExcerpt()); } } } } }