Esempio n. 1
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!");
 }
Esempio n. 2
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');
 }
Esempio 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);
 }
Esempio n. 4
0
 /**
  * @param Post $post
  * @return bool
  */
 public function save(Post $post)
 {
     $new = false;
     if ($post->getId() <= 0) {
         $new = true;
     }
     $text = Utils::purifyHtml($post->getText());
     $post->setText($text);
     $this->em->persist($post);
     $this->em->flush();
     if ($new) {
         $this->markAsNew($post);
     }
     // if it is a new answer of an existing topic
     if ($post->getTopic()->getId() > 0 && $new) {
         // get all notify flags for this topic
         $flags = $this->topicFlagHandler->findFlagsByObjectAndFlag($post->getTopic(), AbstractFlagHandler::FLAG_NOTIFY);
         foreach ($flags as $flag) {
             // if the notify user is not the author of the new post
             if ($flag->getUser()->getId() !== $post->getAuthor()->getId()) {
                 // send a notify
                 $this->notifyHandler->sendTopicNotifications($post->getTopic(), $flag->getUser());
             }
         }
     }
     return true;
 }