Ejemplo n.º 1
0
 public function addsfSimpleForumPost(sfSimpleForumPost $l)
 {
     $this->collsfSimpleForumPosts[] = $l;
     $l->setsfSimpleForumTopic($this);
 }
 public function executeCreateTopic($request)
 {
     $this->form = new forumTopic();
     if ($request->hasParameter('forum_name')) {
         $this->forum = Doctrine::getTable('sfSimpleForumForum')->retrieveBySlug($request->getParameter('forum_name'));
         $this->forward404Unless($this->forum, 'Forum not found !');
         $this->form->setDefaults(array('forum_id' => $this->forum->get('id')));
     } elseif (!$request->isMethod('post')) {
         // we don't allow new topic outside forum
         $this->forward404();
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('forum_topic'));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $topic = new sfSimpleForumTopic();
             $topic->set('forum_id', $values['forum_id']);
             $topic->setTitle($values['title']);
             $topic->setUserId(sfSimpleForumTools::getConnectedUserId($this->getUser()));
             if ($this->getUser()->hasCredential('moderator')) {
                 $topic->setIsSticked($values['is_sticked'] ? 1 : 0);
                 $topic->setIsLocked($values['is_locked'] ? 1 : 0);
             }
             $topic->save();
             $post = new sfSimpleForumPost();
             $post->setContent($values['content']);
             $post->setTitle($values['title']);
             $post->setUserId(sfSimpleForumTools::getConnectedUserId($this->getUser()));
             $post->setsfSimpleForumTopic($topic);
             $post->setForumId($topic->get('sfSimpleForumForum')->get('id'));
             $post->save();
             $this->redirectToPost($post);
         }
     }
 }
 public function executeAddTopic()
 {
     $forum = sfSimpleForumForumPeer::retrieveByStrippedName($this->getRequestParameter('forum_name'));
     $this->forward404Unless($forum);
     $topic = new sfSimpleForumTopic();
     $topic->setsfSimpleForumForum($forum);
     $topic->setTitle($this->getRequestParameter('title'));
     $topic->setUserId(sfSimpleForumTools::getConnectedUserId());
     if ($this->getUser()->hasCredential('moderator')) {
         $topic->setIsSticked($this->getRequestParameter('is_sticked', 0));
         $topic->setIsLocked($this->getRequestParameter('is_locked', 0));
     }
     $topic->save();
     $post = new sfSimpleForumPost();
     $post->setContent($this->getRequestParameter('body'));
     $post->setUserId(sfSimpleForumTools::getConnectedUserId());
     $post->setsfSimpleForumTopic($topic);
     $post->save();
     $this->redirectToPost($post);
 }