Ejemplo n.º 1
0
 protected function createForTopic(\Symbb\Core\ForumBundle\Entity\Topic $object, $breadcrumb)
 {
     if ($object->getId() > 0) {
         $uri = $this->router->generate('symbb_forum_topic_show', array('id' => $object->getId(), 'name' => $object->getSeoName(), 'page' => 1));
         $breadcrumb[] = array('name' => $object->getName(), 'link' => $uri);
     }
     $forum = $object->getForum();
     $breadcrumb = $this->createForForum($forum, $breadcrumb);
     return $breadcrumb;
 }
Ejemplo n.º 2
0
 /**
  * @param Request $request
  * @param Topic $topic
  * @return mixed
  */
 public function handleTopic(Request $request, Topic $topic)
 {
     $editReason = null;
     if ($topic->getId() > 0) {
         if (!$this->get('security.authorization_checker')->isGranted(TopicVoter::EDIT, $topic)) {
             throw $this->createAccessDeniedException();
         }
         $editReason = $request->get("editReason", "");
     } else {
         if (!$this->get('security.authorization_checker')->isGranted(ForumVoter::CREATE_TOPIC, $topic->getForum())) {
             throw $this->createAccessDeniedException();
         }
     }
     $form = $this->createForm("topic", $topic, array("attr" => array("class" => "css-form form-horizontal")));
     $oldText = $topic->getMainPost()->getText();
     $form->handleRequest($request);
     if ($form->isValid()) {
         // insert edit history
         if ($editReason !== null) {
             $history = new Post\History();
             $history->setPost($topic->getMainPost());
             $history->setChanged(new \DateTime());
             $history->setEditor($this->getUser());
             $history->setOldText($oldText);
             $history->setReason($editReason);
             $topic->getMainPost()->addHistory($history);
         }
         $event = new TopicFormSaveEvent($topic, $request, $form);
         $this->get("event_dispatcher")->dispatch('symbb.core.forum.form.topic.before.save', $event);
         $this->get("symbb.core.topic.manager")->save($topic);
         $this->get("event_dispatcher")->dispatch('symbb.core.forum.form.topic.after.save', $event);
         if ($form->get("mainPost")->get("notifyMe")->getData()) {
             $this->get("symbb.core.topic.manager")->subscribeNotification($topic);
         } else {
             $this->get("symbb.core.topic.manager")->unsubscribeNotification($topic);
         }
         $this->get('symbb.core.post.flag')->insertFlags($topic->getMainPost(), PostFlagHandler::FLAG_NEW);
         return $this->redirect($this->generateUrl('symbb_forum_topic_show', array("id" => $topic->getId(), "name" => $topic->getSeoName(), "page" => 1)));
     }
     return $this->render($this->getTemplateBundleName('forum') . ':Forum:topicEdit.html.twig', array("topic" => $topic, "form" => $form->createView()));
 }
Ejemplo n.º 3
0
 /**
  *
  * @param int $topicId
  * @return array(<\Symbb\Core\ForumBundle\Entity\Post>)
  */
 public function findByTopic(Topic $topic, $limit = null, $pageNumber = 1)
 {
     $qb = $this->em->getRepository('SymbbCoreForumBundle:Post')->createQueryBuilder('p');
     $qb->select("p");
     $qb->where("p.topic = :topic ");
     $qb->orderBy("p.created", "ASC");
     $query = $qb->getQuery();
     $query->setParameter('topic', $topic->getId());
     $paginator = $this->paginator;
     $pagination = $paginator->paginate($query, $pageNumber, $limit);
     return $pagination;
 }
Ejemplo n.º 4
0
 public function getBreadcrumbData(\Symbb\Core\ForumBundle\Entity\Topic $object, ForumManager $forumManager)
 {
     $breadcrumb = array();
     $forum = $object->getForum();
     if (\is_object($forum) && $forum->getId() > 0) {
         $breadcrumb = $forumManager->getBreadcrumbData($forum);
         $breadcrumb[] = array('type' => 'topic', 'name' => $object->getName(), 'seoName' => $object->getSeoName(), 'id' => $object->getId());
     }
     return $breadcrumb;
 }