You are here

function nagios_updates in Nagios Monitoring 6

Same name and namespace in other branches
  1. 8 nagios.drush.inc \nagios_updates()
  2. 7 nagios.drush.inc \nagios_updates()

Helper function for drush_nagios_updates().

1 call to nagios_updates()
drush_nagios_updates in ./nagios.drush.inc
Drush command callback: nagios-updates.
1 string reference to 'nagios_updates'
nagios_uninstall in ./nagios.install

File

./nagios.drush.inc, line 160

Code

function nagios_updates($data) {
  if (!is_array($data)) {
    return NULL;
  }
  $updates = array();

  // Create an array of status values keyed by module or theme name, since
  // we'll need this while generating the report if we have to cross reference
  // anything (e.g. subthemes which have base themes missing an update).
  foreach ($data as $project) {
    foreach ($project['includes'] as $key => $name) {
      $status[$key] = $project['status'];
    }
  }
  foreach ($data as $project) {
    if ($project['status'] == UPDATE_NOT_SECURE || $project['status'] == UPDATE_NOT_CURRENT) {
      $security_class = array();
      $version_class = array();
      if (isset($project['recommended'])) {
        if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) {

          // First, figure out what to recommend.
          // If there's only 1 security update and it has the same version we're
          // recommending, give it the same CSS class as if it was recommended,
          // but don't print out a separate "Recommended" line for this project.
          if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] === $project['recommended']) {
            $security_class[] = 'version-recommended';
            $security_class[] = 'version-recommended-strong';
          }
          else {
            $version_class[] = 'version-recommended';

            // Apply an extra class if we're displaying both a recommended
            // version and anything else for an extra visual hint.
            if ($project['recommended'] !== $project['latest_version'] || !empty($project['also']) || $project['install_type'] == 'dev' && isset($project['dev_version']) && $project['latest_version'] !== $project['dev_version'] && $project['recommended'] !== $project['dev_version'] || isset($project['security updates'][0]) && $project['recommended'] !== $project['security updates'][0]) {
              $version_class[] = 'version-recommended-strong';
            }
          }
        }
      }
      $row_key = drupal_strtolower($project['name']);
      if (!isset($updates[$row_key])) {
        $updates[$row_key] = array();
      }
      $updates[$row_key]['type'] = $project['project_type'];
      $updates[$row_key]['status'] = $project['status'];
    }
  }
  return $updates;
}