diff --git includes/module.inc includes/module.inc index 092a32d..1d2c9a0 100644 --- includes/module.inc +++ includes/module.inc @@ -124,11 +124,41 @@ function system_list($type) { // drupal_get_filename() is called without the 'file' argument. drupal_get_filename($record->type, $record->name, $record->filename); } + + system_list_overrides($lists); } return $lists[$type]; } +/* + * Add or remove to the enabled modules/themes as specified in the + * $conf['system_list_overrides'] variable in settings.php. + * + * @param $lists + * An array keyed by system record type (modules, themes, bootstrap). + */ +function system_list_overrides(&$lists) { + if ($overrides = variable_get('system_list_overrides', array())) { + foreach ($overrides as $type => $items) { + foreach ($items as $name => $status) { + if ($status) { + if ($type == 'module') { + $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..0be1c7e 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 and Themes pages using the array below. + * Note that typical enable/disable should use the Modules and Themes pages. + * For example, enabling a module here does not run its hook_install(). + * + * Remove the leading hash signs to enable. + */ + #$conf['system_list_overrides'] = array( + # 'theme' => array( + # 'seven' => 0, + # ), + # 'module' => array( + # 'devel' => 1, + # ), + # 'bootstrap' => array( + # // Add modules which should be (not) loaded during bootstrap. Modules here + # // should also be listed in the 'modules' section above. + # 'devel' => 1, + # ), + #);