You are here

function system_status_status_page in System Status 7

Same name and namespace in other branches
  1. 6.2 system_status_status.page.inc \system_status_status_page()

Return JSON formatted module information.

1 string reference to 'system_status_status_page'
system_status_menu in ./system_status.module
Implements hook_menu().

File

./system_status_status.page.inc, line 10
Logic for system_status output

Code

function system_status_status_page() {
  $system_modules = system_list('module_enabled');

  // Needless initialisation, but hey.
  $res = array(
    "core" => array(),
    "contrib" => array(),
    "custom" => array(),
  );
  foreach ($system_modules as $module => $module_info) {
    $filename = $module_info->filename;

    // Match for custom modules.
    if (variable_get('system_status_do_match_custom', '0')) {
      $regex = variable_get('system_status_preg_match_custom', '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/custom\\/*}');
      if (preg_match($regex, $filename)) {
        $res['custom'][$module] = array(
          "version" => $module_info->info['version'],
        );
      }
    }
    else {
      $res['custom'] = "disabled";
    }

    // Match for contrib modules.
    if (variable_get('system_status_do_match_contrib', '1')) {
      if (variable_get('system_status_match_contrib_mode', 0) == 0) {
        $regex = '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/*}';
      }
      elseif (variable_get('system_status_match_contrib_mode', 0) == 1) {
        $regex = '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/contrib\\/*}';
      }
      else {
        $regex = variable_get('system_status_preg_match_contrib', '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/contrib\\/*}');
      }
      if (preg_match($regex, $filename)) {
        $res['contrib'][$module] = array(
          "version" => $module_info->info['version'],
        );
      }
    }
    else {
      $res['contrib'] = "disabled";
    }

    // Core modules.
    if (variable_get('system_status_do_match_core', '1')) {
      if (strtolower($module_info->info['package']) == "core") {
        $res['core'][$module] = array(
          "version" => $module_info->info['version'],
        );
      }
    }
    else {
      $res['core'] = "disabled";
    }
  }
  if (variable_get('system_status_need_encryption', 0) == 1) {
    $res = SystemStatusEncryption::encrypt(drupal_json_encode(array(
      "system_status" => $res,
    )));
    drupal_json_output(array(
      "system_status" => "encrypted",
      "data" => $res,
    ));
  }
  else {
    drupal_json_output(array(
      "system_status" => $res,
    ));
  }
}