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	7 Jul 2007 22:07:25 -0000
@@ -1,32 +1,50 @@
 <?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 (arg(0) == 'taxonomy' && arg(1) == 'vocabulary') {
+    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' && variable_get('commentrss_vocab', FALSE)) {
       // 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)));
     }
-    elseif (arg(0) == 'taxonomy' && arg(1) == 'term') {
+    elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && variable_get('commentrss_term', FALSE)) {
       drupal_add_link(array('rel' => 'alternate',
                           'type' => 'application/rss+xml',
                           'title' => t('Comments on this taxonomy term'),
@@ -36,14 +54,18 @@
       $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_nodetype', FALSE)) {
+          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 +73,14 @@
 }
 
 function commentrss_handler($type = NULL) {
-  if ($type) {
+  if ($type && variable_get('commentrss_'.$type, FALSE)) {
     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 +279,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', FALSE));
+  $form['commentrss_node'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for individual nodes'),
+    '#default_value' => variable_get('commentrss_node', FALSE));
+  $form['commentrss_nodetype'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for a node type'),
+    '#default_value' => variable_get('commentrss_nodetype', FALSE));
+  $form['commentrss_term'] = array('#type' => 'checkbox',
+    '#title' => t('Node comments for a term'),
+    '#default_value' => variable_get('commentrss_term', FALSE));
+  if (module_exists('vocabulary_list')) {
+    $form['commentrss_vocab'] = array('#type' => 'checkbox',
+      '#title' => t('Node comments for a vocabulary'),
+      '#default_value' => variable_get('commentrss_vocab', FALSE));
+  }
+
+  return system_settings_form($form);
+}
