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'); }
/** * @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!"); }
/** * @param Topic $topic * @param Forum $forum * @return bool */ public function move(Topic $topic, Forum $forum) { $topic->setForum($forum); $this->em->persist($topic); $this->em->flush(); return true; }