You are here

function system_modules in Drupal 4

Same name and namespace in other branches
  1. 5 modules/system/system.module \system_modules()
  2. 6 modules/system/system.admin.inc \system_modules()
  3. 7 modules/system/system.admin.inc \system_modules()

Menu callback; displays a listing of all modules.

1 string reference to 'system_modules'
system_menu in modules/system.module
Implementation of hook_menu().

File

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

Code

function system_modules() {

  // Get current list of modules
  $files = system_listing('\\.module$', 'modules', 'name', 0);

  // Extract current files from database.
  system_get_files_database($files, 'module');
  ksort($files);
  foreach ($files as $filename => $file) {
    drupal_get_filename('module', $file->name, $file->filename);
    drupal_load('module', $file->name);
    $file->description = module_invoke($file->name, 'help', 'admin/modules#description');
    $form['name'][$file->name] = array(
      '#value' => $file->name,
    );
    $form['description'][$file->name] = array(
      '#value' => $file->description,
    );
    $options[$file->name] = '';
    if ($file->status) {
      $status[] = $file->name;
    }
    if ($file->throttle) {
      $throttle[] = $file->name;
    }

    // log the critical hooks implemented by this module
    $bootstrap = 0;
    foreach (bootstrap_hooks() as $hook) {
      if (module_hook($file->name, $hook)) {
        $bootstrap = 1;
        break;
      }
    }

    // Update the contents of the system table:
    if (isset($file->status) || isset($file->old_filename) && $file->old_filename != $file->filename) {
      db_query("UPDATE {system} SET description = '%s', name = '%s', bootstrap = %d, filename = '%s' WHERE filename = '%s'", $file->description, $file->name, $bootstrap, $file->filename, $file->old_filename);
    }
    else {

      // This is a new module.
      db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->description, 'module', $file->filename, $file->status, $file->throttle, $bootstrap);
    }
  }

  // Handle status checkboxes, including overriding the generated
  // checkboxes for required modules.
  $form['status'] = array(
    '#type' => 'checkboxes',
    '#default_value' => $status,
    '#options' => $options,
  );
  $required = array(
    'block',
    'filter',
    'node',
    'system',
    'user',
    'watchdog',
  );
  foreach ($required as $require) {
    $form['status'][$require] = array(
      '#type' => 'hidden',
      '#value' => 1,
      '#suffix' => t('required'),
    );
  }

  /**
   * Handle throttle checkboxes, including overriding the generated checkboxes for required modules.
   */
  if (module_exist('throttle')) {
    $form['throttle'] = array(
      '#type' => 'checkboxes',
      '#default_value' => $throttle,
      '#options' => $options,
    );
    $throttle_required = array_merge($required, array(
      'throttle',
    ));
    foreach ($throttle_required as $require) {
      $form['throttle'][$require] = array(
        '#type' => 'hidden',
        '#value' => 0,
        '#suffix' => t('required'),
      );
    }
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return drupal_get_form('system_modules', $form);
}