You are here

function module_enable in Drupal 6

Same name and namespace in other branches
  1. 5 includes/module.inc \module_enable()
  2. 7 includes/module.inc \module_enable()

Enable a given list of modules.

Parameters

$module_list: An array of module names.

4 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.admin.inc
Submit callback; handles modules form submission.
system_update_6029 in modules/system/system.install
Enable the dblog module on sites that upgrade, since otherwise watchdog logging will stop unexpectedly.
_install_module_batch in ./install.php
Batch callback for batch installation of modules.

File

includes/module.inc, line 312
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 = '%s' AND name = '%s'", 'module', $module));
    if ($existing->status == 0) {
      module_load_install($module);
      db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", 1, 0, 'module', $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);
  }
  foreach ($invoke_modules as $module) {
    module_invoke($module, 'enable');

    // Check if node_access table needs rebuilding.
    // We check for the existence of node_access_needs_rebuild() since
    // at install time, module_enable() could be called while node.module
    // is not enabled yet.
    if (function_exists('node_access_needs_rebuild') && !node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
      node_access_needs_rebuild(TRUE);
    }
  }
}