Ejemplo n.º 1
0
 public function newTopic($forumId, $subject, $text, $prefixId = "", $attachmentIds = array(), $groupId = 0)
 {
     $this->debug("newTopic");
     $forum = $this->forumManager->find($forumId);
     $access = $this->securityContext->isGranted(ForumVoter::CREATE_TOPIC, $forum);
     $success = false;
     $topicId = 0;
     if ($access) {
         if ($forum) {
             $topic = new Topic();
             $topic->setAuthor($this->userManager->getCurrentUser());
             $topic->setName($subject);
             $topic->setForum($forum);
             $post = new Post();
             $post->setName($subject);
             $post->setAuthor($this->userManager->getCurrentUser());
             $post->setText($text);
             $post->setTopic($topic);
             $topic->setMainPost($post);
             $success = $this->topicManager->save($topic);
             $topicId = $topic->getId();
         }
     } else {
         $this->debug("no access");
         $error = "no access";
         $success = false;
     }
     $configList = array('result' => new \Zend\XmlRpc\Value\Boolean($success), 'result_text' => new \Zend\XmlRpc\Value\Base64($error), 'topic_id' => new \Zend\XmlRpc\Value\String($topicId), 'state' => new \Zend\XmlRpc\Value\Integer(0));
     return $this->getResponse($configList, 'struct');
 }
Ejemplo n.º 2
0
 /**
  * @param Request $request
  * @return mixed
  */
 public function createNewsAction(Request $request)
 {
     $entryId = $request->get("id");
     $entry = $this->get('symbb.core.manager.news')->find($entryId);
     if (is_object($entry)) {
         $forum = $entry->getCategory()->getTargetForum();
         if (!$this->get('security.authorization_checker')->isGranted(ForumVoter::CREATE_POST, $forum)) {
             throw $this->createAccessDeniedException();
         }
         $topic = new Topic();
         $topic->setForum($forum);
         $topic->setAuthor($this->getUser());
         $topic->setName($entry->getTitle());
         $entry->setTopic($topic);
         $this->get("doctrine.orm.symbb_entity_manager")->persist($entry);
         $post = new Post();
         $post->setAuthor($this->getUser());
         $post->setText($entry->getText());
         $post->setTopic($topic);
         $post->setName($entry->getTitle());
         $topic->setMainPost($post);
         return $this->handleTopic($request, $topic);
     }
     throw new \ErrorException("News not found!");
 }
Ejemplo n.º 3
0
 /**
  * @param Request $request
  * @return mixed
  */
 public function quotePostAction(Request $request)
 {
     $topicId = $request->get("topic");
     $quoteId = $request->get("quoteId");
     $topic = $this->get('symbb.core.topic.manager')->find($topicId);
     if (is_object($topic)) {
         $quotePost = $this->get('symbb.core.post.manager')->find($quoteId);
         if (!$this->get('security.authorization_checker')->isGranted(ForumVoter::CREATE_POST, $topic->getForum())) {
             throw $this->createAccessDeniedException();
         }
         $post = new Post();
         $post->setAuthor($this->getUser());
         $post->setText("[quote=" . $quotePost->getAuthor()->getUsername() . "]" . $quotePost->getText() . "[/quote]");
         $post->setTopic($topic);
         $post->setName($this->get("translator")->trans("Re:", array(), "symbb_frontend") . " " . $topic->getName());
         return $this->handlePost($request, $post);
     }
     $this->addError("Topic not found!", $request);
     return $this->returnToLastPage($request);
 }
Ejemplo n.º 4
0
 public function setName($value)
 {
     $post = $this->getMainPost();
     if (!is_object($post)) {
         $post = new Post();
         $post->setTopic($this);
     }
     $post->setName($value);
 }