Index: commentrss.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/commentrss/commentrss.info,v
retrieving revision 1.1.2.2.2.1
diff -u -r1.1.2.2.2.1 commentrss.info
--- commentrss.info	28 Apr 2008 22:51:43 -0000	1.1.2.2.2.1
+++ commentrss.info	20 Dec 2010 23:37:13 -0000
@@ -1,5 +1,10 @@
 ; $Id: commentrss.info,v 1.1.2.2.2.1 2008/04/28 22:51:43 goba Exp $
 name = Comment RSS
 description = Provides RSS feeds for comments
-core = 6.x
-dependencies[] = comment
+core = 7.x
+
+files[] = commentrss.admin.inc
+files[] = commentrss.install
+files[] = commentrss.module
+files[] = commentrss.pages.inc
+
Index: commentrss.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/commentrss/commentrss.module,v
retrieving revision 1.12.2.2.2.6.2.10
diff -u -r1.12.2.2.2.6.2.10 commentrss.module
--- commentrss.module	21 Sep 2009 16:50:55 -0000	1.12.2.2.2.6.2.10
+++ commentrss.module	20 Dec 2010 23:37:10 -0000
@@ -40,8 +40,8 @@
   $output = '';
   switch ($path) {
     case 'admin/help#commentrss':
-      $output = '<p>'. t('The commentrss module provides RSS feeds for comments. Comment feeds are published on pages which often also provide a feed of nodes. Some types of comment feeds may be disabled if they are not needed.') .'</p>';
-      $output .= '<p>'. t('If comment feeds are enabled for individual nodes then a "wfw:commentRss" element is added to node feeds (based on <a href="@wfw">the Well Formed Web Comment API</a> specification) so that aggregators may discover the corresponding comment feed.', array('@wfw' => 'http://wellformedweb.org/CommentAPI/')) .'</p>';
+      $output = '<p>' . t('The commentrss module provides RSS feeds for comments. Comment feeds are published on pages which often also provide a feed of nodes. Some types of comment feeds may be disabled if they are not needed.') . '</p>';
+      $output . = '<p>' . t('If comment feeds are enabled for individual nodes then a "wfw:commentRss" element is added to node feeds (based on <a href="@wfw">the Well Formed Web Comment API</a> specification) so that aggregators may discover the corresponding comment feed.', array('@wfw' => 'http://wellformedweb.org/CommentAPI/')) . '</p>';
       break;
   }
   return $output;
@@ -85,7 +85,7 @@
  * Access callback; determines if the user can access a node's comment RSS.
  */
 function commentrss_node_feed_access($node) {
-  return node_access('view', $node) && $node->comment != COMMENT_NODE_DISABLED;
+  return node_access('view', $node) && $node->comment != COMMENT_NODE_CLOSED && $node->comment != COMMENT_NODE_HIDDEN;
 }
 
 /**
@@ -128,7 +128,7 @@
     $node = node_load(arg(1));
     if ($node && variable_get('commentrss_node', TRUE) && commentrss_node_feed_access($node)) {
       drupal_add_feed(
-        url('crss/node/'. $node->nid, array('absolute' => TRUE)),
+        url('crss/node/' . $node->nid, array('absolute' => TRUE)),
         t('Comments for "@title"', array('@title' => $node->title))
       );
     }
@@ -154,13 +154,13 @@
     // Add a wfw:commentRss element to node feed entries if:
     //   node comments are enabled for the node
     //   comment feeds for individual nodes are enabled
-    if ($node->comment != COMMENT_NODE_DISABLED && variable_get('commentrss_node', TRUE)) {
+    if ($node->comment != COMMENT_NODE_HIDDEN && $node->comment != COMMENT_NODE_CLOSED && variable_get('commentrss_node', TRUE)) {
       // The "wfw" namespace is added to each element due to a bug in node_feed().
       // See http://drupal.org/node/157709
       return array(array(
         'key' => 'wfw:commentRss',
         'attributes' => array('xmlns:wfw' => 'http://wellformedweb.org/CommentAPI/'),
-        'value' => url('crss/node/'. $node->nid, array('absolute' => TRUE))));
+        'value' => url('crss/node/' . $node->nid, array('absolute' => TRUE))));
     }
   }
 }
Index: commentrss.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/commentrss/Attic/commentrss.pages.inc,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 commentrss.pages.inc
--- commentrss.pages.inc	21 Sep 2009 16:50:55 -0000	1.1.2.8
+++ commentrss.pages.inc	20 Dec 2010 23:37:11 -0000
@@ -16,8 +16,8 @@
   // different settings, but exposure is not relevant at this point, since
   // we are serving the page, so it is a known URL to the client.
   $default = (in_array($type, array('site', 'node')));
-  if (strlen($type) && variable_get('commentrss_'. $type, $default)) {
-    if (call_user_func('commentrss_feed_'. $type, $value)) {
+  if (strlen($type) && variable_get('commentrss_' . $type, $default)) {
+    if (call_user_func('commentrss_feed_' . $type, $value)) {
       return;
     }
   }
@@ -44,7 +44,7 @@
 function commentrss_feed_node($nid = NULL) {
   global $base_url;
 
-  if (isset($nid) && is_numeric($nid) && ($node = node_load($nid)) && ($node->comment != COMMENT_NODE_DISABLED)) {
+  if (isset($nid) && is_numeric($nid) && ($node = node_load($nid)) && ($node->comment != COMMENT_NODE_HIDDEN) && ($node->comment != COMMENT_NODE_CLOSED)) {
     // Filter with this specific node.
     $items = commentrss_format_items(
       'n.nid',
@@ -63,7 +63,7 @@
         )
       ),
       'description' => t('Comments for "@title"', array('@title' => $node->title)),
-      'link' => url('node/'. $node->nid, array('absolute' => TRUE)),
+      'link' => url('node/' . $node->nid, array('absolute' => TRUE)),
     );
     commentrss_format_feed($items, $channel);
     return TRUE;
@@ -75,7 +75,7 @@
  * Publish a feed for all comments with a specified term.
  */
 function commentrss_feed_term($tid = NULL) {
-  if (isset($tid) && is_numeric($tid) && ($term = taxonomy_get_term($tid))) {
+  if (isset($tid) && is_numeric($tid) && ($term = taxonomy_term_load($tid))) {
     // Filter with specific term ID.
     $items = commentrss_format_items(
       'DISTINCT(n.nid)',
@@ -93,7 +93,7 @@
         )
       ),
       'description' => t('Comments for the category "@term"', array('@term' => $term->name)),
-      'link' => url('taxonomy/term/'. $term->tid, array('absolute' => TRUE)),
+      'link' => url('taxonomy/term/' . $term->tid, array('absolute' => TRUE)),
     );
     commentrss_format_feed($items, $channel);
     return TRUE;
@@ -129,12 +129,12 @@
   $channel = array_merge($channel_defaults, $channel);
   $namespaces = array_merge(array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'), $namespaces);
 
-  $output = '<?xml version="1.0" encoding="utf-8"?>'."\n";
-  $output .= '<rss version="'. $channel['version'] .'" xml:base="'. $base_url .'"'. drupal_attributes($namespaces) .">\n";
+  $output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
+  $output . = '<rss version="' . $channel['version'] . '" xml:base="' . $base_url . '"' . drupal_attributes($namespaces) . ">\n";
   $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
   $output .= "</rss>\n";
 
-  drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
+  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
   print $output;
 }
 
@@ -163,15 +163,47 @@
   $items = '';
 
   // Build SQL query from the passed elements.
-  $sql = 'SELECT '. $nidselector .', c.cid, c.pid, c.subject, c.comment, c.timestamp, c.uid, c.name, c.format, u.name AS username, n.title FROM {node} n '. $joins .' INNER JOIN {comments} c ON c.nid = n.nid INNER JOIN {users} u ON c.uid = u.uid WHERE '. $where .' n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC';
+  $sql = 'SELECT ' . $nidselector . ', c.cid, c.pid, c.subject, c.comment, c.timestamp, c.uid, c.name, c.format, u.name AS username, n.title FROM {node} n ' . $joins . ' INNER JOIN {comments} c ON c.nid = n.nid INNER JOIN {users} u ON c.uid = u.uid WHERE ' . $where . ' n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC';
 
   // Add passed query parameter; plus we are looking for published comments.
   if (!is_array($params)) {
     $params = array($params);
   }
   $params[] = COMMENT_PUBLISHED;
-
+var_dump($nidselector);
   // Use query rewriting for node level access permission support.
+  
+  // Drupal 7 code
+  $query = db_select('node', 'n');
+  $c_alias = $query->join('comment', 'c', 'c.nid = n.nid');
+  $u_alias = $query->join('users', 'u', 'c.uid = u.uid');
+  $query->fields('c', array('cid', 'pid', 'subject', 'comment', 'timestamp', 'uid', 'name', 'format'));
+  $query->fields('n', array($nidselector, 'name', 'title'));
+  
+  /* Drupal 6
+  $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY l.last_comment_timestamp DESC");
+$result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_active', '5'));
+  */
+  
+  /* The same in Drupal 7
+  
+  $query = db_select('node', 'n');
+$tn_alias = $query->join('taxonomy_term_node', 'tn', 'tn.vid = n.vid');
+$td_alias = $query->join('taxonomy_term_data', 'td', 'td.tid = tn.tid');
+$l_alias = $query->join('node_comment_statistics', 'l', 'n.nid = l.nid');
+$query->fields('n', array('nid', 'title'));
+$query
+  ->fields($l_alias, array('comment_count', 'last_comment_timestamp')
+  ->condition("n.status", 1)
+  ->condition("{$td_alias}.vid", variable_get('forum_nav_vocabulary', ''))
+  ->orderBy("{$l_alias}.last_comment_timestamp", 'DESC')
+  ->range(0, variable_get('forum_block_num_active', '5'));
+$query->addTag('node_access');
+$result = $query->execute();
+  
+  
+  */
+  
   $comments = db_query_range(db_rewrite_sql($sql), $params, 0, variable_get('feed_default_items', 10));
   while ($comment = db_fetch_object($comments)) {
     if (!empty($comment->username)) {
@@ -188,7 +220,7 @@
     // Build up item content with node title if required.
     $content = '';
     if ($include_node_title) {
-      $content = '<p>'. t('In reply to <a href="@url">@title</a>', array('@url' => url('node/'. $comment->nid, array('absolute' => TRUE)), '@title' => $comment->title)) .":</p>\n\n";
+      $content = '<p>' . t('In reply to <a href="@url">@title</a>', array('@url' => url('node/' . $comment->nid, array('absolute' => TRUE)), '@title' => $comment->title)) . ":</p>\n\n";
     }
 
     // Format RSS item with input format used on comment. The format
@@ -196,7 +228,7 @@
     // so skip the format validation in check_markup() itself.
     $content .= check_markup($comment->comment, $comment->format, FALSE);
 
-    $link = url('node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid, 'absolute' => TRUE));
+    $link = url('node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid, 'absolute' => TRUE));
     $extra = array(
       array(
         'key' => 'pubDate',

