コード例 #1
0
ファイル: FrontendController.php プロジェクト: symbb/symbb
 /**
  * @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!");
 }
コード例 #2
0
ファイル: TopicManager.php プロジェクト: symbb/symbb
 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');
 }
コード例 #3
0
ファイル: FrontendController.php プロジェクト: symbb/symbb
 /**
  * @param Request $request
  * @return mixed
  */
 public function createTopicAction(Request $request)
 {
     $forumId = $request->get("forum");
     $forum = $this->get('symbb.core.forum.manager')->find($forumId);
     if (!$this->get('security.authorization_checker')->isGranted(ForumVoter::CREATE_TOPIC, $forum) || $forum->getId() <= 0) {
         throw $this->createAccessDeniedException();
     }
     $topic = new Topic();
     $post = new Post();
     $post->setAuthor($this->getUser());
     $topic->setAuthor($this->getUser());
     $post->setTopic($topic);
     $topic->setForum($forum);
     $topic->setMainPost($post);
     return $this->handleTopic($request, $topic);
 }