Index: system.js =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.js,v retrieving revision 1.5 diff -u -r1.5 system.js --- system.js 14 May 2007 16:22:26 -0000 1.5 +++ system.js 20 May 2007 03:56:32 -0000 @@ -78,3 +78,54 @@ // Trigger the event handler to show the form input if necessary. $("select.date-format").trigger("change"); } + +Drupal.moduleDependenciesAttach = function () { + $('#system-modules input[@type=checkbox]') + .click(function () { + Drupal.moduleDependencies(this); + }); +} + +Drupal.moduleDependencies = function (elt) { + var dependencies = Drupal.settings.moduleDependencies.dependencies.[elt.value]; + var missing = Drupal.settings.moduleDependencies.missing; + if (dependencies && dependencies.length) { + for (i in dependencies) { + // Don't make changes to missing modules. + if (missing[dependencies[i]) { + continue; + } + // Iterate through this module's dependencies. + $('#edit-status-' + dependencies[i].replace('_', '-')).each(function () { + // If this module has just been enabled, also enable the module it's dependent on. + if (elt.checked) { + $(this) + .attr('checked', 'checked') + .attr('disabled', 'disabled'); + } + } + // If this module has just been disabled, also enable the checkbox for modules it's + // dependent on if this was the only enabled dependency. + else { + if ($(this).attr('disabled')) { + var disabled = false; + var dependents = Drupal.settings.moduleDependencies.dependents[dependencies[i]]; + if (dependents && dependents.length) { + for (j in dependents) { + if ($('#edit-status-' + dependents[j].replace('_', '-')).attr('checked')) { + disabled = true; + break; + } + } + if (disabled == false) { + $('#edit-status-' + dependencies[i].replace('_', '-')).attr('disabled', false); + } + } + } + } + // Process each dependency. + Drupal.moduleDependencies(this); + }); + } + } +} \ No newline at end of file Index: system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.478 diff -u -r1.478 system.module --- system.module 17 May 2007 07:28:42 -0000 1.478 +++ system.module 20 May 2007 03:50:42 -0000 @@ -1468,6 +1468,12 @@ // Array for disabling checkboxes in callback system_module_disable. $disabled = array(); + // Array of dependencies for passing to js. + $dependencies_js = array(); + // Array of dependents for passing to js. + $dependents_js = array(); + // Array of missing for passing to js. + $missing_js = array(); $throttle = array(); // Traverse the files retrieved and build the form. foreach ($files as $filename => $file) { @@ -1485,12 +1491,14 @@ $dependencies = array(); // Check for missing dependencies. if (is_array($file->info['dependencies'])) { + $dependencies_js[$file->name] = $file->info['dependencies']; foreach ($file->info['dependencies'] as $dependency) { if (!isset($files[$dependency]) || !$files[$dependency]->status) { if (isset($files[$dependency])) { $dependencies[] = $files[$dependency]->info['name'] . t(' (disabled)'); } else { + $missing_js[$dependency] = TRUE; $dependencies[] = drupal_ucfirst($dependency) . t(' (missing)'); $disabled[] = $filename; $form['disabled_modules']['#value'][$filename] = FALSE; @@ -1514,6 +1522,7 @@ // Mark dependents disabled so user can not remove modules being depended on. $dependents = array(); foreach ($file->info['dependents'] as $dependent) { + $dependents_js[$file->name] = $file->info['dependents']; if ($files[$dependent]->status == 1) { $dependents[] = $files[$dependent]->info['name'] . t(' (enabled)'); $disabled[] = $filename; @@ -1534,6 +1543,17 @@ } } + // Pass dependency data to the browser. + drupal_add_js(array('moduleDependencies' => array('dependencies' => $dependencies_js, 'dependents' => $dependents_js, 'missing' => $missing_js)), 'setting'); + drupal_add_js(drupal_get_path('module', 'system') .'/system.js'); + drupal_add_js(' +// Global Killswitch +if (Drupal.jsEnabled) { + $(document).ready(function() { + Drupal.moduleDependenciesAttach(); + }); +}', 'inline'); + $modules_required = drupal_required_modules(); // Merge in required modules. foreach ($modules_required as $required) {