You are here

function module_weights_settings in Util 6.2

Same name and namespace in other branches
  1. 6.3 module_weights.module \module_weights_settings()
1 string reference to 'module_weights_settings'
module_weights_menu in ./module_weights.module

File

./module_weights.module, line 125
Allows module weights to be viewed and edited.

Code

function module_weights_settings() {
  $form = array();
  $weighted = $missing = array();
  $header = array(
    t('Module'),
    t('Weight'),
  );
  $result = db_query("SELECT name, weight, filename FROM {system} WHERE TYPE = 'module' ORDER BY name");
  while ($row = db_fetch_object($result)) {
    if (!file_exists($row->filename)) {
      $missing[] = $row->name;
    }
    if ($row->weight != 0) {
      $weighted[] = array(
        $row->name,
        array(
          'data' => $row->weight,
          'align' => 'right',
        ),
      );
    }
  }
  if ($missing) {
    $form['missing'] = array(
      '#type' => 'fieldset',
      '#title' => t('Missing module files'),
      '#description' => t('These module files could not be found and mess up the modules administration page. The system table needs to be cleaned up.'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['missing']['list'] = array(
      '#type' => 'markup',
      '#value' => theme('item_list', $missing),
    );
  }
  $form['weights'] = array(
    '#type' => 'fieldset',
    '#title' => t('Weighted modules'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['weights']['list'] = array(
    '#type' => 'markup',
    '#value' => theme('table', $header, $weighted, array(
      'style' => 'width: auto;',
    )),
  );
  return $form;
}