Index: commentrss.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/commentrss/commentrss.module,v
retrieving revision 1.12
diff -u -r1.12 commentrss.module
--- commentrss.module	18 Dec 2006 11:42:56 -0000	1.12
+++ commentrss.module	6 Jul 2007 07:15:22 -0000
@@ -1,49 +1,76 @@
 <?php
 // $Id: commentrss.module,v 1.12 2006/12/18 11:42:56 goba Exp $
 
-function commentrss_help($section = "admin/modules#description") {
-  if ($section == "admin/modules#description") {
-    return t('Provides RSS feeds for comments');
-  }
-}
+function commentrss_help($section) {
+  $output = '';
+  switch ($section) {
+    case 'admin/modules#description':
+      $output = t('Provides RSS feeds for comments');
+      break;
+    case 'admin/content/commentrss':
+      $output = '<p>' . t('Select the types of comment feeds to be enabled.') . '</p>';
+      break;
+   }
+  return $output;
+ }
 
 function commentrss_menu($may_cache) {
+  $items = array();
   if ($may_cache) {
+    $items[] = array(
+      'path' => 'admin/content/commentrss',
+      'title' => t('Comment RSS publishing'),
+      'description' => t('Configure RSS feeds for comments.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'commentrss_admin_settings',
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_NORMAL_ITEM);
     $items[] = array('path' => 'crss', 'title' => '',
       'callback' => 'commentrss_handler',
       'access' => user_access('access content'),
       'type' => MENU_CALLBACK);
   }
   else {
-    drupal_add_link(array('rel' => 'alternate',
-                          'type' => 'application/rss+xml',
-                          'title' => t('All comments'),
-                          'href' => url('crss', NULL, NULL, TRUE)));
+    if (variable_get('commentrss_site', TRUE)) {
+      drupal_add_link(array('rel' => 'alternate',
+                            'type' => 'application/rss+xml',
+                            'title' => t('All comments'),
+                            'href' => url('crss', NULL, NULL, TRUE)));
+    }
     if (arg(0) == 'taxonomy' && arg(1) == 'vocabulary') {
       // vocabulary_list module is serving this page - http://drupal.org/project/vocabulary_list
-      drupal_add_link(array('rel' => 'alternate',
-                          'type' => 'application/rss+xml',
-                          'title' => t('Comments on this vocabulary'),
-                          'href' => url('crss/vocab/'. arg(2), NULL, NULL, TRUE)));
+      //don't break the elseif!
+      if (variable_get('commentrss_vocab', TRUE)) {
+        drupal_add_link(array('rel' => 'alternate',
+                            'type' => 'application/rss+xml',
+                            'title' => t('Comments on this vocabulary'),
+                            'href' => url('crss/vocab/'. arg(2), NULL, NULL, TRUE)));
+      }
     }
     elseif (arg(0) == 'taxonomy' && arg(1) == 'term') {
-      drupal_add_link(array('rel' => 'alternate',
-                          'type' => 'application/rss+xml',
-                          'title' => t('Comments on this taxonomy term'),
-                          'href' => url('crss/term/'. arg(2), NULL, NULL, TRUE)));
+      if (variable_get('commentrss_term', TRUE)) {
+        drupal_add_link(array('rel' => 'alternate',
+                            'type' => 'application/rss+xml',
+                            'title' => t('Comments on this taxonomy term'),
+                            'href' => url('crss/term/'. arg(2), NULL, NULL, TRUE)));
+      }
     }
-    elseif (arg(0) == 'node' && is_numeric(arg(1))) {
+    elseif (arg(0) == 'node' && is_numeric(arg(1)) && variable_get('commentrss_node', TRUE)) {
       $node = node_load(arg(1));
       if ($node->nid) {
         $typename = node_get_types('name', $node);
-        drupal_add_link(array('rel' => 'alternate',
-                              'type' => 'application/rss+xml',
-                              'title' => t('Comments for @title', array('@title' => $node->title)),
-                              'href' => url('crss/node/'. arg(1), NULL, NULL, TRUE)));
-        drupal_add_link(array('rel' => 'alternate',
-                              'type' => 'application/rss+xml',
-                              'title' => t('Comments for all @type content', array('@type' => $typename)),
-                              'href' => url('crss/nodetype/'. $node->type, NULL, NULL, TRUE)));
+        if (variable_get('commentrss_node', TRUE)) {
+          drupal_add_link(array('rel' => 'alternate',
+                                'type' => 'application/rss+xml',
+                                'title' => t('Comments for @title', array('@title' => $node->title)),
+                                'href' => url('crss/node/'. arg(1), NULL, NULL, TRUE)));
+        }
+        if (variable_get('commentrss_type', TRUE)) {
+          drupal_add_link(array('rel' => 'alternate',
+                                'type' => 'application/rss+xml',
+                                'title' => t('Comments for all @type content', array('@type' => $typename)),
+                                'href' => url('crss/nodetype/'. $node->type, NULL, NULL, TRUE)));
+        }
       }
     }
   }
@@ -51,14 +78,14 @@
 }
 
 function commentrss_handler($type = NULL) {
-  if ($type) {
+  if ($type && variable_get('commentrss_'.$type, TRUE)) {
     if (in_array($type, array('node', 'term', 'vocab', 'nodetype'))) {
       if (call_user_func('commentrss_feed_' . $type)) {
         return;
       }
     }
   }
-  else {
+  elseif (variable_get('commentrss_site', TRUE)) {
     if (commentrss_feed_site()) {
       return;
     }
@@ -257,3 +284,28 @@
   }
   return $items;
 }
+
+/**
+ * Menu callback; displays the commentrss module settings page.
+ */
+function commentrss_admin_settings() {
+  $form['commentrss_site'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for entire site'),
+    '#default_value' => variable_get('commentrss_site', TRUE));
+  $form['commentrss_type'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for particular node types'),
+    '#default_value' => variable_get('commentrss_type', TRUE));
+  $form['commentrss_node'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for individual nodes'),
+    '#default_value' => variable_get('commentrss_node', TRUE));
+  $form['commentrss_term'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for a term'),
+    '#default_value' => variable_get('commentrss_term', TRUE));
+  if (module_exists('vocabulary_list')) {
+    $form['commentrss_vocab'] = array('#type' => 'checkbox',
+      '#title' => t('Node comments for a vocabulary'),
+      '#default_value' => variable_get('commentrss_vocab', TRUE));
+  }
+
+  return system_settings_form($form);
+}