Index: modules/throttle/throttle.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/throttle/throttle.module,v
retrieving revision 1.67
diff -u -F^f -r1.67 throttle.module
--- modules/throttle/throttle.module	31 Aug 2006 20:22:36 -0000	1.67
+++ modules/throttle/throttle.module	14 Sep 2006 21:40:22 -0000
@@ -14,10 +14,26 @@ function throttle_menu($may_cache) {
       'path' => 'admin/settings/throttle',
       'description' => t('Control how your site cuts out content during heavy load.'),
       'title' => t('throttle'),
+      'access' => user_access('administer site configuration'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('throttle_admin_modules'),
+      'type' => MENU_NORMAL_ITEM,
+    );
+    $items[] = array(
+      'path' => 'admin/settings/throttle/modules',
+      'title' => t('modules'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('throttle_admin_modules'),
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_DEFAULT_LOCAL_TASK,
+    );
+    $items[] = array(
+      'path' => 'admin/settings/throttle/settings',
+      'title' => t('settings'),
       'callback' => 'drupal_get_form',
       'callback arguments' => array('throttle_admin_settings'),
       'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
+      'type' => MENU_LOCAL_TASK,
     );
   }
 
@@ -169,3 +185,79 @@ function throttle_admin_settings() {
 
   return system_settings_form($form);
 }
+
+/**
+ * Menu callback; provides throttle enable/disable interface.
+ * 
+ * Only displays enabled modules with checkboxes to enable/disbale throttling.
+ * Required modules has throttling disabled through hidden form fields.
+ */
+function throttle_admin_modules() {
+  // Get current list of modules.
+  $files = module_rebuild_cache();
+
+  $required = array('block', 'filter', 'node', 'system', 'user', 'watchdog', 'throttle');
+  foreach($files as $filname => $file) {
+    if ($file->status && !in_array($file->name, $required) && file_exists($file->filename)) {
+      $form['name'][$file->name] = array('#value' => $file->name);
+      $form['description'][$file->name] = array('#value' => $file->info['description']);
+      $options[$file->name] = '';
+      $form['original'][$file->name] = array(
+        '#type' => 'value', 
+        '#value' => $file->throttle,
+      );
+      $form['original']['#tree'] = TRUE;
+      if ($file->throttle) {
+        $throttle[] = $file->name;
+      }
+    }
+  }
+
+  // Handle status checkboxes, including hidden values for required modules.
+  $form['throttle'] = array('#type' => 'checkboxes', '#default_value' => $throttle, '#options' => $options);
+  foreach ($required as $require) {
+    $form['throttle'][$require] = array('#type' => 'hidden', '#value' => 0);
+  }
+  $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
+
+  return $form;
+}
+
+/**
+ * Theme callback for throttle form.
+ */
+function theme_throttle_admin_modules($form) {
+  foreach (element_children($form['name']) as $key) {
+    $row = array();
+    $row[] = array('data' => drupal_render($form['throttle'][$key]), 'align' => 'center');
+    $row[] = drupal_render($form['name'][$key]);
+    $row[] = drupal_render($form['description'][$key]);
+    $rows[] = $row;
+  }
+
+  $header = array(
+    t('Throttle'),
+    t('Name'), 
+    t('Description'), 
+  );
+
+  $output = theme('table', $header, $rows);
+  $output .= drupal_render($form);
+  return $output;
+}
+
+/**
+ * Submit callback; handles throttle form submission.
+ */
+function throttle_admin_modules_submit($form_id, $edit) {
+  foreach ($edit['throttle'] as $key => $choice) {
+    if ($choice && !$edit['original'][$key]) {
+      db_query("UPDATE {system} SET throttle = 1 WHERE type = 'module' and name = '%s'", $key);
+    }
+    else if (!$choice && $edit['original'][$key]) {
+      db_query("UPDATE {system} SET throttle = 0 WHERE type = 'module' and name = '%s'", $key);
+    }
+  }
+  
+  drupal_set_message(t('The configuration has been saved.'));
+}
\ No newline at end of file
