public function getFora()
 {
     $c = new Criteria();
     $c->add(sfSimpleForumForumPeer::CATEGORY_ID, $this->getId());
     $c->addAscendingOrderByColumn(sfSimpleForumForumPeer::RANK);
     return sfSimpleForumForumPeer::doSelect($c);
 }
    echo input_tag('title', '', 'id=topic_title');
    ?>
    <?php 
    if (isset($forum)) {
        ?>
      <?php 
        echo input_hidden_tag('forum_name', $forum->getStrippedName());
        ?>
    <?php 
    } else {
        ?>
      <?php 
        echo label_for('forum', __('Forum', null, 'sfSimpleForum'));
        ?>
      <?php 
        echo select_tag('forum_name', options_for_select(sfSimpleForumForumPeer::getAllAsArray()));
        ?>
    <?php 
    }
    ?>
    
  <?php 
}
?>
  
  <?php 
echo form_error('body');
?>
  <?php 
echo label_for('body', __('Body', null, 'sfSimpleForum'));
?>
 public function getsfSimpleForumForumsJoinsfSimpleForumCategory($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BasesfSimpleForumForumPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collsfSimpleForumForums === null) {
         if ($this->isNew()) {
             $this->collsfSimpleForumForums = array();
         } else {
             $criteria->add(sfSimpleForumForumPeer::LATEST_POST_ID, $this->getId());
             $this->collsfSimpleForumForums = sfSimpleForumForumPeer::doSelectJoinsfSimpleForumCategory($criteria, $con);
         }
     } else {
         $criteria->add(sfSimpleForumForumPeer::LATEST_POST_ID, $this->getId());
         if (!isset($this->lastsfSimpleForumForumCriteria) || !$this->lastsfSimpleForumForumCriteria->equals($criteria)) {
             $this->collsfSimpleForumForums = sfSimpleForumForumPeer::doSelectJoinsfSimpleForumCategory($criteria, $con);
         }
     }
     $this->lastsfSimpleForumForumCriteria = $criteria;
     return $this->collsfSimpleForumForums;
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(sfSimpleForumForumPeer::ID, $pks, Criteria::IN);
         $objs = sfSimpleForumForumPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
$t->is($forum->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a message doesn\'t change the forum\'s last update date');
$t->is($forum->getLatestPost()->getId(), $msg3->getId(), 'Updating a message doesn\'t change the forum\'s last reply');
$t->diag('Updating the topic');
sleep(1);
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$topic->setTitle('this is another test');
$topic->save();
$t->is($topic->getNbPosts(), 3, 'Updating a topic doesn\'t change the topic number of replies');
$t->isnt($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a topic changes the topic\'s latest update date');
$t->is($topic->getLatestPost()->getId(), $msg3->getId(), 'Updating a topic doesn\'t change the topic\'s latest reply');
$forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId());
$t->is($forum->getLatestPost()->getCreatedAt('U'), $msg3->getCreatedAt('U'), 'Updating the topic doesn\'t change the forum\'s last update date');
$t->is($forum->getLatestPost()->getAuthorName(), $user3->getUsername(), 'Updating the topic doesn\'t change the forum\'s last reply author name');
$t->diag('Deleting a message from the end');
$msg3->delete();
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$t->is($topic->getNbPosts(), 2, 'Deleting a message decrements the topic number of replies');
$t->is($topic->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message changes the topic\'s latest update date to the latest message creation date');
$t->is($topic->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message changes the topic\'s latest reply');
$forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId());
$t->is($forum->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message changes the forums\'s latest update date to the latest message creation date');
$t->is($forum->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message changes the forums\'s latest reply');
$t->diag('Deleting a message from the middle');
$msg1->delete();
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$t->is($topic->getNbPosts(), 1, 'Deleting a message decrements the topic number of replies');
$t->is($topic->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message from the middle doesn\'t change the topic\'s latest update date');
$t->is($topic->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message from the middle doesn\'t change the topic\'s latest reply');
$forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId());
$t->is($forum->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Deleting a message from the middle doesn\'t change the forum\'s latest update date');
$t->is($forum->getLatestPost()->getId(), $msg2->getId(), 'Deleting a message from the middle doesn\'t change the forum\'s latest reply');
 /**
  * Selects a collection of sfSimpleForumPost objects pre-filled with related topic and forum objects.
  *
  * @return     array Array of sfSimpleForumPost objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *             rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinTopicAndForum(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BasesfSimpleForumPostPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BasesfSimpleForumPostPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     sfSimpleForumPostPeer::addSelectColumns($c);
     $startcol2 = sfSimpleForumPostPeer::NUM_COLUMNS - sfSimpleForumPostPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     sfSimpleForumTopicPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + sfSimpleForumTopicPeer::NUM_COLUMNS;
     sfSimpleForumForumPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + sfSimpleForumForumPeer::NUM_COLUMNS;
     $c->addJoin(sfSimpleForumPostPeer::TOPIC_ID, sfSimpleForumTopicPeer::ID);
     $c->addJoin(sfSimpleForumPostPeer::FORUM_ID, sfSimpleForumForumPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $post = new sfSimpleForumPost();
         $post->hydrate($rs);
         $topic = new sfSimpleForumTopic();
         $topic->hydrate($rs, $startcol2);
         $newObject = true;
         foreach ($results as $temp_post) {
             $existing_topic = $temp_post->getsfSimpleForumTopic();
             if ($existing_topic->getPrimaryKey() === $topic->getPrimaryKey()) {
                 $newObject = false;
                 $existing_topic->addsfSimpleForumPost($post);
                 break;
             }
         }
         if ($newObject) {
             $topic->initsfSimpleForumPosts();
             $topic->addsfSimpleForumPost($post);
         }
         $forum = new sfSimpleForumForum();
         $forum->hydrate($rs, $startcol3);
         $newObject = true;
         foreach ($results as $temp_post) {
             $existing_forum = $temp_post->getsfSimpleForumForum();
             if ($existing_forum->getPrimaryKey() === $forum->getPrimaryKey()) {
                 $newObject = false;
                 $existing_forum->addsfSimpleForumPost($post);
                 break;
             }
         }
         if ($newObject) {
             $forum->initsfSimpleForumPosts();
             $forum->addsfSimpleForumPost($post);
         }
         $results[] = $post;
     }
     return $results;
 }
 public static function doSelectJoinCategoryLeftJoinPost(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BasesfSimpleForumForumPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BasesfSimpleForumForumPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     sfSimpleForumForumPeer::addSelectColumns($c);
     $startcol2 = sfSimpleForumForumPeer::NUM_COLUMNS - sfSimpleForumForumPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     sfSimpleForumCategoryPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + sfSimpleForumCategoryPeer::NUM_COLUMNS;
     sfSimpleForumPostPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + sfSimpleForumPostPeer::NUM_COLUMNS;
     $c->addJoin(sfSimpleForumForumPeer::CATEGORY_ID, sfSimpleForumCategoryPeer::ID);
     $c->addJoin(sfSimpleForumForumPeer::LATEST_POST_ID, sfSimpleForumPostPeer::ID, Criteria::LEFT_JOIN);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = sfSimpleForumForumPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = sfSimpleForumCategoryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getsfSimpleForumCategory();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addsfSimpleForumForum($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initsfSimpleForumForums();
             $obj2->addsfSimpleForumForum($obj1);
         }
         $omClass = sfSimpleForumPostPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj3 = new $cls();
         $obj3->hydrate($rs, $startcol3);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj3 = $temp_obj1->getsfSimpleForumPost();
             if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj3->addsfSimpleForumForum($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj3->initsfSimpleForumForums();
             $obj3->addsfSimpleForumForum($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = sfSimpleForumForumPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setRank($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCategoryId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setCreatedAt($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setUpdatedAt($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setStrippedName($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setLatestPostId($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setNbPosts($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setNbTopics($arr[$keys[10]]);
     }
 }
 public function getsfSimpleForumForum($con = null)
 {
     if ($this->asfSimpleForumForum === null && $this->forum_id !== null) {
         include_once 'lib/model/om/BasesfSimpleForumForumPeer.php';
         $this->asfSimpleForumForum = sfSimpleForumForumPeer::retrieveByPK($this->forum_id, $con);
     }
     return $this->asfSimpleForumForum;
 }
 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);
 }