/**
  * Check if $value is valid. If it is not valid, needs to add an error
  * to Result.
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $post
  * @return bool
  */
 protected function isValid($post)
 {
     $result = TRUE;
     if (trim($post->getText()) === '') {
         $this->addError('The post can\'t be empty!.', 1221560718);
         $result = FALSE;
     }
     return $result;
 }
 /**
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $post
  * @param string $countTarget
  * @param string $countUserTarget
  * @param string $title
  * @return string
  */
 public function render(\Mittwald\Typo3Forum\Domain\Model\Forum\Post $post, $countTarget = NULL, $countUserTarget = NULL, $title = '')
 {
     $class = $this->settings['forum']['post']['helpfulBtn']['iconClass'];
     if ($this->hasArgument('class')) {
         $class .= ' ' . $this->arguments['class'];
     }
     if ($post->getAuthor()->getUid() != $this->authenticationService->getUser()->getUid() and !$this->authenticationService->getUser()->isAnonymous()) {
         $class .= ' tx-typo3forum-helpfull-btn';
     }
     if ($post->hasBeenSupportedByUser($this->authenticationService->getUser())) {
         $class .= ' supported';
     }
     $btn = '<div data-toogle="tooltip" title="' . $title . '" data- class="' . $class . '" data-countusertarget="' . $countUserTarget . '" data-counttarget="' . $countTarget . '" data-post="' . $post->getUid() . '" data-pageuid="' . $this->settings['pids']['Forum'] . '" data-eid="' . $this->settings['forum']['post']['helpfulBtn']['eID'] . '"></div>';
     return $btn;
 }
 /**
  *
  * Renders the input text.
  *
  * @param string                             $configuration The configuration path
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $post
  * @param string                             $content       The content to be rendered. If NULL, the node
  *                                                           content will be rendered instead.
  * @return string                The rendered text
  *
  */
 public function render($configuration = 'plugin.tx_typo3forum.settings.textParsing', \Mittwald\Typo3Forum\Domain\Model\Forum\Post $post = NULL, $content = NULL)
 {
     $this->textParserService->setControllerContext($this->controllerContext);
     $this->textParserService->loadConfiguration($configuration);
     if ($post !== NULL) {
         #if(!$post->_getProperty('renderedText')) {
         $renderedText = $this->textParserService->parseText($post->getText());
         #	$post->_setProperty('renderedText', $renderedText);
         #	$this->postRepository->update($post);
         #} else $renderedText = $post->_getProperty('renderedText');
     } else {
         $renderedText = $this->textParserService->parseText($content ? $content : trim($this->renderChildren()));
     }
     return $renderedText;
 }
示例#4
0
 /**
  * Adds a topic.
  *
  * @param Topic $topic
  *
  * @return void
  */
 public function addTopic(Topic $topic)
 {
     if ($this->lastTopic === NULL || $this->lastTopic->getTimestamp() <= $topic->getTimestamp()) {
         $this->setLastTopic($topic);
     }
     $topicLastPost = $topic->getLastPost();
     if ($topicLastPost !== NULL && ($this->lastPost === NULL || $this->lastPost->getTimestamp() <= $topicLastPost->getTimestamp())) {
         $this->setLastPost($topic->getLastPost());
     }
     $this->_increaseTopicCount(+1);
     // topic will increase postCount itself when adding the initial post to it
     $topic->setForum($this);
     $this->topics->attach($topic);
 }
 /**
  * Sets a post as solution
  *
  * @param Post $post The post to be marked as solution.
  *
  * @throws NoAccessException
  */
 public function solutionAction(Post $post)
 {
     if (!$post->getTopic()->checkSolutionAccess($this->authenticationService->getUser())) {
         throw new NoAccessException('Not allowed to set solution by current user.');
     }
     $this->topicFactory->setPostAsSolution($post->getTopic(), $post);
     $this->redirect('show', 'Topic', NULL, array('topic' => $post->getTopic()));
 }
示例#6
0
 /**
  * Gets the topic to which the reported post belongs to.
  * @return \Mittwald\Typo3Forum\Domain\Model\Forum\Topic The topic.
  */
 public function getTopic()
 {
     return $this->post->getTopic();
 }
 /**
  * Updates a post.
  *
  * @param Post $post The post that is to be updated.
  * @param array $attachments File attachments for the post.
  *
  * @return void
  */
 public function updateAction(Post $post, array $attachments = array())
 {
     if ($post->getAuthor() != $this->authenticationService->getUser() || $post->getTopic()->getLastPost()->getAuthor() != $post->getAuthor()) {
         // Assert authorization
         $this->authenticationService->assertModerationAuthorization($post->getTopic()->getForum());
     }
     if (!empty($attachments)) {
         $attachments = $this->attachmentService->initAttachments($attachments);
         foreach ($attachments as $attachment) {
             $post->addAttachments($attachment);
         }
     }
     $this->postRepository->update($post);
     $this->signalSlotDispatcher->dispatch('Mittwald\\Typo3Forum\\Domain\\Model\\Forum\\Post', 'postUpdated', array('post' => $post));
     $this->controllerContext->getFlashMessageQueue()->enqueue(new FlashMessage(Localization::translate('Post_Update_Success')));
     $this->clearCacheForCurrentPage();
     $this->redirect('show', 'Topic', NULL, array('topic' => $post->getTopic()));
 }
示例#8
0
 /**
  *
  * Deletes a post and decreases the user's post count by 1.
  *
  * @param Post $post
  */
 public function deletePost(Post $post)
 {
     $topic = $post->getTopic();
     // If the post is the only one in the topic, delete the whole topic instead of
     // this single post. Empty topics are not allowed.
     if ($topic->getPostCount() === 1) {
         $this->topicFactory->deleteTopic($topic);
     } else {
         $post->getAuthor()->decreasePostCount();
         $post->getAuthor()->decreasePoints((int) $this->settings['rankScore']['newPost']);
         $this->frontendUserRepository->update($post->getAuthor());
         $topic->removePost($post);
         $this->topicRepository->update($topic);
     }
 }
示例#9
0
 /**
  * Sets the last post. This method is not publicy accessible; is is called
  * automatically when a new post is added to this topic.
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $lastPost The last post.
  *
  * @return void
  */
 protected function setLastPost(\Mittwald\Typo3Forum\Domain\Model\Forum\Post $lastPost)
 {
     $this->lastPost = $lastPost;
     $this->lastPostCrdate = $lastPost->getTimestamp();
 }