Index: modules/system/admin.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/admin.css,v retrieving revision 1.21 diff -u -p -r1.21 admin.css --- modules/system/admin.css 3 Aug 2009 03:04:33 -0000 1.21 +++ modules/system/admin.css 22 Oct 2009 16:57:10 -0000 @@ -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; } Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.216 diff -u -p -r1.216 system.admin.inc --- modules/system/system.admin.inc 19 Oct 2009 23:28:40 -0000 1.216 +++ modules/system/system.admin.inc 22 Oct 2009 16:57:10 -0000 @@ -214,6 +214,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; // Create a list which includes the current theme and all its base themes. @@ -261,6 +263,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( @@ -269,6 +275,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', @@ -300,10 +307,26 @@ function system_themes_form() { '#type' => 'submit', '#value' => t('Save configuration'), ); + $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. */ @@ -651,6 +674,26 @@ 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() { + return db_query("SELECT name FROM {system} WHERE type = 'module' AND status = 1")->fetchCol(); +} + +/** + * Get names of all enabled themes + * + * @return + * Returns an array of the names of all enabled themes + */ +function system_enabled_themes() { + return db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1")->fetchCol(); +} + +/** * Menu callback; provides module enable/disable interface. * * The list of modules gets populated by module.info files, which contain each module's name, @@ -690,6 +733,8 @@ function system_modules($form, $form_sta return system_modules_confirm_form($files, $form_state['storage']); } + $enabled_themes = system_enabled_themes(); + $modules = array(); $form['modules'] = array('#tree' => TRUE); @@ -746,6 +791,16 @@ function system_modules($form, $form_sta } } } + + // 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. @@ -769,10 +824,25 @@ function system_modules($form, $form_sta '#value' => t('Save configuration'), ); $form['#action'] = url('admin/config/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. */ @@ -830,6 +900,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) { @@ -2451,6 +2527,11 @@ function theme_system_themes_form($varia } $description .= '
' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) . '
'; } + elseif (isset($form['status']['#name_conflict_modules'][$key])) { + unset($form['status'][$key]); + $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP')); + $description .= '
' . t('This theme name conflicts with an enabled module with the same name.') . '
'; + } else { $status = drupal_render($form['status'][$key]); }