Exemplo n.º 1
0
 public function canShowCategory(Category $category, Forum $forum = null)
 {
     if ($forum) {
         if ($category->getForum()) {
             if ($category->getForum()->getId() != $forum->getId()) {
                 return false;
             }
         }
         if (!$this->canShowForum($forum)) {
             return false;
         }
     }
     if (!$category->isAuthorisedToRead($this->securityContext)) {
         return false;
     }
     return true;
 }
 /**
  *
  * @access public
  * @return \Symfony\Component\Form\Form
  */
 public function getForm()
 {
     if (null == $this->form) {
         // Store the old board before proceeding, as we will need it to update its stats
         // as it will be a topic down in its count at least, posts perhaps even more so.
         $this->oldBoard = $this->topic->getBoard();
         // Boards are pre-filtered for proper rights managements, moderators may move Topics,
         // but some boards may only be accessible by admins, so moderators should not see them.
         $filteredBoards = $this->boardModel->findAllBoardsForForumById($this->forum->getId());
         $options = array('boards' => $filteredBoards);
         $this->dispatcher->dispatch(ForumEvents::MODERATOR_TOPIC_CHANGE_BOARD_INITIALISE, new ModeratorTopicEvent($this->request, $this->topic));
         $this->form = $this->factory->create($this->formTopicChangeBoardType, $this->topic, $options);
     }
     return $this->form;
 }
 /**
  *
  * @access public
  * @return \Symfony\Component\Form\Form
  */
 public function getForm()
 {
     if (null == $this->form) {
         if (!is_object($this->board) || !$this->board instanceof Board) {
             throw new \Exception('Board must be specified to be create a Topic in TopicCreateFormHandler');
         }
         $filteredBoards = $this->boardModel->findAllBoardsForForumById($this->forum->getId());
         $topicOptions = array('boards' => $filteredBoards, 'auto_initialize' => false);
         $topic = $this->topicModel->createTopic();
         $topic->setBoard($this->board);
         $post = $this->postModel->createPost();
         $post->setTopic($topic);
         $post->setCreatedBy($this->user);
         $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_INITIALISE, new UserTopicEvent($this->request, $post->getTopic()));
         $this->form = $this->factory->create($this->formPostType, $post);
         $this->form->add($this->factory->create($this->formTopicType, $topic, $topicOptions));
     }
     return $this->form;
 }
Exemplo n.º 4
0
 /**
  *
  * @access public
  * @param  \Map2u\ForumBundle\Entity\Forum                        $forum
  * @return \Map2u\ForumBundle\Component\Crumbs\Factory\CrumbTrail
  */
 public function addUserCategoryIndex(Forum $forum = null)
 {
     return $this->createCrumbTrail()->add($forum ? $forum->getName() == 'default' ? 'Index' : $forum->getName() . ' Index' : 'Index', array('route' => 'ccdn_forum_user_category_index', 'params' => array('forumName' => $forum ? $forum->getName() : 'default')));
 }
 /**
  *
  * @access protected
  * @param \Map2u\ForumBundle\Entity\Forum $forum
  */
 protected function onSuccess(Forum $forum)
 {
     $this->dispatcher->dispatch(ForumEvents::ADMIN_FORUM_DELETE_SUCCESS, new AdminForumEvent($this->request, $forum));
     if (!$this->form->get('confirm_subordinates')->getData()) {
         $categories = new ArrayCollection($forum->getCategories()->toArray());
         $this->forumModel->reassignCategoriesToForum($categories, null)->flush();
     }
     $this->forumModel->deleteForum($forum);
     $this->dispatcher->dispatch(ForumEvents::ADMIN_FORUM_DELETE_COMPLETE, new AdminForumEvent($this->request, $forum));
 }