You are here

function prod_check_prod_mode_modules in Production check & Production monitor 7

Same name and namespace in other branches
  1. 6 includes/prod_check.admin.inc \prod_check_prod_mode_modules()

Helper function to enable / disable modules. Also used by Drush.

2 calls to prod_check_prod_mode_modules()
drush_prod_check_prod_mode in ./prod_check.drush.inc
Switch to production mode.
prod_check_prod_mode_form_submit in includes/prod_check.admin.inc
Setup site for production mode: submit.

File

includes/prod_check.admin.inc, line 695

Code

function prod_check_prod_mode_modules($options) {
  $modules['disable'] = array(
    'devel',
    'devel_generate',
    'devel_node_access',
    'devel_themer',
    'update',
  );
  if (isset($options['dblog']) && $options['dblog']) {
    $modules['disable'][] = 'dblog';
  }

  // We do this primarily to prepare feedback to the user. module_disable() will
  // do a module_exists() check as well but only provides feedback using
  // watchdog().
  foreach ($modules['disable'] as $id => $module) {
    if (!module_exists($module)) {
      unset($modules['disable'][$id]);
    }
  }
  if (!empty($modules['disable'])) {
    module_disable($modules['disable']);
  }
  $modules['enable'] = array();
  if ($options['nagios']) {
    $modules['enable'][] = 'nagios';
  }

  // We cannot check if a module is available on the file system. At least,
  // there is not a function in Drupal that I know of to do this and I could not
  // find one. Hence this approach, until there's a better way.
  if (!empty($modules['enable'])) {
    module_enable($modules['enable']);
    foreach ($modules['enable'] as $id => $module) {
      if (!module_exists($module)) {
        unset($modules['enable'][$id]);
      }
    }
  }
  return $modules;
}