function system_enable_module
Search API
7.x system.module | system_enable_module($module_details) |
6.x system.module | system_enable_module($module_details) |
4.x system.module | system_enable_module($module_details) |
5.x system.module | system_enable_module($module_details) |
Handles the enabling (and possible installation) of module.
2 calls to system_enable_module()
- system_enable in modules/
system/ system.install - Implementation of hook_enable.
- system_modules_form_submit in modules/
system/ system.module - Submit handler for the modules form.
File
- modules/
system/ system.module, line 4746
Code
function system_enable_module($module_details) {
$module = $module_details ["module"];
$path = $module_details ["path"];
$bool_call_hook_install = FALSE;
// Do we need to attempt to call the hook_install function?
if (@$module_details ["enabled"] == "") {
// Wasn't in the database, so we need to install it.
$schema = 0;
if (isset($module_details ['schema'])) {
$schema = $module_details ['schema'];
}
// Add to our table.
// (delete anything all ready there first)
$res = db_query("DELETE FROM modules WHERE `name` = ? ", $module);
// Now, add back into the table.
$res = db_query("INSERT INTO modules (`name`, `path`, `version`, `requires`, `enabled`, `type`, `schema`, `info`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
", $module, $path, @$module_details ["version"], @$module_details ["required"], 0, "module",
@intval($schema), serialize($module_details));
$bool_call_hook_install = TRUE;
fp_add_message(t("The module %module has been installed.", array("%module" => $module)));
}
// If the module has a .install file, begin by including it.
if (include_module_install($module, $path)) {
// Include the original module file first.
include_module($module, TRUE, $path);
if ($bool_call_hook_install) {
// call hook_install if it exists.
if (function_exists($module . '_install')) {
call_user_func($module . '_install');
}
}
// Now, we can call hook_enable, if it exists.
if (function_exists($module . '_enable')) {
call_user_func($module . '_enable');
}
}
// Update our table.
$res = db_query("UPDATE modules SET `enabled` = '1' WHERE `name` = ? ", $module);
fp_add_message(t("The module %module has been enabled.", array("%module" => $module)));
}