From 933bc80411b70b298ddc66d4f742a96a9fcf2fab Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Mon, 4 Oct 2010 18:04:52 +0000 Subject: [PATCH] - Patch #931284 by dww: update status admin UI shouldn't rely on hook_help(). --- modules/update/update.module | 61 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/modules/update/update.module b/modules/update/update.module index 1704fdfff11c..42aacc374049 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -79,22 +79,6 @@ function update_help($path, $arg) { case 'admin/reports/updates': return '<p>' . t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include multiple modules or themes within it.') . '</p>'; - case 'admin/appearance': - case 'admin/modules': - module_load_install('update'); - $status = update_requirements('runtime'); - foreach (array('core', 'contrib') as $report_type) { - $type = 'update_' . $report_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'], 'warning'); - } - } - } - case 'admin/appearance/update': case 'admin/appearance/install': case 'admin/modules/update': @@ -128,23 +112,44 @@ function update_help($path, $arg) { } $output .= '</dl>'; return $output; + } +} - default: - // Otherwise, if we're on *any* admin page and there's a security - // update missing, print an error message about it. - if (arg(0) == 'admin' && strpos($path, '#') === FALSE - && user_access('administer site configuration')) { - module_load_install('update'); - $status = update_requirements('runtime'); - foreach (array('core', 'contrib') as $report_type) { - $type = 'update_' . $report_type; - if (isset($status[$type]) - && isset($status[$type]['reason']) - && $status[$type]['reason'] === UPDATE_NOT_SECURE) { +/** + * Implements hook_init(). + */ +function update_init() { + if (arg(0) == 'admin' && user_access('administer site configuration')) { + module_load_install('update'); + $status = update_requirements('runtime'); + + // If we are on the appearance or modules list, display a detailed report + // of the update status. + if (arg(1) == 'appearance' || arg(1) == 'modules') { + foreach (array('core', 'contrib') as $report_type) { + $type = 'update_' . $report_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'], 'warning'); + } } } + } + else { + // Otherwise, if we're on *any* admin page and there's a security + // update missing, print an error message about it. + foreach (array('core', 'contrib') as $report_type) { + $type = 'update_' . $report_type; + if (isset($status[$type]) + && isset($status[$type]['reason']) + && $status[$type]['reason'] === UPDATE_NOT_SECURE) { + drupal_set_message($status[$type]['description'], 'error'); + } + } + } } } -- GitLab