コード例 #1
0
 public function getsfSimpleForumTopicsJoinsfGuardUser($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BasesfSimpleForumTopicPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collsfSimpleForumTopics === null) {
         if ($this->isNew()) {
             $this->collsfSimpleForumTopics = array();
         } else {
             $criteria->add(sfSimpleForumTopicPeer::LATEST_POST_ID, $this->getId());
             $this->collsfSimpleForumTopics = sfSimpleForumTopicPeer::doSelectJoinsfGuardUser($criteria, $con);
         }
     } else {
         $criteria->add(sfSimpleForumTopicPeer::LATEST_POST_ID, $this->getId());
         if (!isset($this->lastsfSimpleForumTopicCriteria) || !$this->lastsfSimpleForumTopicCriteria->equals($criteria)) {
             $this->collsfSimpleForumTopics = sfSimpleForumTopicPeer::doSelectJoinsfGuardUser($criteria, $con);
         }
     }
     $this->lastsfSimpleForumTopicCriteria = $criteria;
     return $this->collsfSimpleForumTopics;
 }
コード例 #2
0
$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');
コード例 #3
0
 public function getTopics($max = 10)
 {
     $c = $this->getTopicsCriteria();
     $c->setLimit($max);
     return sfSimpleForumTopicPeer::doSelect($c);
 }
コード例 #4
0
    slot('forum_navigation');
    ?>
  <?php 
    echo forum_breadcrumb(array(array(sfConfig::get('app_sfSimpleForumPlugin_forum_name', 'Forums'), 'forums/forumList'), $title));
    ?>
  
<?php 
    end_slot();
}
?>

<div class="sfSimpleForum">
  
  <h1><?php 
echo $title;
?>
</h1>
  
  <?php 
include_partial('forums/figures', array('display_topic_link' => true, 'nb_topics' => sfSimpleForumTopicPeer::countForUser($user->getUserId()), 'topic_rule' => 'forums/userLatestTopics?username='******'&project=' . $project->getSlug(), 'display_post_link' => false, 'nb_posts' => $post_pager->getNbResults(), 'post_rule' => '', 'feed_rule' => 'forums/userLatestPostsFeed?username='******'feed_title' => $feed_title));
?>
  
  <?php 
include_partial('forums/post_list', array('posts' => $post_pager->getResults(), 'include_topic' => true, 'project' => $project));
?>
  
  <?php 
echo pager_navigation($post_pager, 'forums/userLatestPosts?username='******'&project=' . $project->getSlug());
?>

</div>
コード例 #5
0
 public static function doSelectJoinAllExceptsfGuardUser(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BasesfSimpleForumTopicViewPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BasesfSimpleForumTopicViewPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     sfSimpleForumTopicViewPeer::addSelectColumns($c);
     $startcol2 = sfSimpleForumTopicViewPeer::NUM_COLUMNS - sfSimpleForumTopicViewPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     sfSimpleForumTopicPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + sfSimpleForumTopicPeer::NUM_COLUMNS;
     $c->addJoin(sfSimpleForumTopicViewPeer::TOPIC_ID, sfSimpleForumTopicPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = sfSimpleForumTopicViewPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = sfSimpleForumTopicPeer::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->getsfSimpleForumTopic();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addsfSimpleForumTopicView($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initsfSimpleForumTopicViews();
             $obj2->addsfSimpleForumTopicView($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = sfSimpleForumTopicPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTitle($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setIsSticked($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setIsLocked($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setForumId($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->setLatestPostId($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setUserId($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setStrippedTitle($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setNbPosts($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setNbViews($arr[$keys[11]]);
     }
 }
コード例 #8
0
 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(sfSimpleForumTopicPeer::ID, $pks, Criteria::IN);
         $objs = sfSimpleForumTopicPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public function executeToggleLock()
 {
     $topic = sfSimpleForumTopicPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($topic);
     $topic->setIsLocked(!$topic->getIsLocked());
     $topic->leaveUpdatedAtUnchanged();
     $topic->save();
     $this->redirect($this->getModuleName() . '/topic?id=' . $topic->getId());
 }
コード例 #10
0
 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;
 }