module_enable

Versions
5 – 6
module_enable($module_list)
7
module_enable($module_list, $disable_modules_installed_hook = FALSE)

Enable a given list of modules.

Parameters

$module_list An array of module names.

▾ 2 functions call 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.

Code

includes/module.inc, line 238

<?php
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');
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.