Index: modules/update_status/update_status.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_status/update_status.module,v retrieving revision 1.75 diff -u -p -r1.75 update_status.module --- modules/update_status/update_status.module 26 Jun 2007 09:12:34 -0000 1.75 +++ modules/update_status/update_status.module 26 Jun 2007 22:33:10 -0000 @@ -9,12 +9,11 @@ define('UPDATE_STATUS_CORE_VERSION', '5. define('UPDATE_STATUS_DEFAULT_URL', 'http://updates.drupal.org/files/release-history'); // These are internally used constants for this code, do not modify. -define('UPDATE_STATUS_CURRENT', 1); -define('UPDATE_STATUS_NOT_CURRENT', 2); -define('UPDATE_STATUS_UNKNOWN', 3); -define('UPDATE_STATUS_NOT_CHECKED', 4); -define('UPDATE_STATUS_CANT_CHECK', 5); -define('UPDATE_STATUS_HAVE_NEWER', 6); +define('UPDATE_STATUS_CURRENT', 1); // Up to date. +define('UPDATE_STATUS_NOT_SECURE', 2); // Missing security update(s). +define('UPDATE_STATUS_NOT_CURRENT', 3); // New available, but not security. +define('UPDATE_STATUS_NOT_CHECKED', 4); // Can't compare for some reason. +define('UPDATE_STATUS_UNKNOWN', 5); // No available update data. /** * Implementation of hook_help(). @@ -30,12 +29,15 @@ function update_status_help($section) { case 'admin/build/modules': include_once './includes/install.inc'; $status = update_status_requirements('runtime'); - if (isset($status['update_status']['severity'])) { - if ($status['update_status']['severity'] == REQUIREMENT_ERROR) { - drupal_set_message(t('There are updates available for one or more of your modules. To ensure the security of your server, you should update immediately. See the !available_updates page for more information', array('!available_updates' => l(t('available updates'), 'admin/logs/updates'))), 'error'); - } - elseif ($status['update_status']['severity'] == REQUIREMENT_WARNING) { - drupal_set_message($status['update_status']['description']); + $types = array('update_status_drupal', 'update_status'); + foreach ($types as $type) { + if (isset($status[$type]['severity'])) { + if ($status[$type]['severity'] == REQUIREMENT_ERROR) { + drupal_set_message($status[$type]['description'], 'error'); + } + elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) { + drupal_set_message($status[$type]['description']); + } } } return '

'. t('See the !available_updates page for information on installed modules with new versions released.', array('!available_updates' => l(t('available updates'), 'admin/logs/updates'))) .'

'; @@ -242,28 +244,48 @@ function update_status_requirements($pha if ($phase == 'runtime') { $requirements['update_status']['title'] = t('Module update status'); $requirements['update_status_drupal']['title'] = t('Drupal core update status'); + $warning_level = variable_get('update_status_warning_threshold', 'all'); if ($avail = update_status_get_available(FALSE)) { $data = update_status_calculate_project_data($avail); - if ($data['drupal']['status'] == UPDATE_STATUS_NOT_CURRENT) { - $requirements['update_status_drupal']['value'] = t('Out of date. Version @version available.', array('@version' => $avail['drupal']['recommended'])); - $requirements['update_status_drupal']['severity'] = REQUIREMENT_ERROR; - $requirements['update_status_drupal']['description'] = t('There are updates available for your version of Drupal. To ensure the security of your server, you should update immediately.See the !status_page for more information', array('!status_page' => l('update status page', 'admin/logs/updates'))); - } - else { - $requirements['update_status_drupal']['value'] = t('Up to date'); + switch ($data['drupal']['status']) { + case UPDATE_STATUS_NOT_CURRENT: + $requirements['update_status_drupal']['value'] = t('Out of date (version @version available)', array('@version' => $data['drupal']['recommended'])); + $requirements['update_status_drupal']['severity'] = $warning_level == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; + $requirements['update_status_drupal']['description'] = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible. See the !available_updates page for more information.', array('!available_updates' => l('available updates', 'admin/logs/updates'))); + break; + + case UPDATE_STATUS_NOT_SECURE: + $requirements['update_status_drupal']['value'] = t('Not secure! (version @version available)', array('@version' => $data['drupal']['recommended'])); + $requirements['update_status_drupal']['severity'] = REQUIREMENT_ERROR; + $requirements['update_status_drupal']['description'] = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately. See the !available_updates page for more information.', array('!available_updates' => l('available updates', 'admin/logs/updates'))); + break; + + default: + $requirements['update_status_drupal']['value'] = t('Up to date'); + break; } // We don't want to check drupal a second time. unset($data['drupal']); $requirements['update_status']['value'] = t('Up to date'); + $not_current = FALSE; foreach (array_keys($data) as $project) { - if (isset($avail[$project]) && - $data[$project]['status'] == UPDATE_STATUS_NOT_CURRENT) { - $requirements['update_status']['value'] = t('Out of date'); - $requirements['update_status']['severity'] = REQUIREMENT_ERROR; - $requirements['update_status']['description'] = t('There are updates available for one or more of your modules. To ensure the security of your server, you should update immediately. See the !status_page for more information', array('!status_page' => l('update status page', 'admin/logs/updates'))); - break; + if (isset($avail[$project])) { + if ($data[$project]['status'] == UPDATE_STATUS_NOT_SECURE) { + $requirements['update_status']['value'] = t('Not secure!'); + $requirements['update_status']['severity'] = REQUIREMENT_ERROR; + $requirements['update_status']['description'] = t('There are security updates available for one or more of your modules. To ensure the security of your server, you should update immediately. See the !available_updates page for more information.', array('!available_updates' => l('available updates', 'admin/logs/updates'))); + break; + } + elseif ($data[$project]['status'] == UPDATE_STATUS_NOT_CURRENT) { + $not_current = TRUE; + } } } + if (!isset($requirements['update_status']['severity']) && $not_current) { + $requirements['update_status']['severity'] = $warning_level == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; + $requirements['update_status']['value'] = t('Out of date'); + $requirements['update_status']['description'] = t('There are updates available for one or more of your modules. To ensure the proper functioning of your site, you should update as soon as possible. See the !available_updates page for more information.', array('!available_updates' => l('available updates', 'admin/logs/updates'))); + } } else { $requirements['update_status']['value'] = t('No update data available'); @@ -619,10 +641,15 @@ function update_status_calculate_project // differences between the datestamp in the .info file and the // timestamp of the tarball itself (which are usually off by 1 or 2 // seconds) so that we don't flag that as a new release. - if ($projects[$project]['type'] == 'dev' && isset($release['date']) - && isset($projects[$project]['datestamp']) - && ($projects[$project]['datestamp'] + 100 > $release['date'])) { - continue; + if ($projects[$project]['type'] == 'dev') { + if (empty($projects[$project]['datestamp'])) { + // We don't have current timestamp info, so we can't know. + continue; + } + elseif (isset($release['date']) && ($projects[$project]['datestamp'] + 100 > $release['date'])) { + // We're newer than this, so we can skip it. + continue; + } } // See if this release is a security update. @@ -686,17 +713,18 @@ function update_status_calculate_project if ($projects[$project]['existing_version'] == $projects[$project]['recommended'] || $projects[$project]['existing_version'] == $projects[$project]['latest_version']) { $projects[$project]['status'] = UPDATE_STATUS_CURRENT; } - elseif ($warning_level == 'security' && empty($projects[$project]['security updates'])) { - $projects[$project]['status'] = UPDATE_STATUS_NOT_CHECKED; - $projects[$project]['reason'] = t('Not a security update'); - } else { - $projects[$project]['status'] = UPDATE_STATUS_NOT_CURRENT; + if (!empty($projects[$project]['security updates'])) { + $projects[$project]['status'] = UPDATE_STATUS_NOT_SECURE; + } + else { + $projects[$project]['status'] = UPDATE_STATUS_NOT_CURRENT; + } } break; case 'dev': if (!empty($projects[$project]['security updates'])) { - $projects[$project]['status'] = UPDATE_STATUS_NOT_CURRENT; + $projects[$project]['status'] = UPDATE_STATUS_NOT_SECURE; break; } @@ -708,10 +736,6 @@ function update_status_calculate_project elseif (($projects[$project]['datestamp'] + 100 > $latest['date'])) { $projects[$project]['status'] = UPDATE_STATUS_CURRENT; } - elseif ($warning_level == 'security') { - $projects[$project]['status'] = UPDATE_STATUS_NOT_CHECKED; - $projects[$project]['reason'] = t('Not a security update'); - } else { $projects[$project]['status'] = UPDATE_STATUS_NOT_CURRENT; } @@ -749,18 +773,25 @@ function theme_update_status_report($dat $header = array(); $rows = array(); + $warning_level = variable_get('update_status_warning_threshold', 'all'); + foreach ($data as $project) { switch ($project['status']) { - case UPDATE_STATUS_NOT_CURRENT: - $class = 'error'; - $icon = theme('image', 'misc/watchdog-error.png'); - break; case UPDATE_STATUS_CURRENT: $class = 'ok'; $icon = theme('image', 'misc/watchdog-ok.png'); break; + case UPDATE_STATUS_NOT_SECURE: + case UPDATE_STATUS_NOT_CURRENT: + if ($warning_level == 'all' + || $project['status'] == UPDATE_STATUS_NOT_SECURE) { + $class = 'error'; + $icon = theme('image', 'misc/watchdog-error.png'); + break; + } + // Otherwise, fall through and use the warning class/icon. default: - $class = 'unknown'; + $class = 'warning'; $icon = theme('image', 'misc/watchdog-warning.png'); break; } @@ -770,14 +801,18 @@ function theme_update_status_report($dat case UPDATE_STATUS_CURRENT: $row .= t('Up to date'); break; + case UPDATE_STATUS_NOT_SECURE: + $row .= ''; + $row .= t('Security update required!'); + $row .= ''; + break; case UPDATE_STATUS_NOT_CURRENT: - if (!empty($project['security updates'])) { - $row .= ''. t('Security update required!') .''; - } - else { + if ($warning_level == 'all') { $row .= t('Update available'); + break; } - break; + // Otherwise, fall through and just ignore this project. + $project['reason'] = t('Not a security update'); default: $row .= t('Ignored'); $row .= ' ('. $project['reason'] .')'; Index: modules/update_status/update_status.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_status/update_status.css,v retrieving revision 1.17 diff -u -p -r1.17 update_status.css --- modules/update_status/update_status.css 26 Jun 2007 08:59:28 -0000 1.17 +++ modules/update_status/update_status.css 26 Jun 2007 22:33:10 -0000 @@ -39,11 +39,11 @@ background: #dfd; } -.update-status tr.unknown { +.update-status tr.warning { background: #ffd; } -.update-status tr.unknown .version-recommended { +.update-status tr.warning .version-recommended { background: #ffe; }