Index: modules/comment/comment.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v retrieving revision 1.23 diff -u -p -r1.23 comment.admin.inc --- modules/comment/comment.admin.inc 6 Jun 2009 10:27:42 -0000 1.23 +++ modules/comment/comment.admin.inc 6 Jun 2009 13:02:41 -0000 @@ -71,6 +71,7 @@ function comment_admin_overview($type = $query->join('node', 'n', 'n.nid = c.nid'); $query->addField('u', 'name', 'registered_name'); $query->addField('n', 'title', 'node_title'); + $query->addField('n', 'type', 'node_type'); $result = $query ->fields('c', array('subject', 'nid', 'cid', 'comment', 'timestamp', 'status', 'name', 'homepage')) ->fields('u', array('uid')) @@ -85,8 +86,10 @@ function comment_admin_overview($type = $destination = drupal_get_destination(); foreach ($result as $comment) { + $node = (object) array('type' => $comment->node_type); + $page = comment_get_display_page($comment->cid, $node); $options[$comment->cid] = array( - 'subject' => l($comment->subject, 'node/' . $comment->nid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid)), + 'subject' => l($comment->subject, 'node/' . $comment->nid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'query' => array('page' => $page), 'fragment' => 'comment-' . $comment->cid)), 'author' => theme('username', $comment), 'posted_in' => l($comment->node_title, 'node/' . $comment->nid), 'time' => format_date($comment->timestamp, 'small'), Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.719 diff -u -p -r1.719 comment.module --- modules/comment/comment.module 3 Jun 2009 06:52:29 -0000 1.719 +++ modules/comment/comment.module 6 Jun 2009 13:02:42 -0000 @@ -1348,6 +1348,52 @@ function comment_num_new($nid, $timestam } /** + * Get the display ordinal for a comment, starting from 0. + * + * @param $cid + * The comment ID. + * @return + * The display ordinal for the comment. + */ +function comment_get_display_ordinal($cid, $node) { + // Count how many comments (c) are before $cid (d) in display order. This is + // the 0-based display ordinal. + $query = db_select('comment', 'c'); + $query->innerJoin('comment', 'd', 'd.nid = c.nid'); + $query->addExpression('COUNT(*)', 'count'); + $query->condition('d.cid', $cid); + if (!user_access('administer comments')) { + $query->condition('c.status', COMMENT_PUBLISHED); + } + $mode = _comment_get_display_setting('mode', $node); + + if ($mode == COMMENT_MODE_FLAT_EXPANDED || $mode == COMMENT_MODE_FLAT_COLLAPSED) { + $query->condition('c.cid', 'd.cid', '<'); + } + else { + $query->addExpression('SUBSTRING(c.thread, 1, (LENGTH(c.thread) -1)) < SUBSTRING(d.thread, 1, (LENGTH(d.thread) -1))'); + } + + return $query->execute()->fetchField(); +} + +/** + * Return the page number for a comment. + * + * @param $cid + * The comment ID. + * @param $node + * The node the comment is attached to. + * @return + * The page number. + */ +function comment_get_display_page($cid, $node) { + $ordinal = comment_get_display_ordinal($cid, $node); + $comments_per_page = _comment_get_display_setting('comments_per_page', $node); + return floor($ordinal/$comments_per_page); +} + +/** * Validate comment data. * * @param $edit