? comment_rss_og_support.patch
Index: commentrss.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/commentrss/commentrss.module,v
retrieving revision 1.12.2.2.4.4
diff -u -p -b -r1.12.2.2.4.4 commentrss.module
--- commentrss.module	8 May 2008 10:28:01 -0000	1.12.2.2.4.4
+++ commentrss.module	6 Oct 2008 20:44:59 -0000
@@ -97,6 +97,16 @@ function commentrss_menu($may_cache) {
         'type' => MENU_CALLBACK
       );
     }
+    if (variable_get('commentrss_og', FALSE)) {
+      // Callback for og RSS handling.
+      $items[] = array(
+        'path' => 'crss/og',
+        'title' => '',
+        'callback' => 'commentrss_feed_og',
+        'access' => user_access('access comments'),
+        'type' => MENU_CALLBACK
+      );
+    }
 
     // Expose site feed based on settings.
     switch (variable_get('commentrss_site', COMMENTRSS_SITE_FRONT_PAGE)) {
@@ -144,6 +154,17 @@ function commentrss_menu($may_cache) {
       );
     }
     
+    // Expose og feed on group pages.
+    if (module_exists('og') && (arg(0) == 'node') && is_numeric($nid = arg(1)) && is_null(arg(2)) &&
+        variable_get('commentrss_og', FALSE) && ($group = node_load($nid))) {
+      if (og_is_group_type($group->type)) {
+
+        drupal_add_feed(
+          url('crss/og/'. $group->nid),
+          t('Comments for group "@title"', array('@title' => $group->title))
+        );
+      }
+    }
   }
   return $items;
 }
@@ -198,6 +219,14 @@ function commentrss_admin_settings() {
     '#description' => t('Feeds will be accessible at @url type of URLs. Only supports one term, no composition.', array('@url' => url('crss/term/...', NULL, NULL, TRUE))),
     '#default_value' => variable_get('commentrss_term', FALSE),
   );
+  if (module_exists('og')) {
+    $form['commentrss_og'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Enable individual comment feeds for each organic group (og) on the website'),
+      '#description' => t('Feeds will be accessible at @url type of URLs. Only supports one group, no composition.', array('@url' => url('crss/og/...', NULL, NULL, TRUE))),
+      '#default_value' => variable_get('commentrss_og', FALSE),
+    );
+  }
 
   return system_settings_form($form);
 }
@@ -236,8 +265,8 @@ function commentrss_feed_node($nid = NUL
       'title' => t(
         '@site - Comments for "@title"',
         array(
-          '@site' => check_plain(variable_get('site_name', 'Drupal')),
-          '@title' => check_plain($node->title)
+          '@site' => variable_get('site_name', 'Drupal'),
+          '@title' => $node->title
         )
       ),
       'description' => t('Comments for "@title"', array('@title' => $node->title)),
@@ -266,8 +295,8 @@ function commentrss_feed_term($tid = NUL
       'title' => t(
         '@site - Comments for "@term"',
         array(
-          '@site' => check_plain(variable_get('site_name', 'Drupal')),
-          '@term' => check_plain($term->name)
+          '@site' => variable_get('site_name', 'Drupal'),
+          '@term' => $term->name
         )
       ),
       'description' => t('Comments for the category "@term"', array('@term' => $term->name)),
@@ -279,6 +308,36 @@ function commentrss_feed_term($tid = NUL
   drupal_not_found();
 }
 
+/**
+ * Publish a feed for all comments from a specified organic group (og).
+ */
+function commentrss_feed_og($gid = NULL) {
+  if (module_exists('og') && isset($gid) && is_numeric($gid) && ($group = node_load($gid))) {
+    // Filter with specific term ID.
+    $items = commentrss_format_items(
+      'DISTINCT(n.nid)',
+      'INNER JOIN {og_ancestry} oa ON n.nid = oa.nid',
+      'oa.group_nid = %d AND',
+      $group->nid
+    );
+    // Fill channel information based on group details.
+    $channel = array(
+      'title' => t(
+        '@site - Comments for "@group"',
+        array(
+          '@site' => variable_get('site_name', 'Drupal'),
+          '@term' => $group->title
+        )
+      ),
+      'description' => t('Comments for the group "@group"', array('@group' => $group->title)),
+      'link' => url('node/'. $group->nid, NULL, NULL, TRUE),
+    );
+    commentrss_format_feed($items, $channel);
+    return NULL;
+  }
+  drupal_not_found();
+}
+
 // == API functions ============================================================
 
 /**
