diff -urp ./modules/system/admin.css ../drupal-HEAD/modules/system/admin.css --- ./modules/system/admin.css 2009-05-21 11:58:35.000000000 +1200 +++ ../drupal-HEAD/modules/system/admin.css 2009-05-21 17:35:34.000000000 +1200 @@ -51,6 +51,9 @@ div.admin-requirements, div.admin-requir font-size: 0.9em; color: #444; } +div.admin-theme-name-conflict { + color: #800; +} span.admin-disabled { color: #800; } diff -urp ./modules/system/system.admin.inc ../drupal-HEAD/modules/system/system.admin.inc --- ./modules/system/system.admin.inc 2009-05-21 11:58:35.000000000 +1200 +++ ../drupal-HEAD/modules/system/system.admin.inc 2009-05-21 17:36:16.000000000 +1200 @@ -148,6 +148,8 @@ function system_themes_form() { $incompatible_core = array(); $incompatible_php = array(); + $enabled_modules = system_enabled_modules(); + $name_conflict_modules = array(); foreach ($themes as $theme) { $screenshot = NULL; $theme_key = $theme->name; @@ -186,6 +188,10 @@ function system_themes_form() { $incompatible_php[$theme->name] = $theme->info['php']; } } + + if (in_array($theme->name, $enabled_modules)) { + $name_conflict_modules[$theme->name] = 0; + } } $form['status'] = array( @@ -194,6 +200,7 @@ function system_themes_form() { '#default_value' => $status, '#incompatible_themes_core' => drupal_map_assoc($incompatible_core), '#incompatible_themes_php' => $incompatible_php, + '#name_conflict_modules' => $name_conflict_modules ); $form['theme_default'] = array( '#type' => 'radios', @@ -230,10 +237,26 @@ function system_themes_form() { '#type' => 'submit', '#value' => t('Reset to defaults'), ); + $form['#validate'][] = 'system_themes_form_validate'; return $form; } +function system_themes_form_validate($form, &$form_state) { + $enabled_modules = system_enabled_modules(); + + if (in_array($form_state['values']['theme_default'], $enabled_modules)) { + form_set_error($form_state['values']['theme_default'], t("The '!theme' theme could not be set as default because it conflicts with an enabled module with the same name.", array('!theme' => $form_state['values']['theme_default']))); + } + else if (is_array($form_state['values']['status'])) { + foreach ($form_state['values']['status'] as $key => $choice) { + if ($choice && in_array($key, $enabled_modules)) { + form_set_error($key, t("The '!theme' theme could not be enabled because it conflicts with an enabled module with the same name.", array('!theme' => $key))); + } + } + } +} + /** * Process system_themes_form form submissions. */ @@ -554,6 +577,36 @@ function _system_is_incompatible(&$incom } /** + * Get names of all enabled modules + * + * @return + * Returns an array of the names of all enabled modules + */ +function system_enabled_modules() { + $enabled_modules = array(); + $result = db_query("SELECT name FROM {system} WHERE type='module' AND status=1"); + while ($module = db_fetch_object($result)) { + $enabled_modules[] = $module->name; + } + return $enabled_modules; +} + +/** + * Get names of all enabled themes + * + * @return + * Returns an array of the names of all enabled themes + */ +function system_enabled_themes() { + $enabled_themes = array(); + $result = db_query("SELECT name FROM {system} WHERE type='theme' AND status=1"); + while ($theme = db_fetch_object($result)) { + $enabled_themes[] = $theme->name; + } + return $enabled_themes; +} + +/** * Menu callback; provides module enable/disable interface. * * The list of modules gets populated by module.info files, which contain each module's name, @@ -598,6 +651,8 @@ function system_modules($form_state = ar return system_modules_confirm_form($files, $form_state['storage']); } + $enabled_themes = system_enabled_themes(); + $modules = array(); $form['modules'] = array('#tree' => TRUE); @@ -644,6 +699,16 @@ function system_modules($form_state = ar } } } + + // Mark module disabled if there is an enabled module with the same name. + if (in_array($module->name, $enabled_themes)) { + $extra['theme_name_conflict'] = TRUE; + $extra['disabled'] = TRUE; + } + else { + $extra['theme_name_conflict'] = FALSE; + } + $form['modules'][$module->info['package']][$filename] = _system_modules_build_row($module->info, $extra); } // Add basic information to the fieldsets. @@ -667,10 +732,25 @@ function system_modules($form_state = ar '#value' => t('Save configuration'), ); $form['#action'] = url('admin/build/modules/list/confirm'); + $form['#validate'][] = 'system_modules_validate'; return $form; } +function system_modules_validate($form, &$form_state) { + $enabled_themes = system_enabled_themes(); + + if (isset($form_state['input']['modules'])) { + foreach ($form_state['input']['modules'] as $group_name => $group) { + foreach ($group as $module_name => $module_state) { + if ($module_state['enable'] && in_array($module_name, $enabled_themes)) { + form_set_error("modules][$group_name][$module_name", t("The '!module' module could not be enabled because it conflicts with an enabled theme with the same name.", array('!module' => $module_name))); + } + } + } + } +} + /** * Array sorting callback; sorts modules or themes by their name. */ @@ -728,6 +808,12 @@ function _system_modules_build_row($info $status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())); } + if ($extra['theme_name_conflict']) { + $compatible = FALSE; + $status_short .= t('Name conflict with enabled theme.'); + $status_long .= t('The name of this module conflicts with the !theme theme.', array('!theme' => $info['name'])); + } + // If this module is compatible, present a checkbox indicating // this module may be installed. Otherwise, show a big red X. if ($compatible) { @@ -2228,6 +2314,11 @@ function theme_system_themes_form($form) } $description .= '