[pLog-svn] r4735 - plog/branches/lifetype-1.1.6/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Feb 14 03:57:54 EST 2007


Author: oscar
Date: 2007-02-14 03:57:54 -0500 (Wed, 14 Feb 2007)
New Revision: 4735

Modified:
   plog/branches/lifetype-1.1.6/class/dao/commentscommon.class.php
Log:
Fix backported from LT 1.2.

Modified: plog/branches/lifetype-1.1.6/class/dao/commentscommon.class.php
===================================================================
--- plog/branches/lifetype-1.1.6/class/dao/commentscommon.class.php	2007-02-14 08:56:17 UTC (rev 4734)
+++ plog/branches/lifetype-1.1.6/class/dao/commentscommon.class.php	2007-02-14 08:57:54 UTC (rev 4735)
@@ -101,56 +101,39 @@
 		 * @return False if error or an array of ArticleComments objects
 		 */
 		function getPostComments( $artid, 
-		                          $order = COMMENT_ORDER_NEWEST_FIRST, 
-		                          $status = COMMENT_STATUS_ALL, 
-		                          $type = COMMENT_TYPE_ANY, 
-		                          $page = -1, 
-		                          $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+								  $order = COMMENT_ORDER_NEWEST_FIRST, 
+								  $status = COMMENT_STATUS_ALL, 
+								  $type = COMMENT_TYPE_ANY, 
+								  $page = -1, 
+								  $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
 		{
-			if( $order == COMMENT_ORDER_NEWEST_FIRST ){
-				$order = Array( "date" => "DESC" );
-                $cache_item = CACHE_ARTICLE_COMMENTS_BYARTICLE_NEWEST_TO_OLDEST;
-            }
-			else{
-				$order = Array( "date" => "ASC" );
-                $cache_item = CACHE_ARTICLE_COMMENTS_BYARTICLE_OLDEST_TO_NEWEST;
-            }
-		
-			$comments = $this->getMany( "article_id",
-			                            $artid,
-                                        $cache_item,
-			                            Array(),
-			                            $order,
-										"",
-			                            $page,
-			                            $itemsPerPage );			                           
-			                            
-			$result = Array();
-		
-			if( $comments ) {
-				// load the post to get the blog in order to get the time difference
-				$articles = new Articles();
-				$article = $articles->getArticle( $artid );
-				$blog = $article->getBlogInfo();
-				$blogSettings = $blog->getSettings();
-				$timeDiff = $blogSettings->getValue( "time_offset" );
-				include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-				foreach( $comments as $comment ) {
-					if( $this->check( $comment, $type, $status )) {
-						// WARNING (oscar 20070101)
-						// This isn't necessary as CommentsCommon::mapRow() is already applying the offset...
-						// otherwise what we're getting here is the same offset applied twice!
-						//$date = Timestamp::getDateWithOffset( $comment->getDate(), $timeDiff );
-						//$comment->setDate( $date );
-						$result[] = $comment;
-					}
-				}
-			}
+			$query = "SELECT * FROM ".$this->getPrefix()."articles_comments ".
+			         "WHERE article_id = '".Db::qstr( $artid )."'";
+
+			if( $status != COMMENT_STATUS_ALL )
+				 $query .= "AND status = '".Db::qstr( $status )."'";
+
+			if( $type != COMMENT_TYPE_ANY )
+				$query .= " AND type = '".Db::qstr( $type )."'";				
+
+			if( $order == COMMENT_ORDER_NEWEST_FIRST )
+				$query .= " ORDER BY date DESC";
 			else
-				$result = Array();
-				
-				
-			return( $result );			               
+				$query .=" ORDER BY date ASC";
+
+			$result = $this->Execute( $query, $page, $itemsPerPage );
+
+			if( !$result )
+				return( Array());
+
+			$results = Array();
+
+			while( $row = $result->FetchRow()) {
+				$results[] = $this->mapRow( $row );
+			}
+
+
+			return( $results );						   
 		}
 		
 		/**



More information about the pLog-svn mailing list