=== modified file 'includes/form.inc'
--- includes/form.inc	2008-09-21 06:34:41 +0000
+++ includes/form.inc	2008-09-27 06:09:01 +0000
@@ -1166,7 +1166,7 @@ function form_type_image_button_value($f
  */
 function form_type_checkbox_value($form, $edit = FALSE) {
   if ($edit !== FALSE) {
-    return !empty($edit) ? $form['#return_value'] : 0;
+    return empty($edit) && empty($form['#disabled']) ? 0 : $form['#return_value'];
   }
 }
 

=== modified file 'modules/system/system.admin.inc'
--- modules/system/system.admin.inc	2008-09-20 20:22:23 +0000
+++ modules/system/system.admin.inc	2008-09-27 06:09:46 +0000
@@ -624,6 +624,10 @@ function system_modules($form_state = ar
   uasort($files, 'system_sort_modules_by_info_name');
 
   if (!empty($form_state['storage'])) {
+    // If the modules form was submitted, then first system_modules_submit runs
+    // and if there are unfilled dependencies, then form_state['storage'] is
+    // filled, triggering a rebuild. In this case we need to show a confirm
+    // form.
     return system_modules_confirm_form($files, $form_state['storage']);
   }
   $dependencies = array();
@@ -859,7 +863,7 @@ function system_modules_submit($form, &$
   $files = module_rebuild_cache();
 
   // The modules to be enabled.
-  $enabled_modules = array();
+  $modules_to_be_enabled = array();
   // The modules to be disabled.
   $disable_modules = array();
   // The modules to be installed.
@@ -876,28 +880,29 @@ function system_modules_submit($form, &$
       if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
         $new_modules[$name] = $name;
       }
-      else {
-        $enable_modules[$name] = $name;
+      elseif (!module_exists($name)) {
+        $modules_to_be_enabled[$name] = $name;
       }
       // If we're not coming from a confirmation form,
       // search dependencies. Otherwise, the user will have already
       // approved of the depdent modules being enabled.
       if (empty($form_state['storage'])) {
         foreach ($form['modules'][$module['group']][$name]['#dependencies'] as $dependency => $string) {
-          if (!isset($dependencies[$name])) {
-            $dependencies[$name] = array(
-              'name' => $files[$name]->info['name'],
-              'dependencies' => array($dependency => $files[$dependency]->info['name']),
-            );
-          }
-          else {
+          if (!$modules[$dependency]['enabled']) {
+            if (!isset($dependencies[$name])) {
+              $dependencies[$name]['name'] = $files[$name]->info['name'];
+            }
             $dependencies[$name]['dependencies'][$dependency] = $files[$dependency]->info['name'];
           }
           $modules[$dependency] = array('group' => $files[$dependency]->info['package'], 'enabled' => TRUE);
         }
       }
     }
-    else {
+  }
+  // A second loop is necessary, otherwise the modules set to be enabled in the
+  // previous loop would not be found.
+  foreach ($modules as $name => $module) {
+    if (module_exists($name) && !$module['enabled']) {
       $disable_modules[$name] = $name;
     }
   }
@@ -917,7 +922,7 @@ function system_modules_submit($form, &$
             $new_modules[$name] = $name;
           }
           else {
-            $enable_modules[$name] = $name;
+            $modules_to_be_enabled[$name] = $name;
           }
         }
       }
@@ -930,8 +935,8 @@ function system_modules_submit($form, &$
   $old_module_list = module_list();
 
   // Enable the modules needing enabling.
-  if (!empty($enable_modules)) {
-    module_enable($enable_modules);
+  if (!empty($modules_to_be_enabled)) {
+    module_enable($modules_to_be_enabled);
   }
   // Disable the modules that need disabling.
   if (!empty($disable_modules)) {
@@ -2091,7 +2096,11 @@ function theme_system_modules_fieldset($
     $row = array();
     unset($module['enable']['#title']);
     $row[] = array('class' => 'checkbox', 'data' => drupal_render($module['enable']));
-    $row[] = '<label for="' . $module['enable']['#id'] . '"><strong>' . drupal_render($module['name']) . '</strong></label>';
+    $label = '<label';
+    if (isset($module['enable']['#markup'])) {
+      $label .= ' for="' . $module['enable']['#id'] . '"';
+    }
+    $row[] = $label . '><strong>' . drupal_render($module['name']) . '</strong></label>';
     $row[] = drupal_render($module['version']);
     $description = '';
     // If we have help, it becomes the first part

