public function setName($name) { parent::setName($name); $this->setStrippedName(sfSimpleForumTools::stripText($name)); }
public function getUser() { return sfSimpleForumTools::getUser($this); }
public function setTitle($title) { parent::setTitle($title); $this->setStrippedTitle(sfSimpleForumTools::stripText($title)); }
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); } } }
<?php use_helper('I18N'); $author = sfSimpleForumTools::getUserByUsername($author_name); $nb_posts = $author->countsfSimpleForumPosts(); echo link_to(get_partial('sfSimpleForum/author_name', array('author' => $author, 'sf_cache_key' => $author_name)), 'sfSimpleForum/userLatestPosts?username='******'moderator')) { ?> <?php echo __('Moderator', null, 'sfSimpleForum'); ?> <br/> <?php } echo format_number_choice('[1]1 message|(1,+Inf] %1% messages', array('%1%' => $nb_posts), $nb_posts, 'sfSimpleForum'); ?> <br />
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 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); }