5 system.module | system_modules( |
6 system.admin.inc | system_modules($form_state = array()) |
7 system.admin.inc | system_modules($form, $form_state = array()) |
8 system.admin.inc | system_modules($form, $form_state = array()) |
Menu callback; provides module enable/disable interface.
Modules can be enabled or disabled and set for throttling if the throttle module is enabled. The list of modules gets populated by module.info files, which contain each module's name, description and dependencies.
Dependency checking is performed to ensure that a module cannot be enabled if the module has disabled dependencies and also to ensure that the module cannot be disabled if the module has enabled dependents.
Return value
The form array.
See also
_module_parse_info_file for information on module.info descriptors.
1 function calls system_modules()
File
- modules/
system/ system.module, line 1245 - Configuration system that lets administrators modify the workings of the site.
Code
<?php
function system_modules($form_values = NULL) {
// Get current list of modules.
$files = module_rebuild_cache();
uasort($files, 'system_sort_modules_by_info_name');
if ($confirm_form = system_modules_confirm_form($files, $form_values)) {
return $confirm_form;
}
// Store module list for validation callback.
$form['validation_modules'] = array(
'#type' => 'value',
'#value' => $files,
);
// Create storage for disabled modules as browser will disable checkboxes.
$form['disabled_modules'] = array(
'#type' => 'value',
'#value' => array(),
);
// Array for disabling checkboxes in callback system_module_disable.
$disabled = array();
// Traverse the files retrieved and build the form.
foreach ($files as $filename => $file) {
$form['name'][$filename] = array('#value' => $file->info['name']);
$form['version'][$filename] = array('#value' => $file->info['version']);
$form['description'][$filename] = array('#value' => t($file->info['description']));
$options[$filename] = '';
if ($file->status) {
$status[] = $file->name;
}
if ($file->throttle) {
$throttle[] = $file->name;
}
$dependencies = array();
// Check for missing dependencies.
if (is_array($file->info['dependencies'])) {
foreach ($file->info['dependencies'] as $dependency) {
if (!isset($files[$dependency]) || !$files[$dependency]->status) {
if (isset($files[$dependency])) {
$dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
}
else {
$dependencies[] = drupal_ucfirst($dependency) . t(' (<span class="admin-missing">missing</span>)');
$disabled[] = $filename;
$form['disabled_modules']['#value'][$filename] = FALSE;
}
}
else {
$dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
}
}
// Add text for dependencies.
if (!empty($dependencies)) {
$form['description'][$filename]['dependencies'] = array(
'#value' => t('Depends on: !dependencies', array('!dependencies' => implode(', ', $dependencies))),
'#prefix' => '<div class="admin-dependencies">',
'#suffix' => '</div>',
);
}
}
// Mark dependents disabled so user can not remove modules being depended on.
$dependents = array();
if (is_array($file->info['dependents'])) {
foreach ($file->info['dependents'] as $dependent) {
if ($files[$dependent]->status == 1) {
$dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
$disabled[] = $filename;
$form['disabled_modules']['#value'][$filename] = TRUE;
}
else {
$dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
}
}
}
// Add text for enabled dependents.
if (!empty($dependents)) {
$form['description'][$filename]['required'] = array(
'#value' => t('Required by: !required', array('!required' => implode(', ', $dependents))),
'#prefix' => '<div class="admin-required">',
'#suffix' => '</div>',
);
}
}
// Merge in required modules.
$modules_required = array('block', 'filter', 'node', 'system', 'user', 'watchdog');
foreach ($modules_required as $required) {
$disabled[] = $required;
$form['disabled_modules']['#value'][$required] = TRUE;
}
// Handle status checkboxes, including overriding
// the generated checkboxes for required modules.
$form['status'] = array(
'#type' => 'checkboxes',
'#default_value' => $status,
'#options' => $options,
'#process' => array(
'expand_checkboxes' => array(),
'system_modules_disable' => array($disabled),
),
);
// Handle throttle checkboxes, including overriding the
// generated checkboxes for required modules.
if (module_exists('throttle')) {
$form['throttle'] = array(
'#type' => 'checkboxes',
'#default_value' => $throttle,
'#options' => $options,
'#process' => array(
'expand_checkboxes' => array(),
'system_modules_disable' => array(array_merge($modules_required, array('throttle'))),
),
);
}
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['#multistep'] = TRUE;
$form['#action'] = url('admin/build/modules/list/confirm');
return $form;
}
?>
Login or register to post comments