Beispiel #1
0
 /**
  *
  * @access public
  * @param  \Map2u\ForumBundle\Entity\Post              $post
  * @return \Map2u\ForumBundle\Manager\ManagerInterface
  */
 public function savePost(Post $post)
 {
     $this->postLockHelper->setLockLimitOnPost($post);
     $this->gateway->savePost($post);
     // refresh the user so that we have an PostId to work with.
     $this->refresh($post);
     return $this;
 }
Beispiel #2
0
 public function canEditPost(Post $post, Forum $forum = null)
 {
     if (!$this->securityContext->isGranted('ROLE_USER')) {
         return false;
     }
     if (!$this->canShowPost($post, $forum) && !$this->securityContext->isGranted('ROLE_ADMIN')) {
         return false;
     }
     if ($this->postLockHelper->isLocked($post)) {
         if (!$this->securityContext->isGranted('ROLE_MODERATOR')) {
             return false;
         }
     }
     if (!$this->securityContext->isGranted('ROLE_ADMIN')) {
         if (!$post->getCreatedBy()) {
             return false;
         } else {
             if ($post->getCreatedBy()->getId() != $this->securityContext->getToken()->getUser()->getId()) {
                 return false;
             }
         }
     }
     return true;
 }