--- system.module?rev=1.196 2005-03-05 19:41:38.000000000 +0100 +++ system.module 2005-03-06 03:11:35.000000000 +0100 @@ -395,11 +395,13 @@ function system_theme_data() { * sites/somesite/modules/. * @param $key * The key to be passed to file_scan_directory(). + * @param $min_depth + * Minimum depth of directories to return files from. * * @return * An array of file objects of the specified type. */ -function system_listing($mask, $directory, $key = 'name') { +function system_listing($mask, $directory, $key = 'name', $min_depth = 1) { $config = conf_init(); $searchdir = array($directory); $files = array(); @@ -410,7 +412,7 @@ function system_listing($mask, $director // Get current list of items foreach ($searchdir as $dir) { - $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key)); + $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth)); } return $files; @@ -456,7 +458,7 @@ function system_theme_listing() { */ function system_module_listing() { // Get current list of modules - $files = system_listing('\.module$', 'modules'); + $files = system_listing('\.module$', 'modules', 'name', 0); // Extract current files from database. system_get_files_database($files, 'module'); @@ -465,6 +467,7 @@ function system_module_listing() { $required = array('block', 'filter', 'system', 'user', 'watchdog'); $throttle_required = array_merge($required, array('throttle')); + $depends = module_invoke_all('depends'); $header = array(t('Name'), t('Description'), t('Enabled')); if (module_exist('throttle')) { @@ -486,15 +489,29 @@ function system_module_listing() { } } + if (!$file->status && in_array($file->name, $depends)) { + drupal_set_message(t('%module is switched on because other modules depend on it.', array ('%module' => $file->name)), 'error'); + $file->status = 1; + $need_save = TRUE; + } + // Update the contents of the system table: db_query("DELETE FROM {system} WHERE name = '%s' AND type = '%s'", $file->name, 'module'); db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->description, 'module', $file->filename, $file->status, $file->throttle, $bootstrap); $row = array($file->name, $file->description, array('data' => (in_array($file->name, $required) ? form_hidden("status][$file->name", 1) . t('required') : form_checkbox('', "status][$file->name", 1, $file->status)), 'align' => 'center')); + $edit['status'][$file->name] = $file->status; if (module_exist('throttle')) { $row[] = array('data' => (in_array($file->name, $throttle_required) ? form_hidden("throttle][$file->name", 0) . t('required') : form_checkbox(NULL, "throttle][$file->name", 1, $file->throttle, NULL)), 'align' => 'center'); + $edit['throttle'][$file->name] = $file->throttle; } $rows[] = $row; + + } + + if ($need_save) { + $edit['type'] = 'module'; + system_listing_save($edit, t('Save configuration')); } $output = theme('table', $header, $rows); @@ -503,9 +520,13 @@ function system_module_listing() { return $output; } -function system_listing_save($edit = array()) { - $op = $_POST['op']; - $edit = $_POST['edit']; +function system_listing_save($edit = array(), $op = '') { + if (empty($op)) { + $op = $_POST['op']; + } + if (empty($edit)) { + $edit = $_POST['edit']; + } if ($op == t('Save configuration')) { db_query("UPDATE {system} SET status = 0 WHERE type = '%s'", $edit['type']); @@ -525,7 +546,11 @@ function system_listing_save($edit = arr cache_clear_all(); menu_rebuild(); - drupal_set_message(t('The configuration options have been saved.')); + $message = t('The configuration options have been saved.'); + if (!in_array($message, drupal_set_message())) { + drupal_set_message($message); + } + drupal_goto($_GET['q']); } } --- forum.module~ 2005-02-10 22:00:02.000000000 +0100 +++ forum.module 2005-03-06 01:29:30.000000000 +0100 @@ -25,6 +25,13 @@ function forum_help($section) { } /** + * Implementation of hook_depends(). + */ +function forum_depends() { + return 'comment'; +} + +/** * Implementation of hook_node_name(). */ function forum_node_name($node) {