diff --git includes/module.inc includes/module.inc index 59f546c..960d5cb 100644 --- includes/module.inc +++ includes/module.inc @@ -121,11 +121,40 @@ function drupal_build_system_lists() { drupal_get_filename($record->type, $record->name, $record->filename); } } + drupal_build_system_lists_overrides($lists); } - + return $lists; } +/* + * Add or remove to the enabled modules/themes as specified in the + * $conf['system_lists_overrides'] variable in settings.php. + * + * @param $lists + * An array keyed by system record type (modules, themes, bootstrap). + */ +function drupal_build_system_lists_overrides(&$lists) { + if ($overrides = variable_get('system_lists_overrides', array())) { + foreach ($overrides as $type => $items) { + foreach ($items as $name => $status) { + if ($status) { + if ($type == 'modules') { + $lists[$type][$name] = $name; + } + else { + $theme = db_query('SELECT * FROM {system} WHERE name = :name AND type = :name', array(':name' => $name, ':type' => $type))->fetchAll(); + $lists[$type][$name] = $theme; + } + } + else { + unset($lists[$type][$name]); + } + } + } + } +} + /** * Find dependencies any level deep and fill in required by information too. * diff --git sites/default/default.settings.php sites/default/default.settings.php index bc97373..67c32b5 100644 --- sites/default/default.settings.php +++ sites/default/default.settings.php @@ -359,3 +359,26 @@ $conf = array( * Remove the leading hash signs to disable. */ # $conf['allow_authorize_operations'] = FALSE; + +/** + * Dynamically enable/disable modules and themes. + * + * Override choices made on the Modules page using the array below. Note that + * general enable/disable should still happen on using the admin web pages. For + * example, enabling a module here does not run its hook_install(). + * + * Remove the leading hash signs to enable. + */ + #$conf['system_lists_overrides'] = array( + # 'themes' => array( + # 'seven' => 0, + # ), + # 'modules' => array( + # 'devel' => 0, + # ), + # 'bootstrap' => array( + # // Add modules which should be (not) loaded during bootstrap. Modules here + # // should also be listed in the 'modules' section above. + # 'devel' => 0, + # ), + #); \ No newline at end of file