Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.30 diff -u -r1.30 system.admin.inc --- modules/system/system.admin.inc 27 Nov 2007 21:06:28 -0000 1.30 +++ modules/system/system.admin.inc 3 Dec 2007 01:56:26 -0000 @@ -566,6 +566,8 @@ * The form array. */ function system_modules($form_state = array()) { + // For uninstallation checks + include_once './includes/install.inc'; drupal_rebuild_theme_registry(); node_types_rebuild(); menu_rebuild(); @@ -585,6 +587,28 @@ // Create storage for disabled modules as browser will disable checkboxes. $form['disabled_modules'] = array('#type' => 'value', '#value' => array()); + + // Create links for module dashboard + $form['module_menu'] = array('#type' => 'value', '#value' => array()); + + // Retrieve help links that 'help' knows about + $help_menu = module_invoke('help', 'menu'); + $help_links = array(); + if (is_array($help_menu)) { + foreach ($help_menu as $path => $info) { + if (!isset($info['title'])) continue; + $help_links[$info['title']] = $path; + } + } + + // Determine which modules can be uninstalled + $db_result = _system_modules_get_uninstallable_modules(); + $uninstallable_modules = array(); + while ($module = db_fetch_object($db_result)) { + $uninstallable_modules[$module->name] = true; + } + + // Traverse the files, checking for compatibility $incompatible_core = array(); @@ -621,6 +645,21 @@ if ($file->throttle) { $throttle[] = $file->name; } + + $menu = system_get_module_admin_tasks($filename); + if (isset($help_links[$filename])) { + $form['module_menu']['#value'][$filename][] = ''. t('Help') .''; + } + foreach ($menu as $link) { + $form['module_menu']['#value'][$filename][] = $link; + } + // Checking if module was previously enabled mitigates security risk + if (isset($uninstallable_modules[$filename])) { + module_load_install($filename); + if (module_hook($filename, 'uninstall')) { + $form['module_menu']['#value'][$filename][] = ''. t('Uninstall') .''; + } + } $dependencies = array(); // Check for missing dependencies. @@ -716,7 +755,6 @@ '#value' => t('Save configuration'), ); $form['#action'] = url('admin/build/modules/list/confirm'); - return $form; } @@ -936,7 +974,7 @@ $form = array(); // Pull all disabled modules from the system table. - $disabled_modules = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > %d ORDER BY name", SCHEMA_UNINSTALLED); + $disabled_modules = _system_modules_get_uninstallable_modules(); while ($module = db_fetch_object($disabled_modules)) { // Grab the module info @@ -951,6 +989,18 @@ $options[$module->name] = ''; } } + + if (arg(4) == 'confirm' && $module = arg(5)) { + if (isset($form['modules'][$module])) { + $storage['uninstall'][$module] = $module; + if ($confirm_form = system_modules_uninstall_confirm_form($storage)) { + return $confirm_form; + } + } + else { + form_set_error('system_modules_uninstall', 'Cannot uninstall '. $module .'; module either does not exist or is active.'); + } + } // Only build the rest of the form if there are any modules available to uninstall. if (!empty($options)) { @@ -1055,6 +1105,14 @@ } /** + * Returns a list of modules that have been deactivated, and thus + * are eligible for uninstallation. + */ +function _system_modules_get_uninstallable_modules() { + return db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > %d ORDER BY name", SCHEMA_UNINSTALLED); +} + +/** * Form builder; The general site information form. * * @ingroup forms @@ -1931,6 +1989,10 @@ foreach ($modules as $key => $module) { $row = array(); $description = drupal_render($form['description'][$key]); + if (isset($form['module_menu']['#value'][$key])) { + // Add module links + $description .= '
'; + } if (isset($form['status']['#incompatible_modules_core'][$key])) { unset($form['status'][$key]); $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core')); @@ -1963,7 +2025,11 @@ $row[] = drupal_render($form['version'][$key]); $row[] = array('data' => $description, 'class' => 'description'); - $rows[] = $row; + + $extended_row = array('data' => $row); + if (!empty($form['status'][$key]['#value'])) $extended_row['class'] = 'selected'; + + $rows[] = $extended_row; } $fieldset = array( '#title' => t($package), Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.41 diff -u -r1.41 system.css --- modules/system/system.css 20 Nov 2007 10:18:43 -0000 1.41 +++ modules/system/system.css 2 Dec 2007 17:41:54 -0000 @@ -495,6 +495,24 @@ font-weight: bold; } +#system-modules div.menu { + color: #444444; + font-size: 0.9em; +} + +#system-modules tr.selected div.menu, +#system-modules tr.selected div.admin-dependencies, +#system-modules tr.selected div.admin-required { + color: #FFFFFF; +} + +#system-modules tr.selected span.admin-disabled { + color: #FFAAAA; +} +#system-modules tr.selected span.admin-enabled { + color: #AAFFAA; +} + /* ** Styles for the system themes page (admin/build/themes) */