Ejemplo n.º 1
0
 /**
  * Checks if a new comment could be created
  *
  * @param Post $post The post the comment is related to
  *
  * @return void
  */
 protected function checkIfCommentIsAllowed(Post $post)
 {
     $settings = $this->settings['blogsystem']['comments'];
     if (!$settings['allowed'] || $post->getAllowComments() === 1) {
         $this->addFlashMessageByKey('notAllowed', FlashMessage::ERROR);
         $this->errorAction();
     }
     if ($post->getAllowComments() === 2 && empty(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->loginUser)) {
         $this->addFlashMessageByKey('notLoggedIn', FlashMessage::ERROR);
         $this->errorAction();
     }
     if ($settings['allowedUntil']) {
         if ($post->isExpired(trim($settings['allowedUntil']))) {
             $this->addFlashMessageByKey('commentsClosed', FlashMessage::ERROR);
             $this->errorAction();
         }
     }
 }