Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/Attic/comment.module,v retrieving revision 1.455.2.7 diff -u -p -r1.455.2.7 comment.module --- modules/comment.module 18 Jul 2006 10:46:24 -0000 1.455.2.7 +++ modules/comment.module 5 Aug 2006 01:14:50 -0000 @@ -171,7 +171,15 @@ function comment_block($op = 'list', $de } function theme_comment_block() { - $result = db_query_range(db_rewrite_sql('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC', 'c'), COMMENT_PUBLISHED, 0, 10); + $result1 = db_query_range(db_rewrite_sql("SELECT n.nid from {node_comment_statistics} n WHERE n.comment_count > 0 ORDER BY n.last_comment_timestamp DESC"),0, 10); + + $recent_nids = array(); + + while ($cnode = db_fetch_object($result1)) { + $recent_nids[] = $cnode->nid; + } + + $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('.implode(',',$recent_nids).') AND n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC',COMMENT_PUBLISHED,0,10); $items = array(); while ($comment = db_fetch_object($result)) { $items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'
'. t('%time ago', array('%time' => format_interval(time() - $comment->timestamp)));