/**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     // get user ids
     $userIDs = array();
     foreach ($this->objects as &$response) {
         if (!$this->minResponseTime || $response->time < $this->minResponseTime) {
             $this->minResponseTime = $response->time;
         }
         $userIDs[] = $response->userID;
         $response = new StructuredCommentResponse($response);
         $response->setIsDeletable($this->commentManager->canDeleteResponse($response->getDecoratedObject()));
         $response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject()));
     }
     unset($response);
     // fetch user data and avatars
     if (!empty($userIDs)) {
         $userIDs = array_unique($userIDs);
         $users = UserProfile::getUserProfiles($userIDs);
         foreach ($this->objects as $response) {
             if (isset($users[$response->userID])) {
                 $response->setUserProfile($users[$response->userID]);
             }
         }
     }
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     // fetch response ids
     $responseIDs = $userIDs = array();
     foreach ($this->objects as &$comment) {
         if (!$this->minCommentTime || $comment->time < $this->minCommentTime) {
             $this->minCommentTime = $comment->time;
         }
         $commentResponseIDs = $comment->getResponseIDs();
         foreach ($commentResponseIDs as $responseID) {
             $this->responseIDs[] = $responseID;
             $responseIDs[$responseID] = $comment->commentID;
         }
         if ($comment->userID) {
             $userIDs[] = $comment->userID;
         }
         $comment = new StructuredComment($comment);
         $comment->setIsDeletable($this->commentManager->canDeleteComment($comment->getDecoratedObject()));
         $comment->setIsEditable($this->commentManager->canEditComment($comment->getDecoratedObject()));
     }
     unset($comment);
     // fetch last responses
     if (!empty($responseIDs)) {
         $responseList = new CommentResponseList();
         $responseList->getConditionBuilder()->add("comment_response.responseID IN (?)", array(array_keys($responseIDs)));
         $responseList->readObjects();
         foreach ($responseList as $response) {
             $response = new StructuredCommentResponse($response);
             $response->setIsDeletable($this->commentManager->canDeleteResponse($response->getDecoratedObject()));
             $response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject()));
             $commentID = $responseIDs[$response->responseID];
             $this->objects[$commentID]->addResponse($response);
             if ($response->userID) {
                 $userIDs[] = $response->userID;
             }
         }
     }
     // fetch user data and avatars
     if (!empty($userIDs)) {
         $userIDs = array_unique($userIDs);
         $users = UserProfile::getUserProfiles($userIDs);
         foreach ($this->objects as $comment) {
             if ($comment->userID && isset($users[$comment->userID])) {
                 $comment->setUserProfile($users[$comment->userID]);
             }
             foreach ($comment as $response) {
                 if ($response->userID && isset($users[$response->userID])) {
                     $response->setUserProfile($users[$response->userID]);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Renders a response.
  * 
  * @param	\wcf\data\comment\response\CommentResponse	$response
  * @return	string
  */
 protected function renderResponse(CommentResponse $response)
 {
     $response = new StructuredCommentResponse($response);
     $response->setIsDeletable($this->commentProcessor->canDeleteResponse($response->getDecoratedObject()));
     $response->setIsEditable($this->commentProcessor->canEditResponse($response->getDecoratedObject()));
     // set user profile
     if ($response->userID) {
         $userProfile = UserProfile::getUserProfile($response->userID);
         $response->setUserProfile($userProfile);
     }
     // render response
     WCF::getTPL()->assign(array('responseList' => array($response), 'commentManager' => $this->commentProcessor));
     return WCF::getTPL()->fetch('commentResponseList');
 }