You are here

function systeminfo_display_drupal in System Information 6.2

Same name and namespace in other branches
  1. 5.2 systeminfo.module \systeminfo_display_drupal()
  2. 6 systeminfo.module \systeminfo_display_drupal()

Menu callback of page 'Drupal'.

1 string reference to 'systeminfo_display_drupal'
systeminfo_menu in ./systeminfo.module
Implementation of hook_menu().

File

./systeminfo.module, line 397
Displays information about the Drupal installation and system environment.

Code

function systeminfo_display_drupal() {
  drupal_add_css(drupal_get_path('module', 'systeminfo') . '/systeminfo.css');
  $output = '<p>' . t('Information about the Drupal installation.') . '</p>';

  // Content
  $output_fieldset = '';
  $types_active = array();
  $types_deleted = array();
  $result = db_query("SELECT n.type, nt.name, COUNT(n.nid) AS count FROM {node} n LEFT JOIN {node_type} nt ON n.type = nt.type GROUP BY n.type, nt.name");
  while ($type = db_fetch_object($result)) {
    if ($type->name) {
      $types_active[$type->name] = $type;
    }
    else {
      $types_deleted[$type->type] = $type;
    }
  }
  ksort($types_active);
  ksort($types_deleted);
  $header = array(
    t('Group'),
    t('Value'),
  );
  $rows = array();
  $rows[] = array(
    t('Total'),
    t('!nodes', array(
      '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node}")), '1 node', '@count nodes'),
    )),
  );
  if ($types_active) {
    $rows[] = array(
      array(
        'data' => t('Active content types'),
        'class' => 'title1',
        'colspan' => '2',
      ),
    );
    foreach ($types_active as $type) {
      $rows[] = array(
        array(
          'data' => check_plain($type->name),
          'class' => 'text1',
        ),
        t('!nodes', array(
          '!nodes' => format_plural($type->count, '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Published'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND status = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Promoted to front page'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND promote = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Sticky at top of lists'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND sticky = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
    }
  }
  if ($types_deleted) {
    $rows[] = array(
      array(
        'data' => t('Deleted content types'),
        'class' => 'title1',
        'colspan' => '2',
      ),
    );
    foreach ($types_deleted as $type) {
      $rows[] = array(
        array(
          'data' => $type->type,
          'class' => 'text1',
        ),
        t('!nodes', array(
          '!nodes' => format_plural($type->count, '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Published'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND status = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Promoted to front page'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND promote = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
      $rows[] = array(
        array(
          'data' => t('Sticky at top of lists'),
          'class' => 'text2',
        ),
        t('!nodes', array(
          '!nodes' => format_plural(db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type = '%s' AND sticky = 1", $type->type)), '1 node', '@count nodes'),
        )),
      );
    }
  }
  $output_fieldset .= theme('table', $header, $rows, array(
    'class' => 'systeminfo systeminfo_width50',
  ));
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Content'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);

  // Content types
  $output_fieldset = '';
  $node_get_types_names = node_get_types('names');
  foreach ($node_get_types_names as $node_type => $node_name) {
    $output_fieldset .= '<h4>' . t('Content type: %type', array(
      '%type' => t($node_name),
    )) . '</h4>';
    $header = array(
      t('Name'),
      t('Value'),
    );
    $rows = array();
    $rows[] = array(
      t('Type'),
      $node_type,
    );
    $node_options = variable_get('node_options_' . $node_type, array(
      'status',
      'promote',
    ));
    $rows[] = array(
      t('Published'),
      in_array('status', $node_options) ? t('Yes') : t('No'),
    );
    $rows[] = array(
      t('Promoted to front page'),
      in_array('promote', $node_options) ? t('Yes') : t('No'),
    );
    $rows[] = array(
      t('Sticky at top of lists'),
      in_array('sticky', $node_options) ? t('Yes') : t('No'),
    );
    $rows[] = array(
      t('Create new revision'),
      in_array('revision', $node_options) ? t('Yes') : t('No'),
    );
    $node_language = variable_get('language_content_type_' . $node_type, 0);
    $rows[] = array(
      t('Multilingual support'),
      $node_language == 2 ? t('Enabled, with translation') : ($node_language == 1 ? t('Enabled') : t('Disabled')),
    );
    if (module_exists('comment')) {
      $node_comment = variable_get('comment_' . $node_type, COMMENT_NODE_READ_WRITE);
      $rows[] = array(
        array(
          'data' => t('Comment'),
          'class' => 'title1',
          'colspan' => '2',
        ),
      );
      $rows[] = array(
        array(
          'data' => t('Comment'),
          'class' => 'text1',
        ),
        $node_comment == COMMENT_NODE_READ_WRITE ? t('Read/Write') : ($node_comment == COMMENT_NODE_READ_ONLY ? t('Read only') : t('Disabled')),
      );
      if ($node_comment == COMMENT_NODE_READ_WRITE || $node_comment == COMMENT_NODE_READ_ONLY) {
        $node_comment_mode = variable_get('comment_default_mode_' . $node_type, COMMENT_MODE_THREADED_EXPANDED);
        $node_comment_modes = _comment_get_modes();
        $rows[] = array(
          array(
            'data' => t('Display mode'),
            'class' => 'text1',
          ),
          $node_comment_modes[$node_comment_mode],
        );
        $node_comment_order = variable_get('comment_default_order_' . $node_type, COMMENT_ORDER_NEWEST_FIRST);
        $node_comment_orders = _comment_get_orders();
        $rows[] = array(
          array(
            'data' => t('Display order'),
            'class' => 'text1',
          ),
          $node_comment_orders[$node_comment_order],
        );
        $rows[] = array(
          array(
            'data' => t('Comments per page'),
            'class' => 'text1',
          ),
          variable_get('comment_default_per_page_' . $node_type, 50),
        );
        $node_comment_control = variable_get('comment_controls_' . $node_type, COMMENT_CONTROLS_HIDDEN);
        $node_comment_controls = array(
          COMMENT_CONTROLS_ABOVE => t('Display above the comments'),
          COMMENT_CONTROLS_BELOW => t('Display below the comments'),
          COMMENT_CONTROLS_ABOVE_BELOW => t('Display above and below the comments'),
          COMMENT_CONTROLS_HIDDEN => t('Do not display'),
        );
        $rows[] = array(
          array(
            'data' => t('Controls'),
            'class' => 'text1',
          ),
          $node_comment_controls[$node_comment_control],
        );
        if (user_access('post comments', drupal_anonymous_user())) {
          $node_comment_anonymous = variable_get('comment_anonymous_' . $node_type, COMMENT_ANONYMOUS_MAYNOT_CONTACT);
          $node_comment_anonymous_contact = array(
            COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
            COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
            COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
          );
          $rows[] = array(
            array(
              'data' => t('Anonymous commenting'),
              'class' => 'text1',
            ),
            $node_comment_anonymous_contact[$node_comment_anonymous],
          );
        }
        $rows[] = array(
          array(
            'data' => t('Subject field'),
            'class' => 'text1',
          ),
          variable_get('comment_subject_field_' . $node_type, 1) ? t('Enabled') : t('Disabled'),
        );
        $rows[] = array(
          array(
            'data' => t('Preview'),
            'class' => 'text1',
          ),
          variable_get('comment_preview_' . $node_type, COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL ? t('Optional') : t('Required'),
        );
        $rows[] = array(
          array(
            'data' => t('Location of submission form'),
            'class' => 'text1',
          ),
          variable_get('comment_form_location_' . $node_type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE ? t('Display on separate page') : t('Display below post or comments'),
        );
      }
    }
    if (module_exists('taxonomy')) {
      $vocabularies = taxonomy_get_vocabularies($node_type);
      if (!empty($vocabularies)) {
        $rows[] = array(
          array(
            'data' => t('Taxonomy'),
            'class' => 'title1',
            'colspan' => '2',
          ),
        );
        foreach ($vocabularies as $vocabulary) {
          $rows[] = array(
            array(
              'data' => t('Vocabulary'),
              'class' => 'text1',
            ),
            $vocabulary->name,
          );
        }
      }
    }
    $output_fieldset .= theme('table', $header, $rows, array(
      'class' => 'systeminfo systeminfo_width50',
    ));
  }
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Content types'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);

  // Taxonomy
  if (module_exists('taxonomy')) {
    $vocabularies = taxonomy_get_vocabularies();
    if (count($vocabularies)) {
      $output_fieldset = '';
      foreach ($vocabularies as $vocabulary) {
        $output_fieldset .= '<h4>' . t('Vocabulary: %vocabulary', array(
          '%vocabulary' => $vocabulary->name,
        )) . '</h4>';
        $header = array(
          t('Name'),
          t('Value'),
        );
        $rows = array();
        $rows[] = array(
          t('Type'),
          $vocabulary->hierarchy == 2 ? t('Multiple hierarchy') : ($vocabulary->hierarchy == 1 ? t('Single hierarchy') : t('Flat')),
        );
        $rows[] = array(
          t('Total'),
          t('!terms', array(
            '!terms' => format_plural(db_result(db_query("SELECT COUNT(tid) FROM {term_data} WHERE vid = %d", $vocabulary->vid)), '1 term', '@count terms'),
          )),
        );
        $types = array();
        foreach ($vocabulary->nodes as $type) {
          $node_type = node_get_types('name', $type);
          $types[] = $node_type ? check_plain($node_type) : check_plain($type);
        }
        $rows[] = array(
          t('Content types'),
          !empty($types) ? theme('item_list', $types) : '',
        );
        $rows[] = array(
          t('Multiple select'),
          $vocabulary->multiple ? t('On') : t('Off'),
        );
        $rows[] = array(
          t('Required'),
          $vocabulary->required ? t('On') : t('Off'),
        );
        $rows[] = array(
          t('Tags'),
          $vocabulary->tags ? t('On') : t('Off'),
        );
        $rows[] = array(
          t('Weight'),
          $vocabulary->weight,
        );
        $output_fieldset .= theme('table', $header, $rows, array(
          'class' => 'systeminfo systeminfo_width50',
        ));
      }
      $fieldset = array(
        '#type' => 'fieldset',
        '#title' => t('Taxonomy'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#value' => $output_fieldset,
      );
      $output .= theme('fieldset', $fieldset);
    }
  }

  // Users
  $output_fieldset = '';
  $header = array(
    t('Group'),
    t('Accounts'),
  );
  $rows = array();
  $rows[] = array(
    t('Total'),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Status'),
      'class' => 'title1',
      'colspan' => '2',
    ),
  );
  $rows[] = array(
    array(
      'data' => t('Active'),
      'class' => 'text1',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 1")),
  );
  $rows[] = array(
    array(
      'data' => t('Already logged in'),
      'class' => 'text2',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 1 AND login <> 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Not yet logged in'),
      'class' => 'text2',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 1 AND login = 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Blocked'),
      'class' => 'text1',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Already logged in'),
      'class' => 'text2',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 0 AND login <> 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Not yet logged in'),
      'class' => 'text2',
    ),
    db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0 AND status = 0 AND login = 0")),
  );
  $rows[] = array(
    array(
      'data' => t('Roles'),
      'class' => 'title1',
      'colspan' => '2',
    ),
  );
  $result = db_query("SELECT rid, name FROM {role} WHERE rid <> %d ORDER BY name", DRUPAL_ANONYMOUS_RID);
  while ($role = db_fetch_object($result)) {
    $count = $role->rid != DRUPAL_AUTHENTICATED_RID ? db_result(db_query("SELECT COUNT(uid) FROM {users_roles} WHERE rid = %d", $role->rid)) : db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid <> 0"));
    $rows[] = array(
      array(
        'data' => t($role->name),
        'class' => 'text1',
      ),
      $count,
    );
  }
  $output_fieldset .= theme('table', $header, $rows, array(
    'class' => 'systeminfo systeminfo_width50',
  ));
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Users'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);

  // Roles
  $output_fieldset = '';
  $header = array(
    t('Name'),
    t('Permissions'),
  );
  $rows = array();
  $result = db_query("SELECT r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY r.name");
  while ($role = db_fetch_object($result)) {
    $perms = explode(', ', $role->perm);
    asort($perms);
    $rows[] = array(
      t($role->name),
      !empty($role->perm) ? theme('item_list', $perms) : '',
    );
  }
  $output_fieldset .= theme('table', $header, $rows, array(
    'class' => 'systeminfo systeminfo_width50',
  ));
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Roles'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);

  // Modules
  $output_fieldset = '';
  $modules_sort = variable_get('systeminfo_drupal_modules_sort', 'name');
  $header = array(
    t('Name'),
    t('Version'),
    t('Date'),
    t('Filename'),
    t('Weight'),
  );
  $rows = array();
  foreach (module_list() as $module) {
    $file = db_fetch_object(db_query("SELECT info, filename, weight FROM {system} WHERE type = 'module' AND name = '%s'", $module));
    $file->info = unserialize($file->info);
    $key = $modules_sort == 'name' ? $file->info['name'] : $file->filename;
    $rows[$key] = array(
      $file->info['name'],
      $file->info['version'],
      isset($file->info['datestamp']) ? format_date($file->info['datestamp'], 'small') : '',
      $file->filename,
      $file->weight,
    );
  }
  if ($modules_sort == 'name' || $modules_sort == 'filename') {
    ksort($rows);
  }
  $output_fieldset .= theme('table', $header, $rows, array(
    'class' => 'systeminfo',
  ));
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Modules'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);

  // Themes
  $output_fieldset = '';
  $themes_sort = variable_get('systeminfo_drupal_themes_sort', 'name');
  $header = array(
    t('Name'),
    t('Version'),
    t('Date'),
    t('Filename'),
  );
  $rows = array();
  foreach (list_themes() as $theme) {
    if ($theme->status) {
      $key = $themes_sort == 'name' ? $theme->name : $theme->filename;
      $rows[$key] = array(
        $theme->info['name'],
        $theme->info['version'],
        isset($theme->info['datestamp']) ? format_date($theme->info['datestamp'], 'small') : '',
        $theme->filename,
      );
    }
  }
  if ($themes_sort == 'name' || $themes_sort == 'filename') {
    ksort($rows);
  }
  $output_fieldset .= theme('table', $header, $rows, array(
    'class' => 'systeminfo',
  ));
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Themes'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output_fieldset,
  );
  $output .= theme('fieldset', $fieldset);
  return $output;
}