function module_enable

cis7 module_enable($module_list, $enable_dependencies = TRUE)
cle7 module_enable($module_list, $enable_dependencies = TRUE)
elmsmedia7 module_enable($module_list, $enable_dependencies = TRUE)
icor7 module_enable($module_list, $enable_dependencies = TRUE)
meedjum_blog7 module_enable($module_list, $enable_dependencies = TRUE)
mooc7 module_enable($module_list, $enable_dependencies = TRUE)

Enables or installs a given list of modules.


  • "Enabling" is the process of activating a module for use by Drupal.
  • "Disabling" is the process of deactivating a module.
  • "Installing" is the process of enabling it for the first time or after it has been uninstalled.
  • "Uninstalling" is the process of removing all traces of a module.

Order of events:

  • Gather and add module dependencies to $module_list (if applicable).
  • For each module that is being enabled:
    • Install module schema and update system registries and caches.
    • If the module is being enabled for the first time or had been uninstalled, invoke hook_install() and add it to the list of installed modules.
    • Invoke hook_enable().
  • Invoke hook_modules_installed().
  • Invoke hook_modules_enabled().


$module_list: An array of module names.

$enable_dependencies: If TRUE, dependencies will automatically be added and enabled in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete and in the correct order.

Return value

FALSE if one or more dependencies are missing, TRUE otherwise.

See also





22 calls to module_enable()
admin_menu_toggle_modules in sites/all/modules/ulmus/admin_menu/
Menu callback; Enable/disable developer modules.
ctools_update_6003 in sites/all/modules/ulmus/ctools/ctools.install
Take over for the panels_views module if it was on.
ctools_update_6007 in sites/all/modules/ulmus/ctools/ctools.install
ctools_custom_content table was originally here, but is now moved to its own module.
date_update_7002 in sites/all/modules/ulmus/date/date.install
Add a notification about the new Date All Day module, and enable it.
date_update_7003 in sites/all/modules/ulmus/date/date.install
Adds a notification about the new Date Repeat Field module, and enable it.

... See full list


includes/, line 383
API for loading and interacting with Drupal modules.


function module_enable($module_list, $enable_dependencies = TRUE) {
  if ($enable_dependencies) {
    // Get all module data so we can find dependencies and sort.
    $module_data = system_rebuild_module_data();
    // Create an associative array with weights as values.
    $module_list = array_flip(array_values($module_list));

    while (list($module) = each($module_list)) {
      if (!isset($module_data[$module])) {
        // This module is not found in the filesystem, abort.
        return FALSE;
      if ($module_data[$module]->status) {
        // Skip already enabled modules.
      $module_list[$module] = $module_data[$module]->sort;

      // Add dependencies to the list, with a placeholder weight.
      // The new modules will be processed as the while loop continues.
      foreach (array_keys($module_data[$module]->requires) as $dependency) {
        if (!isset($module_list[$dependency])) {
          $module_list[$dependency] = 0;

    if (!$module_list) {
      // Nothing to do. All modules already enabled.
      return TRUE;

    // Sort the module list by pre-calculated weights.
    $module_list = array_keys($module_list);

  // Required for module installation checks.
  include_once DRUPAL_ROOT . '/includes/';

  $modules_installed = array();
  $modules_enabled = array();
  foreach ($module_list as $module) {
    // Only process modules that are not already enabled.
    $existing = db_query("SELECT status FROM {system} WHERE type = :type AND name = :name", array(
      ':type' => 'module',
      ':name' => $module,
    if ($existing->status == 0) {
      // Load the module's code.
      drupal_load('module', $module);

      // Update the database and module list to reflect the new module. This
      // needs to be done first so that the module's hook implementations,
      // hook_schema() in particular, can be called while it is being
      // installed.
      db_update('system')->fields(array('status' => 1))->condition('type', 'module')->condition('name', $module)->execute();
      // Refresh the module list to include it.
      module_implements('', FALSE, TRUE);
      // Update the registry to include it.
      // Refresh the schema to include it.
      drupal_get_schema(NULL, TRUE);
      // Update the theme registry to include it.
      // Clear entity cache.

      // Now install the module if necessary.
      if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {

        // Set the schema version to the number of the last update provided
        // by the module.
        $versions = drupal_get_schema_versions($module);
        $version = $versions ? max($versions) : SCHEMA_INSTALLED;

        // If the module has no current updates, but has some that were
        // previously removed, set the version to the value of
        // hook_update_last_removed().
        if ($last_removed = module_invoke($module, 'update_last_removed')) {
          $version = max($version, $last_removed);
        drupal_set_installed_schema_version($module, $version);
        // Allow the module to perform install tasks.
        module_invoke($module, 'install');
        // Record the fact that it was installed.
        $modules_installed[] = $module;
        watchdog('system', '%module module installed.', array('%module' => $module), WATCHDOG_INFO);

      // Enable the module.
      module_invoke($module, 'enable');

      // Record the fact that it was enabled.
      $modules_enabled[] = $module;
      watchdog('system', '%module module enabled.', array('%module' => $module), WATCHDOG_INFO);

  // If any modules were newly installed, invoke hook_modules_installed().
  if (!empty($modules_installed)) {
    module_invoke_all('modules_installed', $modules_installed);

  // If any modules were newly enabled, invoke hook_modules_enabled().
  if (!empty($modules_enabled)) {
    module_invoke_all('modules_enabled', $modules_enabled);

  return TRUE;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.