Ejemplo n.º 1
0
 /**
  * Get previous post
  *
  * @param Post $post
  *
  * @return Post
  */
 public function previousPost(Post $post)
 {
     $query = $this->createQuery();
     $query->matching($query->lessThan('publishDate', $post->getPublishDate()));
     return $query->execute()->getFirst();
 }
Ejemplo n.º 2
0
 /**
  * @param Post $post The post the comment is related to
  *
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 public function findForNotification(Post $post)
 {
     $query = $this->createQuery();
     $query->matching($query->equals('postUid', $post->getUid()));
     return $query->execute();
 }
Ejemplo n.º 3
0
 /**
  * @test
  *
  * @return void
  */
 public function testCanGetLinkParameter()
 {
     $this->fixture->setPublishDate(new \DateTime('2014-01-14'));
     $this->fixture->_setProperty('uid', 123);
     $this->assertEquals($this->fixture->getLinkParameter(), array('post' => '123', 'day' => '14', 'month' => '01', 'year' => '2014'));
 }
Ejemplo n.º 4
0
 /**
  * Finds pending comments by post
  *
  * @param Post $post
  *
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 public function findPendingByPost(Post $post)
 {
     $query = $this->createQuery();
     $query->matching($query->logicalAnd($query->equals('postId', $post->getUid()), $this->getPendingConstraints($query)));
     return $query->execute();
 }
Ejemplo n.º 5
0
 /**
  * Process comment request
  *
  * @param Comment $comment The comment to be deleted
  * @param Post $post The comment to be deleted
  *
  * @return void
  */
 protected function checkSpamPoints(Comment $comment, Post $post)
 {
     $settings = $this->settings['blogsystem']['comments']['spamCheck'];
     $threshold = $settings['threshold'];
     $logData = array('postUid' => $post->getUid(), 'spamPoints' => $comment->getSpamPoints());
     // block comment and redirect user
     if ($threshold['redirect'] > 0 && $comment->getSpamPoints() >= intval($threshold['redirect'])) {
         $this->log->notice('New comment blocked and user redirected because of SPAM.', $logData);
         $this->redirect('', NULL, NULL, $settings['redirect']['arguments'], intval($settings['redirect']['pid']), $statusCode = 403);
     }
     // block comment and show message
     if ($threshold['block'] > 0 && $comment->getSpamPoints() >= intval($threshold['block'])) {
         $this->log->notice('New comment blocked because of SPAM.', $logData);
         $this->addFlashMessageByKey('blockedAsSpam', FlashMessage::ERROR);
         $this->errorAction();
     }
     // mark as spam
     if ($comment->getSpamPoints() >= intval($threshold['markAsSpam'])) {
         $this->log->notice('New comment marked as SPAM.', $logData);
         $comment->markAsSpam();
         $this->addFlashMessageByKey('markedAsSpam', FlashMessage::NOTICE);
     }
 }