Changeset 5403
- Timestamp:
- 10/07/07 13:12:25 (6 years ago)
- Files:
-
- plugins/sfSimpleForumPlugin/trunk/CHANGELOG (modified) (1 diff)
- plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumPost.php (modified) (1 diff)
- plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumPostPeer.php (modified) (4 diffs)
- plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumTopicPeer.php (modified) (1 diff)
- plugins/sfSimpleForumPlugin/trunk/modules/sfSimpleForum/lib/BasesfSimpleForumActions.class.php (modified) (14 diffs)
- plugins/sfSimpleForumPlugin/trunk/modules/sfSimpleForum/templates/_post.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSimpleForumPlugin/trunk/CHANGELOG
r5357 r5403 1 1 == Trunk == 2 2 3 * francois: Further optimized queries 4 3 5 == 2007-10-03 | 0.6.3 Beta == 4 6 plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumPost.php
r5356 r5403 124 124 } 125 125 126 public function getCreationTimestamp() 127 { 128 return $this->getCreatedAt('U'); 129 } 126 130 } plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumPostPeer.php
r5356 r5403 11 11 { 12 12 13 public static function setIsNewForUser($topics, $user_id) 14 { 15 $topic_ids = array(); 16 $topic_hash = array(); 17 foreach ($topics as $topic) 18 { 19 // A topic is new unless we can find a view from the user for it 20 $topic->setIsNew(true); 21 $id = $topic->getId(); 22 $topic_ids[] = $id; 23 $topic_hash[$id] = $topic; 24 } 25 26 $c = new Criteria(); 27 $c->clearSelectColumns(); 28 $c->addSelectColumn(sfSimpleForumTopicViewPeer::TOPIC_ID); 29 $c->add(sfSimpleForumTopicViewPeer::USER_ID, $user_id); 30 $c->add(sfSimpleForumTopicViewPeer::TOPIC_ID, $topic_ids, Criteria::IN); 31 $rs = sfSimpleForumTopicViewPeer::doSelectRS($c); 32 33 while($rs->next()) 34 { 35 $topic = $topic_hash[$rs->getInt(1)]; 36 $topic->setIsNew(false); 37 } 38 39 return $topic_hash; 40 } 41 13 public static function getOneJoinForum($id) 14 { 15 $c = new Criteria(); 16 $c->add(self::ID, $id); 17 $c->setLimit(1); 18 19 $objects = self::doSelectJoinsfSimpleForumForum($c); 20 21 if ($objects) 22 { 23 return $objects[0]; 24 } 25 return null; 26 } 42 27 public static function getLatestCriteria() 43 28 { … … 65 50 $pager->setPage($page); 66 51 $pager->setCriteria($c); 67 $pager->setPeerMethod('doSelectJoin AllExceptsfGuardUser');52 $pager->setPeerMethod('doSelectJoinsfSimpleForumForum'); 68 53 $pager->init(); 69 54 … … 130 115 $pager->setPage($page); 131 116 $pager->setCriteria($c); 132 $pager->setPeerMethod('doSelectJoin TopicAndForum');117 $pager->setPeerMethod('doSelectJoinsfSimpleForumForum'); 133 118 $pager->init(); 134 119 … … 162 147 $pager->setPage($page); 163 148 $pager->setCriteria($c); 164 $pager->setPeerMethod('doSelectJoin TopicAndForum');149 $pager->setPeerMethod('doSelectJoinsfSimpleForumForum'); 165 150 $pager->init(); 166 151 plugins/sfSimpleForumPlugin/trunk/lib/model/sfSimpleForumTopicPeer.php
r5287 r5403 10 10 class sfSimpleForumTopicPeer extends BasesfSimpleForumTopicPeer 11 11 { 12 public static function setIsNewForUser($topics, $user_id) 13 { 14 $topic_ids = array(); 15 $topic_hash = array(); 16 foreach ($topics as $topic) 17 { 18 // A topic is new unless we can find a view from the user for it 19 $topic->setIsNew(true); 20 $id = $topic->getId(); 21 $topic_ids[] = $id; 22 $topic_hash[$id] = $topic; 23 } 24 25 $c = new Criteria(); 26 $c->clearSelectColumns(); 27 $c->addSelectColumn(sfSimpleForumTopicViewPeer::TOPIC_ID); 28 $c->add(sfSimpleForumTopicViewPeer::USER_ID, $user_id); 29 $c->add(sfSimpleForumTopicViewPeer::TOPIC_ID, $topic_ids, Criteria::IN); 30 $rs = sfSimpleForumTopicViewPeer::doSelectRS($c); 31 32 while($rs->next()) 33 { 34 $topic = $topic_hash[$rs->getInt(1)]; 35 $topic->setIsNew(false); 36 } 37 38 return $topic_hash; 39 } 40 12 41 public static function getLatestCriteria() 13 42 { plugins/sfSimpleForumPlugin/trunk/modules/sfSimpleForum/lib/BasesfSimpleForumActions.class.php
r5356 r5403 60 60 sfConfig::get('app_sfSimpleForumPlugin_feed_max', 10) 61 61 ); 62 $this->rule = 'sfSimpleForum/latestPosts';62 $this->rule = $this->getModuleName().'/latestPosts'; 63 63 $this->feed_title = $this->getFeedTitle(); 64 64 … … 90 90 sfConfig::get('app_sfSimpleForumPlugin_feed_max', 10) 91 91 ); 92 $this->rule = 'sfSimpleForum/latestTopics';92 $this->rule = $this->getModuleName().'/latestTopics'; 93 93 $this->feed_title = $this->getLatestTopicsFeedTitle(); 94 94 … … 119 119 { 120 120 // FIXME: When Propel can do a right join with multiple on conditions, merge this query with the pager's one 121 $this->topics = sfSimpleForum PostPeer::setIsNewForUser($this->topics, $this->getUser()->getGuardUser()->getId());121 $this->topics = sfSimpleForumTopicPeer::setIsNewForUser($this->topics, $this->getUser()->getGuardUser()->getId()); 122 122 } 123 123 } … … 141 141 sfConfig::get('app_sfSimpleForumPlugin_feed_max', 10) 142 142 ); 143 $this->rule = 'sfSimpleForum/forumLatestPosts?forum_name='.$this->name;143 $this->rule = $this->getModuleName().'/forumLatestPosts?forum_name='.$this->name; 144 144 145 145 return $this->renderText($this->getFeedFromObjects($this->posts)); … … 196 196 $this->forward404Unless($this->posts); 197 197 198 $this->rule = 'sfSimpleForum/topic?id='.$this->getRequestParameter('id').'&stripped_title='.$this->getRequestParameter('forum_name');198 $this->rule = $this->getModuleName().'/topic?id='.$this->getRequestParameter('id').'&stripped_title='.$this->getRequestParameter('forum_name'); 199 199 200 200 return $this->renderText($this->getFeedFromObjects($this->posts)); … … 222 222 $position = $post->getPositionInTopic(); 223 223 $page = ceil(($position + 1) / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10)); 224 $this->redirect( 'sfSimpleForum/topic?id='.$topic->getId().'&stripped_title='.$topic->getStrippedTitle().'&page='.$page.'#post'.$post->getId());224 $this->redirect($this->getModuleName().'/topic?id='.$topic->getId().'&stripped_title='.$topic->getStrippedTitle().'&page='.$page.'#post'.$post->getId()); 225 225 } 226 226 … … 248 248 ); 249 249 250 $this->rule = 'sfSimpleForum/userLatestPosts?username='.$this->username;250 $this->rule = $this->getModuleName().'/userLatestPosts?username='.$this->username; 251 251 $this->feed_title = $this->getUserLatestPostsFeedTitle(); 252 252 … … 284 284 sfConfig::get('app_sfSimpleForumPlugin_feed_max', 10) 285 285 ); 286 $this->rule = 'sfSimpleForum/latestUserTopics?username='.$this->username;286 $this->rule = $this->getModuleName().'/latestUserTopics?username='.$this->username; 287 287 $this->feed_title = $this->getUserLatestTopicsFeedTitle(); 288 288 … … 403 403 $position = $post->getPositionInTopic(); 404 404 $page = ceil(($position + 1) / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10)); 405 $this->redirect( 'sfSimpleForum/topic?id='.$post->getTopic()->getId().'&stripped_title='.$post->getTopic()->getStrippedTitle().'&page='.$page.'#post'.$post->getId());405 $this->redirect($this->getModuleName().'/topic?id='.$post->getTopic()->getId().'&stripped_title='.$post->getTopic()->getStrippedTitle().'&page='.$page.'#post'.$post->getId()); 406 406 } 407 407 … … 417 417 $topic->delete(); 418 418 $forum = $post->getsfSimpleForumForum(); 419 $this->redirect( 'sfSimpleForum/forum?forum_name='.$forum->getStrippedName());419 $this->redirect($this->getModuleName().'/forum?forum_name='.$forum->getStrippedName()); 420 420 } 421 421 else … … 423 423 // delete only one message and redirect to the topic 424 424 $post->delete(); 425 $this->redirect( 'sfSimpleForum/topic?id='.$topic->getId().'&stripped_title='.$topic->getStrippedTitle());425 $this->redirect($this->getModuleName().'/topic?id='.$topic->getId().'&stripped_title='.$topic->getStrippedTitle()); 426 426 } 427 427 } … … 435 435 436 436 $forum = $topic->getsfSimpleForumForum(); 437 $this->redirect( 'sfSimpleForum/forum?forum_name='.$forum->getStrippedName());437 $this->redirect($this->getModuleName().'/forum?forum_name='.$forum->getStrippedName()); 438 438 } 439 439 … … 449 449 $topic->save(); 450 450 451 $this->redirect( 'sfSimpleForum/topic?id='.$topic->getId());451 $this->redirect($this->getModuleName().'/topic?id='.$topic->getId()); 452 452 } 453 453 … … 463 463 $topic->save(); 464 464 465 $this->redirect( 'sfSimpleForum/topic?id='.$topic->getId());465 $this->redirect($this->getModuleName().'/topic?id='.$topic->getId()); 466 466 } 467 467 } plugins/sfSimpleForumPlugin/trunk/modules/sfSimpleForum/templates/_post.php
r5312 r5403 13 13 <?php echo link_to($post->getsfSimpleForumForum()->getName(), 'sfSimpleForum/forum?forum_name='.$post->getsfSimpleForumForum()->getStrippedName()) ?> 14 14 » 15 <?php echo link_to($post->get sfSimpleForumTopic()->getTitle(), 'sfSimpleForum/post?id='.$post->getId()) ?>15 <?php echo link_to($post->getTitle(), 'sfSimpleForum/post?id='.$post->getId()) ?> 16 16 <?php endif ?> 17 17 </div>