You are here

function upgrade_assist_disable_modules_validate in Upgrade Status 6

Form submit handler to disable non-core modules.

File

upgrade_assist/upgrade_assist.module, line 552
Assists in upgrading Drupal.

Code

function upgrade_assist_disable_modules_validate($form, &$form_state) {
  if (!empty($form_state['values']['disable'])) {
    $modules = array_filter($form_state['values']['disable']);

    // Reload already disabled modules, merge the new ones, and save the list
    // for later use.
    $module_info = variable_get('upgrade_assist_modules_disabled', array());
    $module_info = array_merge($module_info, array_intersect_key($form['#modules'], $modules));
    variable_set('upgrade_assist_modules_disabled', $module_info);

    // Compile and save a list of projects for later use.
    // Ensure that special cases are contained.
    $project_info = array_intersect_key($form['#projects'], array(
      'upgrade_assist' => 1,
      'demo' => 1,
    ));
    foreach ($modules as $module) {
      if (isset($form['#projects'][$module])) {
        $project = $form['#projects'][$module];
        $project_info[$project['project']] = $project;
      }
    }
    variable_set('upgrade_assist_projects', $project_info);
    module_disable($modules);
    drupal_flush_all_caches();
    drupal_set_message(t('The selected modules have been disabled.'));
  }
}