コード例 #1
0
 /**
  * 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));
 }
コード例 #2
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);
     }
 }
コード例 #3
0
 /**
  * Creates a new post.
  *
  * @param Topic $topic The topic in which the new post is to be created.
  * @param Post $post The new post.
  * @param array $attachments File attachments for the post.
  *
  * @validate $post \Mittwald\Typo3Forum\Domain\Validator\Forum\PostValidator
  * @validate $attachments \Mittwald\Typo3Forum\Domain\Validator\Forum\AttachmentPlainValidator
  */
 public function createAction(Topic $topic, Post $post, array $attachments = array())
 {
     // Assert authorization
     $this->authenticationService->assertNewPostAuthorization($topic);
     // Create new post, add the new post to the topic and persist the topic.
     $this->postFactory->assignUserToPost($post);
     if (!empty($attachments)) {
         $attachments = $this->attachmentService->initAttachments($attachments);
         $post->setAttachments($attachments);
     }
     $topic->addPost($post);
     $this->topicRepository->update($topic);
     // All potential listeners (Signal-Slot FTW!)
     $this->signalSlotDispatcher->dispatch('Mittwald\\Typo3Forum\\Domain\\Model\\Forum\\Post', 'postCreated', array('post' => $post));
     // Display flash message and redirect to topic->show action.
     $this->controllerContext->getFlashMessageQueue()->enqueue(new FlashMessage(Localization::translate('Post_Create_Success')));
     $this->clearCacheForCurrentPage();
     $redirectArguments = array('topic' => $topic, 'forum' => $topic->getForum());
     $pageNumber = $topic->getPageCount();
     if ($pageNumber > 1) {
         $redirectArguments['@widget_0'] = array('currentPage' => $pageNumber);
     }
     $this->redirect('show', 'Topic', NULL, $redirectArguments);
 }
コード例 #4
0
 /**
  * Sets a post as solution
  *
  * @param Topic $topic
  * @param Post  $post
  */
 public function setPostAsSolution(Topic $topic, Post $post)
 {
     $topic->setSolution($post);
     $this->topicRepository->update($topic);
     $this->forumRepository->update($topic->getForum());
 }