/**
  * @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\system\menu\user\profile\content\IUserProfileMenuContent::getContent()
  */
 public function getContent($userID)
 {
     if ($this->commentManager === null) {
         $this->objectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment');
         $objectType = CommentHandler::getInstance()->getObjectType($this->objectTypeID);
         $this->commentManager = $objectType->getProcessor();
     }
     $commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->objectTypeID, $userID);
     // assign variables
     WCF::getTPL()->assign(array('commentCanAdd' => $this->commentManager->canAdd($userID), 'commentList' => $commentList, 'commentObjectTypeID' => $this->objectTypeID, 'userID' => $userID, 'lastCommentTime' => $commentList->getMinCommentTime(), 'likeData' => MODULE_LIKE ? $commentList->getLikeData() : array()));
     return WCF::getTPL()->fetch('userProfileCommentList');
 }
 /**
  * @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]);
                 }
             }
         }
     }
 }
 /**
  * Validates parameters to load responses for a given comment id.
  */
 public function validateLoadResponses()
 {
     $this->readInteger('commentID', false, 'data');
     $this->readInteger('lastResponseTime', false, 'data');
     $this->readBoolean('loadAllResponses', true, 'data');
     $this->comment = new Comment($this->parameters['data']['commentID']);
     if (!$this->comment->commentID) {
         throw new UserInputException('commentID');
     }
     $this->commentManager = ObjectTypeCache::getInstance()->getObjectType($this->comment->objectTypeID)->getProcessor();
     if (!$this->commentManager->isAccessible($this->comment->objectID)) {
         throw new PermissionDeniedException();
     }
 }
Пример #5
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');
 }