function system_modules_submit
7.x system.admin.inc | system_modules_submit($form, &$form_state) |
6.x system.admin.inc | system_modules_submit($form, &$form_state) |
Submit callback; handles modules form submission.
File
- drupal-6.x/
modules/ system/ system.admin.inc, line 877 - Admin page callbacks for the system module.
Code
function system_modules_submit($form, &$form_state) {
include_once './includes/install.inc';
$new_modules = array();
// If we are coming from the confirm form...
if (!isset($form_state['storage'])) {
// Merge in disabled active modules since they should be enabled.
// They don't appear because disabled checkboxes are not submitted
// by browsers.
$form_state['values']['status'] = array_merge($form_state['values']['status'], $form_state['values']['disabled_modules']);
// Check values for dependency that we can't install.
if ($dependencies = system_module_build_dependencies($form_state['values']['validation_modules'], $form_state['values'])) {
// These are the modules that depend on existing modules.
foreach (array_keys($dependencies) as $name) {
$form_state['values']['status'][$name] = 0;
}
}
}
else {
$dependencies = NULL;
}
// Update throttle settings, if present
if (isset($form_state['values']['throttle'])) {
foreach ($form_state['values']['throttle'] as $key => $choice) {
db_query("UPDATE {system} SET throttle = %d WHERE type = 'module' and name = '%s'", $choice ? 1 : 0, $key);
}
}
// If there where unmet dependencies and they haven't confirmed don't process
// the submission yet. Store the form submission data needed later.
if ($dependencies) {
if (!isset($form_state['values']['confirm'])) {
$form_state['storage'] = array($dependencies, $form_state['values']['status']);
return;
}
else {
$form_state['values']['status'] = array_merge($form_state['values']['status'], $form_storage[1]);
}
}
// If we have no dependencies, or the dependencies are confirmed
// to be installed, we don't need the temporary storage anymore.
unset($form_state['storage']);
$enable_modules = array();
$disable_modules = array();
foreach ($form_state['values']['status'] as $key => $choice) {
if ($choice) {
if (drupal_get_installed_schema_version($key) == SCHEMA_UNINSTALLED) {
$new_modules[] = $key;
}
else {
$enable_modules[] = $key;
}
}
else {
$disable_modules[] = $key;
}
}
$old_module_list = module_list();
if (!empty($enable_modules)) {
module_enable($enable_modules);
}
if (!empty($disable_modules)) {
module_disable($disable_modules);
}
// Install new modules.
foreach ($new_modules as $key => $module) {
if (!drupal_check_module($module)) {
unset($new_modules[$key]);
}
}
drupal_install_modules($new_modules);
$current_module_list = module_list(TRUE, FALSE);
if ($old_module_list != $current_module_list) {
drupal_set_message(t('The configuration options have been saved.'));
}
drupal_rebuild_theme_registry();
node_types_rebuild();
menu_rebuild();
cache_clear_all('schema', 'cache');
drupal_clear_css_cache();
drupal_clear_js_cache();
$form_state['redirect'] = 'admin/build/modules';
// Notify locale module about module changes, so translations can be
// imported. This might start a batch, and only return to the redirect
// path after that.
module_invoke('locale', 'system_update', $new_modules);
// Synchronize to catch any actions that were added or removed.
actions_synchronize();
return;
}