Esempio n. 1
0
 /**
  * @param $object
  * @param $flag
  * @param UserInterface $user
  * @param bool $flushEm
  */
 public function insertFlag($object, $flag, UserInterface $user = null, $flushEm = true)
 {
     $ignore = false;
     // if we add a post "new" flag, we need to check if the user has read access to the forum
     // an we must check if the user has ignore the forum
     if ($flag === AbstractFlagHandler::FLAG_NEW) {
         $access = $this->securityContext->isGranted(ForumVoter::VIEW, $object->getTopic()->getForum(), $user);
         if ($access) {
             $ignore = $this->forumFlagHandler->checkFlag($object->getTopic()->getForum(), 'ignore', $user);
         } else {
             $ignore = true;
         }
     }
     if (!$ignore) {
         parent::insertFlag($object, $flag, $user, $flushEm);
         if ($flag === AbstractFlagHandler::FLAG_NEW) {
             // insert to topic (parent)
             parent::insertFlag($object->getTopic(), $flag, $user, $flushEm);
             // insert to all parents ( recrusivly )
             $parent = $object->getTopic()->getForum();
             do {
                 if (is_object($parent)) {
                     parent::insertFlag($parent, $flag, $user, $flushEm);
                 } else {
                     break;
                 }
             } while ($parent = $parent->getParent());
         }
     }
 }
Esempio n. 2
0
 public function checkForFlag(\Symbb\Core\ForumBundle\Entity\Forum $element, $flag)
 {
     return $this->flagHandler->checkFlag($element, $flag);
 }
Esempio n. 3
0
 /**
  * @param Forum $forum
  * @param $flag
  * @param UserInterface $user
  * @return bool
  */
 public function hasFlag(Forum $forum, $flag, UserInterface $user = null)
 {
     return $this->forumFlagHandler->checkFlag($forum, $flag, $user = null);
 }