function module_enable in Drupal 5
Same name and namespace in other branches
- 6 includes/module.inc \module_enable()
- 7 includes/module.inc \module_enable()
Enable a given list of modules.
Parameters
$module_list: An array of module names.
2 calls to module_enable()
- drupal_install_modules in includes/
install.inc - Calls the install function and updates the system table for a given list of modules.
- system_modules_submit in modules/
system/ system.module - Submit callback; handles modules form submission.
File
- includes/
module.inc, line 238 - API for loading and interacting with Drupal modules.
Code
function module_enable($module_list) {
$invoke_modules = array();
foreach ($module_list as $module) {
$existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = 'module' AND name = '%s'", $module));
if ($existing->status === '0') {
module_load_install($module);
db_query("UPDATE {system} SET status = 1, throttle = 0 WHERE type = 'module' AND name = '%s'", $module);
drupal_load('module', $module);
$invoke_modules[] = $module;
}
}
if (!empty($invoke_modules)) {
// Refresh the module list to include the new enabled module.
module_list(TRUE, FALSE);
// Force to regenerate the stored list of hook implementations.
module_implements('', FALSE, TRUE);
cache_clear_all('*', 'cache_menu', TRUE);
}
foreach ($invoke_modules as $module) {
module_invoke($module, 'enable');
}
}