/** * @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; }
/** * 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())); }
/** * * 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); } }