You are here

function system_modules_confirm_form in Drupal 5

Same name and namespace in other branches
  1. 6 modules/system/system.admin.inc \system_modules_confirm_form()
  2. 7 modules/system/system.admin.inc \system_modules_confirm_form()
1 call to system_modules_confirm_form()
system_modules in modules/system/system.module
Menu callback; provides module enable/disable interface.

File

modules/system/system.module, line 1387
Configuration system that lets administrators modify the workings of the site.

Code

function system_modules_confirm_form($modules, $form_values = array()) {
  $form = array();
  $items = array();

  // Check values for submitted dependency errors.
  if ($dependencies = system_module_build_dependencies($modules, $form_values)) {

    // preserve the already switched on modules
    foreach ($modules as $name => $module) {
      if ($module->status) {
        $form['status'][$name] = array(
          '#type' => 'hidden',
          '#value' => 1,
        );
      }
    }
    $form['validation_modules'] = array(
      '#type' => 'value',
      '#value' => $modules,
    );
    $form['status']['#tree'] = TRUE;
    foreach ($dependencies as $name => $missing_dependencies) {
      $form['status'][$name] = array(
        '#type' => 'hidden',
        '#value' => 1,
      );
      foreach ($missing_dependencies as $k => $dependency) {
        $form['status'][$dependency] = array(
          '#type' => 'hidden',
          '#value' => 1,
        );
        $info = $modules[$dependency]->info;
        $missing_dependencies[$k] = $info['name'] ? $info['name'] : drupal_ucfirst($dependency);
      }
      $t_argument = array(
        '%module' => $modules[$name]->info['name'],
        '%dependencies' => implode(', ', $missing_dependencies),
      );
      $items[] = strtr(format_plural(count($missing_dependencies), 'You must enable the %dependencies module to install %module.', 'You must enable the %dependencies modules to install %module.'), $t_argument);
    }
    $form['text'] = array(
      '#value' => theme('item_list', $items),
    );
  }
  if ($form) {

    // Set some default form values
    $form = confirm_form($form, t('Some required modules must be enabled'), 'admin/build/modules', t('Would you like to continue with enabling the above?'), t('Continue'), t('Cancel'));
    return $form;
  }
}