function upgrade_assist_enable_modules in Upgrade Status 6
Form constructor to re-enable non-core modules.
File
- upgrade_assist/
upgrade_assist.module, line 662 - Assists in upgrading Drupal.
Code
function upgrade_assist_enable_modules() {
drupal_set_title(t('Re-enable modules'));
$disabled_modules = variable_get('upgrade_assist_modules_disabled', array());
$options = array();
$all_modules = db_query("SELECT * FROM {system} WHERE type = 'module'")
->fetchAllAssoc('name');
foreach ($all_modules as $module) {
$module->info = unserialize($module->info);
// Skip required core modules and hidden modules.
if (!empty($module->info['required']) || !empty($module->info['hidden'])) {
continue;
}
// Ignore core modules by package name.
if ($module->info['package'] == 'Core') {
continue;
}
// Extra safety.
if ($module->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
continue;
}
// Skip already enabled modules and not previously disabled modules.
if ($module->status || !isset($disabled_modules[$module->name])) {
continue;
}
// Dependencies need to exist.
$dependencies = TRUE;
if (isset($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $required) {
if (!isset($all_modules[$required])) {
$dependencies = FALSE;
break;
}
}
}
if ($dependencies) {
$options[$module->name] = t('@project: @name', array(
'@project' => isset($module->info['project']) ? $module->info['project'] : t('Unknown'),
'@name' => $module->info['name'],
));
}
}
// Sort options by label.
asort($options);
$form['enable'] = array(
'#type' => 'checkboxes',
'#title' => t('Modules to re-enable'),
'#options' => $options,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Re-enable'),
);
return $form;
}