public function executeAddPost() { $topic = sfSimpleForumTopicPeer::retrieveByPK($this->getRequestParameter('topic_id')); $this->forward404Unless($topic); // We must check if the topic isn't locked $this->forward404If($topic->getIsLocked()); $post = new sfSimpleForumPost(); $post->setContent($this->getRequestParameter('body')); $post->setUserId(sfSimpleForumTools::getConnectedUserId()); $post->setTopicId($topic->getId()); $post->save(); $this->redirectToPost($post); }
public function getsfSimpleForumTopic($con = null) { if ($this->asfSimpleForumTopic === null && $this->topic_id !== null) { include_once 'lib/model/om/BasesfSimpleForumTopicPeer.php'; $this->asfSimpleForumTopic = sfSimpleForumTopicPeer::retrieveByPK($this->topic_id, $con); } return $this->asfSimpleForumTopic; }
public function executeAddPost() { $topic = sfSimpleForumTopicPeer::retrieveByPK($this->getRequestParameter('topic_id')); $this->forward404Unless($topic); // We must check if the topic isn't locked $this->forward404If($topic->getIsLocked(), 'Topic is locked, unable to post'); $post = new sfSimpleForumPost(); $post->setContent($this->getRequestParameter('body')); $post->setUserId(sfSimpleForumTools::getConnectedUserId()); $post->setTopicId($topic->getId()); $post->save(); if ($this->getUser()->isAuthenticated()) { $this->getUser()->getProfile()->addKarma(sfConfig::get('app_karma_post_forum_points')); } $this->redirectToPost($post); }