diff -urp ./modules/system/admin.css ../DRUPAL-6-CHANGES-NOGIT/modules/system/admin.css --- ./modules/system/admin.css 2009-05-18 15:49:42.000000000 +1200 +++ ../DRUPAL-6-CHANGES-NOGIT/modules/system/admin.css 2009-05-18 16:10:13.000000000 +1200 @@ -51,6 +51,9 @@ div.admin-dependencies, div.admin-requir font-size: 0.9em; color: #444; } +div.admin-theme-name-conflict { + color: #f00; +} span.admin-disabled { color: #800; } diff -urp ./modules/system/system.admin.inc ../DRUPAL-6-CHANGES-NOGIT/modules/system/system.admin.inc --- ./modules/system/system.admin.inc 2009-05-18 15:49:42.000000000 +1200 +++ ../DRUPAL-6-CHANGES-NOGIT/modules/system/system.admin.inc 2009-05-18 16:10:13.000000000 +1200 @@ -196,6 +196,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; @@ -234,6 +236,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( @@ -242,6 +248,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', @@ -256,9 +263,25 @@ 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 a module with the same name is currently enabled.", 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 a module with the same name is currently enabled.", array('!theme' => $key))); + } + } + } +} + /** * Process system_themes_form form submissions. */ @@ -598,6 +621,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. * * Modules can be enabled or disabled and set for throttling if the throttle module is enabled. @@ -632,6 +685,8 @@ function system_modules($form_state = ar } $dependencies = array(); + $enabled_themes = system_enabled_themes(); + // Store module list for validation callback. $form['validation_modules'] = array('#type' => 'value', '#value' => $files); @@ -673,7 +728,7 @@ function system_modules($form_state = ar if ($file->throttle) { $throttle[] = $file->name; } - + $dependencies = array(); // Check for missing dependencies. if (is_array($file->info['dependencies'])) { @@ -703,6 +758,7 @@ function system_modules($form_state = ar } } + $disabled_by_dependents = FALSE; // Mark dependents disabled so user can not remove modules being depended on. $dependents = array(); foreach ($file->info['dependents'] as $dependent) { @@ -710,12 +766,25 @@ function system_modules($form_state = ar $dependents[] = t('@module (enabled)', array('@module' => $files[$dependent]->info['name'])); $disabled[] = $filename; $form['disabled_modules']['#value'][$filename] = TRUE; + $disabled_by_dependents = TRUE; } else { $dependents[] = t('@module (disabled)', array('@module' => $files[$dependent]->info['name'])); } } + // Mark module disabled if there is an enabled module with the same name. + if (in_array($file->name, $enabled_themes)) { + $form['description'][$filename]['theme_conflict'] = array( + '#value' => t('Conflicts with an enabled theme with the same name'), + '#prefix' => '
', + '#suffix' => '
', + ); + if (!$disabled_by_dependents) { // check it hasn't already been disabled + $disabled[] = $filename; + } + } + // Add text for enabled dependents. if (!empty($dependents)) { $form['description'][$filename]['required'] = array( @@ -768,10 +837,23 @@ 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 (is_array($form_state['values']['status'])) { + foreach ($form_state['values']['status'] as $key => $choice) { + if ($choice && in_array($key, $enabled_themes)) { + form_set_error($key, t("The '!module' module could not be enabled because a theme with the same name is currently enabled.", array('!module' => $key))); + } + } + } +} + /** * Array sorting callback; sorts modules or themes by their name. */ @@ -2184,6 +2266,11 @@ function theme_system_themes_form($form) } $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('name conflict'), t('Name conflict with enabled module with same name')); + $description .= '
'. t('This theme name conflicts with an enabled module with the same name.', array('!core_version' => VERSION)) .'
'; + } else { $status = drupal_render($form['status'][$key]); }