### Eclipse Workspace Patch 1.0
#P Drupal HEAD (Core)
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.707
diff -u -r1.707 node.module
--- modules/node/node.module	14 Oct 2006 11:09:09 -0000	1.707
+++ modules/node/node.module	17 Oct 2006 02:04:49 -0000
@@ -727,13 +727,9 @@
 /**
  * Generate a page displaying a single node, along with its comments.
  */
-function node_show($node, $cid) {
+function node_show($node) {
   $output = node_view($node, FALSE, TRUE);
 
-  if (function_exists('comment_render') && $node->comment) {
-    $output .= comment_render($node, $cid);
-  }
-
   // Update the history table, stating that this user viewed this node.
   node_tag_new($node->nid);
 
@@ -2303,10 +2299,15 @@
 
 /**
  * Menu callback; view a single node.
+ * 
+ * @param $node   
+ *   The node object to be viewed.
+ * @return
+ *   An HTML representation of the node view page. 
  */
-function node_page_view($node, $cid = NULL) {
+function node_page_view($node) {
   drupal_set_title(check_plain($node->title));
-  return node_show($node, $cid);
+  return node_show($node);
 }
 
 /**
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.490
diff -u -r1.490 comment.module
--- modules/comment/comment.module	11 Oct 2006 13:17:23 -0000	1.490
+++ modules/comment/comment.module	17 Oct 2006 02:04:47 -0000
@@ -144,11 +144,6 @@
           'callback' => 'comment_reply', 'access' => node_access('view', $node), 'type' => MENU_CALLBACK);
       }
     }
-    if ((arg(0) == 'node') && is_numeric(arg(1)) && is_numeric(arg(2))) {
-      $items[] = array('path' => ('node/'. arg(1) .'/'. arg(2)), 'title' => t('view'),
-        'callback' => 'node_page',
-        'type' => MENU_CALLBACK);
-    }
   }
 
   return $items;
@@ -300,7 +295,7 @@
  * Implementation of hook_nodeapi().
  *
  */
-function comment_nodeapi(&$node, $op, $arg = 0) {
+function comment_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   switch ($op) {
     case 'load':
       return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
@@ -340,6 +335,16 @@
       else {
         return array();
       }
+    
+    case 'view':
+      // If node has comments enabled, and $page == TRUE, add comments to body.
+      if ($node->comment && $a4) {
+        $node->content['comments'] = array(
+          '#value' => comment_render($node),
+          '#weight' => 10,
+        );
+      }
+      break;
   }
 }
 
@@ -742,7 +747,7 @@
   return $links;
 }
 
-function comment_render($node, $cid = 0) {
+function comment_render($node) {
   global $user;
 
   $output = '';
@@ -758,175 +763,150 @@
     $order = _comment_get_display_setting('sort');
     $comments_per_page = _comment_get_display_setting('comments_per_page');
 
-    if ($cid) {
-      // Single comment view.
-      $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';
-      $query_args = array($cid);
-      if (!user_access('administer comments')) {
-        $query .= ' AND c.status = %d';
-        $query_args[] = COMMENT_PUBLISHED;
-      }
-      $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.status';
-      $result = db_query($query, $query_args);
-
-      if ($comment = db_fetch_object($result)) {
-        $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
-        $links = module_invoke_all('link', 'comment', $comment, 1);
-
-        foreach (module_implements('link_alter') as $module) {
-          $function = $module .'_link_alter';
-          $function($node, $links);
-        }
-
-        $output .= theme('comment_view', $comment, $links);
+    // Multiple comment view
+    $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
+    $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
+
+    $query_args = array($nid);
+    if (!user_access('administer comments')) {
+      $query .= ' AND c.status = %d';
+      $query_count .= ' AND status = %d';
+      $query_args[] = COMMENT_PUBLISHED;
+    }
+
+    $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread, c.status';
+
+    /*
+    ** We want to use the standard pager, but threads would need every
+    ** comment to build the thread structure, so we need to store some
+    ** extra info.
+    **
+    ** We use a "thread" field to store this extra info. The basic idea
+    ** is to store a value and to order by that value. The "thread" field
+    ** keeps this data in a way which is easy to update and convenient
+    ** to use.
+    **
+    ** A "thread" value starts at "1". If we add a child (A) to this
+    ** comment, we assign it a "thread" = "1.1". A child of (A) will have
+    ** "1.1.1". Next brother of (A) will get "1.2". Next brother of the
+    ** parent of (A) will get "2" and so on.
+    **
+    ** First of all note that the thread field stores the depth of the
+    ** comment: depth 0 will be "X", depth 1 "X.X", depth 2 "X.X.X", etc.
+    **
+    ** Now to get the ordering right, consider this example:
+    **
+    ** 1
+    ** 1.1
+    ** 1.1.1
+    ** 1.2
+    ** 2
+    **
+    ** If we "ORDER BY thread ASC" we get the above result, and this is
+    ** the natural order sorted by time. However, if we "ORDER BY thread
+    ** DESC" we get:
+    **
+    ** 2
+    ** 1.2
+    ** 1.1.1
+    ** 1.1
+    ** 1
+    **
+    ** Clearly, this is not a natural way to see a thread, and users
+    ** will get confused. The natural order to show a thread by time
+    ** desc would be:
+    **
+    ** 2
+    ** 1
+    ** 1.2
+    ** 1.1
+    ** 1.1.1
+    **
+    ** which is what we already did before the standard pager patch. To
+    ** achieve this we simply add a "/" at the end of each "thread" value.
+    ** This way out thread fields will look like depicted below:
+    **
+    ** 1/
+    ** 1.1/
+    ** 1.1.1/
+    ** 1.2/
+    ** 2/
+    **
+    ** we add "/" since this char is, in ASCII, higher than every number,
+    ** so if now we "ORDER BY thread DESC" we get the correct order. Try
+    ** it, it works ;). However this would spoil the "ORDER BY thread ASC"
+    ** Here, we do not need to consider the trailing "/" so we use a
+    ** substring only.
+    */
+
+    if ($order == COMMENT_ORDER_NEWEST_FIRST) {
+      if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
+        $query .= ' ORDER BY c.timestamp DESC';
+      }
+      else {
+        $query .= ' ORDER BY c.thread DESC';
       }
     }
-    else {
-      // Multiple comment view
-      $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
-      $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
-
-      $query_args = array($nid);
-      if (!user_access('administer comments')) {
-        $query .= ' AND c.status = %d';
-        $query_count .= ' AND status = %d';
-        $query_args[] = COMMENT_PUBLISHED;
-      }
-
-      $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread, c.status';
-
-      /*
-      ** We want to use the standard pager, but threads would need every
-      ** comment to build the thread structure, so we need to store some
-      ** extra info.
-      **
-      ** We use a "thread" field to store this extra info. The basic idea
-      ** is to store a value and to order by that value. The "thread" field
-      ** keeps this data in a way which is easy to update and convenient
-      ** to use.
-      **
-      ** A "thread" value starts at "1". If we add a child (A) to this
-      ** comment, we assign it a "thread" = "1.1". A child of (A) will have
-      ** "1.1.1". Next brother of (A) will get "1.2". Next brother of the
-      ** parent of (A) will get "2" and so on.
-      **
-      ** First of all note that the thread field stores the depth of the
-      ** comment: depth 0 will be "X", depth 1 "X.X", depth 2 "X.X.X", etc.
-      **
-      ** Now to get the ordering right, consider this example:
-      **
-      ** 1
-      ** 1.1
-      ** 1.1.1
-      ** 1.2
-      ** 2
-      **
-      ** If we "ORDER BY thread ASC" we get the above result, and this is
-      ** the natural order sorted by time. However, if we "ORDER BY thread
-      ** DESC" we get:
-      **
-      ** 2
-      ** 1.2
-      ** 1.1.1
-      ** 1.1
-      ** 1
-      **
-      ** Clearly, this is not a natural way to see a thread, and users
-      ** will get confused. The natural order to show a thread by time
-      ** desc would be:
-      **
-      ** 2
-      ** 1
-      ** 1.2
-      ** 1.1
-      ** 1.1.1
-      **
-      ** which is what we already did before the standard pager patch. To
-      ** achieve this we simply add a "/" at the end of each "thread" value.
-      ** This way out thread fields will look like depicted below:
-      **
-      ** 1/
-      ** 1.1/
-      ** 1.1.1/
-      ** 1.2/
-      ** 2/
-      **
-      ** we add "/" since this char is, in ASCII, higher than every number,
-      ** so if now we "ORDER BY thread DESC" we get the correct order. Try
-      ** it, it works ;). However this would spoil the "ORDER BY thread ASC"
-      ** Here, we do not need to consider the trailing "/" so we use a
-      ** substring only.
-      */
-
-      if ($order == COMMENT_ORDER_NEWEST_FIRST) {
-        if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $query .= ' ORDER BY c.timestamp DESC';
-        }
-        else {
-          $query .= ' ORDER BY c.thread DESC';
-        }
+    else if ($order == COMMENT_ORDER_OLDEST_FIRST) {
+      if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
+        $query .= ' ORDER BY c.timestamp';
       }
-      else if ($order == COMMENT_ORDER_OLDEST_FIRST) {
-        if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $query .= ' ORDER BY c.timestamp';
-        }
-        else {
+      else {
 
-          /*
-          ** See comment above. Analysis learns that this doesn't cost
-          ** too much. It scales much much better than having the whole
-          ** comment structure.
-          */
+        /*
+        ** See comment above. Analysis learns that this doesn't cost
+        ** too much. It scales much much better than having the whole
+        ** comment structure.
+        */
 
-          $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
-        }
+        $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
       }
+    }
 
-      // Start a form, for use with comment control.
-      $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
-      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
-        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
-      }
-
-      $last_depth = 0;
-      drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css');
-      while ($comment = db_fetch_object($result)) {
-        $comment = drupal_unpack($comment);
-        $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
-        $comment->depth = count(explode('.', $comment->thread)) - 1;
-
-        if ($comment->depth > $last_depth) {
-          $divs++;
-          $output .= '<div class="indented">';
-        }
-        else if ($comment->depth < $last_depth) {
-          $divs--;
-          $output .= '</div>';
-        }
-        $last_depth = $comment->depth;
+    // Start a form, for use with comment control.
+    $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
+    if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+      $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
+    }
 
-        if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
-          $output .= theme('comment_flat_collapsed', $comment);
-        }
-        else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $output .= theme('comment_flat_expanded', $comment);
-        }
-        else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
-          $output .= theme('comment_thread_collapsed', $comment);
-        }
-        else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
-          $output .= theme('comment_thread_expanded', $comment);
-        }
+    $last_depth = 0;
+    drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css');
+    while ($comment = db_fetch_object($result)) {
+      $comment = drupal_unpack($comment);
+      $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
+      $comment->depth = count(explode('.', $comment->thread)) - 1;
+
+      if ($comment->depth > $last_depth) {
+        $divs++;
+        $output .= '<div class="indented">';
       }
-      for ($i = 0; $i < $divs; $i++) {
+      else if ($comment->depth < $last_depth) {
+        $divs--;
         $output .= '</div>';
       }
-      $output .= theme('pager', NULL, $comments_per_page, 0);
+      $last_depth = $comment->depth;
 
-      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
-        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
+      if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
+        $output .= theme('comment_flat_collapsed', $comment);
+      }
+      else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
+        $output .= theme('comment_flat_expanded', $comment);
+      }
+      else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
+        $output .= theme('comment_thread_collapsed', $comment);
+      }
+      else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
+        $output .= theme('comment_thread_expanded', $comment);
       }
     }
+    for ($i = 0; $i < $divs; $i++) {
+      $output .= '</div>';
+    }
+    $output .= theme('pager', NULL, $comments_per_page, 0);
+
+    if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+      $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
+    }
 
     // If enabled, show new comment form.
     if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW)) {
