예제 #1
0
 /**
  * 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()));
 }
 /**
  * Updates a forum with special super-moderator-powers!
  *
  * @param Topic $topic The topic that is be edited.
  * @param boolean $moveTopic TRUE, if the topic is to be moved to another forum.
  * @param Forum $moveTopicTarget The forum to which the topic is to be moved.
  */
 public function updateTopicAction(Topic $topic, $moveTopic = FALSE, Forum $moveTopicTarget = NULL)
 {
     $this->authenticationService->assertModerationAuthorization($topic->getForum());
     $this->topicRepository->update($topic);
     if ($moveTopic) {
         $this->topicFactory->moveTopic($topic, $moveTopicTarget);
     }
     $this->controllerContext->getFlashMessageQueue()->enqueue(new FlashMessage(Localization::translate('Moderation_UpdateTopic_Success', 'Typo3Forum')));
     $this->clearCacheForCurrentPage();
     $this->redirect('show', 'Topic', NULL, array('topic' => $topic));
 }
예제 #3
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);
     }
 }