annotate modules/update/update.module @ 11:589fb7c02327 6.5

Drupal 6.5
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:32:19 +0100
parents c1f4ac30525a
children
rev   line source
webmaster@1 1 <?php
webmaster@11 2 // $Id: update.module,v 1.17.2.1 2008/09/23 10:19:02 goba Exp $
webmaster@1 3
webmaster@1 4 /**
webmaster@1 5 * @file
webmaster@1 6 * The "Update status" module checks for available updates of Drupal core and
webmaster@1 7 * any installed contributed modules and themes. It warns site administrators
webmaster@1 8 * if newer releases are available via the system status report
webmaster@1 9 * (admin/reports/status), the module and theme pages, and optionally via email.
webmaster@1 10 */
webmaster@1 11
webmaster@1 12 /**
webmaster@1 13 * URL to check for updates, if a given project doesn't define its own.
webmaster@1 14 */
webmaster@1 15 define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history');
webmaster@1 16
webmaster@1 17 // These are internally used constants for this code, do not modify.
webmaster@1 18
webmaster@1 19 /**
webmaster@1 20 * Project is missing security update(s).
webmaster@1 21 */
webmaster@1 22 define('UPDATE_NOT_SECURE', 1);
webmaster@1 23
webmaster@1 24 /**
webmaster@1 25 * Current release has been unpublished and is no longer available.
webmaster@1 26 */
webmaster@1 27 define('UPDATE_REVOKED', 2);
webmaster@1 28
webmaster@1 29 /**
webmaster@1 30 * Current release is no longer supported by the project maintainer.
webmaster@1 31 */
webmaster@1 32 define('UPDATE_NOT_SUPPORTED', 3);
webmaster@1 33
webmaster@1 34 /**
webmaster@1 35 * Project has a new release available, but it is not a security release.
webmaster@1 36 */
webmaster@1 37 define('UPDATE_NOT_CURRENT', 4);
webmaster@1 38
webmaster@1 39 /**
webmaster@1 40 * Project is up to date.
webmaster@1 41 */
webmaster@1 42 define('UPDATE_CURRENT', 5);
webmaster@1 43
webmaster@1 44 /**
webmaster@1 45 * Project's status cannot be checked.
webmaster@1 46 */
webmaster@1 47 define('UPDATE_NOT_CHECKED', -1);
webmaster@1 48
webmaster@1 49 /**
webmaster@1 50 * No available update data was found for project.
webmaster@1 51 */
webmaster@1 52 define('UPDATE_UNKNOWN', -2);
webmaster@1 53
webmaster@1 54
webmaster@1 55 /**
webmaster@1 56 * Implementation of hook_help().
webmaster@1 57 */
webmaster@1 58 function update_help($path, $arg) {
webmaster@1 59 switch ($path) {
webmaster@1 60 case 'admin/reports/updates':
webmaster@1 61 $output = '<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>';
webmaster@1 62 $output .= '<p>'. t('To extend the functionality or to change the look of your site, a number of contributed <a href="@modules">modules</a> and <a href="@themes">themes</a> are available.', array('@modules' => 'http://drupal.org/project/modules', '@themes' => 'http://drupal.org/project/themes')) .'</p>';
webmaster@1 63 return $output;
webmaster@1 64 case 'admin/build/themes':
webmaster@1 65 case 'admin/build/modules':
webmaster@1 66 include_once './includes/install.inc';
webmaster@1 67 $status = update_requirements('runtime');
webmaster@1 68 foreach (array('core', 'contrib') as $report_type) {
webmaster@1 69 $type = 'update_'. $report_type;
webmaster@1 70 if (isset($status[$type]['severity'])) {
webmaster@1 71 if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
webmaster@1 72 drupal_set_message($status[$type]['description'], 'error');
webmaster@1 73 }
webmaster@1 74 elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
webmaster@1 75 drupal_set_message($status[$type]['description'], 'warning');
webmaster@1 76 }
webmaster@1 77 }
webmaster@1 78 }
webmaster@1 79 return '<p>'. t('See the <a href="@available_updates">available updates</a> page for information on installed modules and themes with new versions released.', array('@available_updates' => url('admin/reports/updates'))) .'</p>';
webmaster@1 80
webmaster@1 81 case 'admin/reports/updates/settings':
webmaster@1 82 case 'admin/reports/status':
webmaster@1 83 // These two pages don't need additional nagging.
webmaster@1 84 break;
webmaster@1 85
webmaster@1 86 case 'admin/help#update':
webmaster@1 87 $output = '<p>'. t("The Update status module periodically checks for new versions of your site's software (including contributed modules and themes), and alerts you to available updates.") .'</p>';
webmaster@1 88 $output .= '<p>'. t('The <a href="@update-report">report of available updates</a> will alert you when new releases are available for download. You may configure options for update checking frequency and notifications at the <a href="@update-settings">Update status module settings page</a>.', array('@update-report' => url('admin/reports/updates'), '@update-settings' => url('admin/reports/updates/settings'))) .'</p>';
webmaster@1 89 $output .= '<p>'. t('Please note that in order to provide this information, anonymous usage statistics are sent to drupal.org. If desired, you may disable the Update status module from the <a href="@modules">module administration page</a>.', array('@modules' => url('admin/build/modules'))) .'</p>';
webmaster@1 90 $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@update">Update status module</a>.', array('@update' => 'http://drupal.org/handbook/modules/update')) .'</p>';
webmaster@1 91 return $output;
webmaster@1 92
webmaster@1 93 default:
webmaster@1 94 // Otherwise, if we're on *any* admin page and there's a security
webmaster@1 95 // update missing, print an error message about it.
webmaster@1 96 if (arg(0) == 'admin' && strpos($path, '#') === FALSE
webmaster@1 97 && user_access('administer site configuration')) {
webmaster@1 98 include_once './includes/install.inc';
webmaster@1 99 $status = update_requirements('runtime');
webmaster@1 100 foreach (array('core', 'contrib') as $report_type) {
webmaster@1 101 $type = 'update_'. $report_type;
webmaster@1 102 if (isset($status[$type])
webmaster@1 103 && isset($status[$type]['reason'])
webmaster@1 104 && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
webmaster@1 105 drupal_set_message($status[$type]['description'], 'error');
webmaster@1 106 }
webmaster@1 107 }
webmaster@1 108 }
webmaster@1 109
webmaster@1 110 }
webmaster@1 111 }
webmaster@1 112
webmaster@1 113 /**
webmaster@1 114 * Implementation of hook_menu().
webmaster@1 115 */
webmaster@1 116 function update_menu() {
webmaster@1 117 $items = array();
webmaster@1 118
webmaster@1 119 $items['admin/reports/updates'] = array(
webmaster@1 120 'title' => 'Available updates',
webmaster@1 121 'description' => 'Get a status report about available updates for your installed modules and themes.',
webmaster@1 122 'page callback' => 'update_status',
webmaster@1 123 'access arguments' => array('administer site configuration'),
webmaster@1 124 'file' => 'update.report.inc',
webmaster@1 125 'weight' => 10,
webmaster@1 126 );
webmaster@1 127 $items['admin/reports/updates/list'] = array(
webmaster@1 128 'title' => 'List',
webmaster@1 129 'page callback' => 'update_status',
webmaster@1 130 'access arguments' => array('administer site configuration'),
webmaster@1 131 'file' => 'update.report.inc',
webmaster@1 132 'type' => MENU_DEFAULT_LOCAL_TASK,
webmaster@1 133 );
webmaster@1 134 $items['admin/reports/updates/settings'] = array(
webmaster@1 135 'title' => 'Settings',
webmaster@1 136 'page callback' => 'drupal_get_form',
webmaster@1 137 'page arguments' => array('update_settings'),
webmaster@1 138 'access arguments' => array('administer site configuration'),
webmaster@1 139 'file' => 'update.settings.inc',
webmaster@1 140 'type' => MENU_LOCAL_TASK,
webmaster@1 141 );
webmaster@1 142 $items['admin/reports/updates/check'] = array(
webmaster@1 143 'title' => 'Manual update check',
webmaster@1 144 'page callback' => 'update_manual_status',
webmaster@1 145 'access arguments' => array('administer site configuration'),
webmaster@1 146 'file' => 'update.fetch.inc',
webmaster@1 147 'type' => MENU_CALLBACK,
webmaster@1 148 );
webmaster@1 149
webmaster@1 150 return $items;
webmaster@1 151 }
webmaster@1 152
webmaster@1 153 /**
webmaster@1 154 * Implementation of the hook_theme() registry.
webmaster@1 155 */
webmaster@1 156 function update_theme() {
webmaster@1 157 return array(
webmaster@1 158 'update_settings' => array(
webmaster@1 159 'arguments' => array('form' => NULL),
webmaster@1 160 ),
webmaster@1 161 'update_report' => array(
webmaster@1 162 'arguments' => array('data' => NULL),
webmaster@1 163 ),
webmaster@1 164 'update_version' => array(
webmaster@1 165 'arguments' => array('version' => NULL, 'tag' => NULL, 'class' => NULL),
webmaster@1 166 ),
webmaster@1 167 );
webmaster@1 168 }
webmaster@1 169
webmaster@1 170 /**
webmaster@1 171 * Implementation of hook_requirements.
webmaster@1 172 *
webmaster@1 173 * @return
webmaster@1 174 * An array describing the status of the site regarding available updates.
webmaster@1 175 * If there is no update data, only one record will be returned, indicating
webmaster@1 176 * that the status of core can't be determined. If data is available, there
webmaster@1 177 * will be two records: one for core, and another for all of contrib
webmaster@1 178 * (assuming there are any contributed modules or themes enabled on the
webmaster@1 179 * site). In addition to the fields expected by hook_requirements ('value',
webmaster@1 180 * 'severity', and optionally 'description'), this array will contain a
webmaster@1 181 * 'reason' attribute, which is an integer constant to indicate why the
webmaster@1 182 * given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or
webmaster@1 183 * UPDATE_UNKNOWN). This is used for generating the appropriate e-mail
webmaster@1 184 * notification messages during update_cron(), and might be useful for other
webmaster@1 185 * modules that invoke update_requirements() to find out if the site is up
webmaster@1 186 * to date or not.
webmaster@1 187 *
webmaster@1 188 * @see _update_message_text()
webmaster@1 189 * @see _update_cron_notify()
webmaster@1 190 */
webmaster@1 191 function update_requirements($phase) {
webmaster@1 192 if ($phase == 'runtime') {
webmaster@1 193 if ($available = update_get_available(FALSE)) {
webmaster@1 194 module_load_include('inc', 'update', 'update.compare');
webmaster@1 195 $data = update_calculate_project_data($available);
webmaster@1 196 // First, populate the requirements for core:
webmaster@1 197 $requirements['update_core'] = _update_requirement_check($data['drupal'], 'core');
webmaster@1 198 // We don't want to check drupal a second time.
webmaster@1 199 unset($data['drupal']);
webmaster@1 200 if (!empty($data)) {
webmaster@1 201 // Now, sort our $data array based on each project's status. The
webmaster@1 202 // status constants are numbered in the right order of precedence, so
webmaster@1 203 // we just need to make sure the projects are sorted in ascending
webmaster@1 204 // order of status, and we can look at the first project we find.
webmaster@1 205 uasort($data, '_update_project_status_sort');
webmaster@1 206 $first_project = reset($data);
webmaster@1 207 $requirements['update_contrib'] = _update_requirement_check($first_project, 'contrib');
webmaster@1 208 }
webmaster@1 209 }
webmaster@1 210 else {
webmaster@1 211 $requirements['update_core']['title'] = t('Drupal core update status');
webmaster@1 212 $requirements['update_core']['value'] = t('No update data available');
webmaster@1 213 $requirements['update_core']['severity'] = REQUIREMENT_WARNING;
webmaster@1 214 $requirements['update_core']['reason'] = UPDATE_UNKNOWN;
webmaster@1 215 $requirements['update_core']['description'] = _update_no_data();
webmaster@1 216 }
webmaster@1 217 return $requirements;
webmaster@1 218 }
webmaster@1 219 }
webmaster@1 220
webmaster@1 221 /**
webmaster@1 222 * Private helper method to fill in the requirements array.
webmaster@1 223 *
webmaster@1 224 * This is shared for both core and contrib to generate the right elements in
webmaster@1 225 * the array for hook_requirements().
webmaster@1 226 *
webmaster@1 227 * @param $project
webmaster@1 228 * Array of information about the project we're testing as returned by
webmaster@1 229 * update_calculate_project_data().
webmaster@1 230 * @param $type
webmaster@1 231 * What kind of project is this ('core' or 'contrib').
webmaster@1 232 *
webmaster@1 233 * @return
webmaster@1 234 * An array to be included in the nested $requirements array.
webmaster@1 235 *
webmaster@1 236 * @see hook_requirements()
webmaster@1 237 * @see update_requirements()
webmaster@1 238 * @see update_calculate_project_data()
webmaster@1 239 */
webmaster@1 240 function _update_requirement_check($project, $type) {
webmaster@1 241 $requirement = array();
webmaster@1 242 if ($type == 'core') {
webmaster@1 243 $requirement['title'] = t('Drupal core update status');
webmaster@1 244 }
webmaster@1 245 else {
webmaster@1 246 $requirement['title'] = t('Module and theme update status');
webmaster@1 247 }
webmaster@1 248 $status = $project['status'];
webmaster@1 249 if ($status != UPDATE_CURRENT) {
webmaster@1 250 $requirement['reason'] = $status;
webmaster@1 251 $requirement['description'] = _update_message_text($type, $status, TRUE);
webmaster@1 252 $requirement['severity'] = REQUIREMENT_ERROR;
webmaster@1 253 }
webmaster@1 254 switch ($status) {
webmaster@1 255 case UPDATE_NOT_SECURE:
webmaster@1 256 $requirement_label = t('Not secure!');
webmaster@1 257 break;
webmaster@1 258 case UPDATE_REVOKED:
webmaster@1 259 $requirement_label = t('Revoked!');
webmaster@1 260 break;
webmaster@1 261 case UPDATE_NOT_SUPPORTED:
webmaster@1 262 $requirement_label = t('Unsupported release');
webmaster@1 263 break;
webmaster@1 264 case UPDATE_NOT_CURRENT:
webmaster@1 265 $requirement_label = t('Out of date');
webmaster@1 266 $requirement['severity'] = variable_get('update_notification_threshold', 'all') == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING;
webmaster@1 267 break;
webmaster@1 268 case UPDATE_UNKNOWN:
webmaster@1 269 case UPDATE_NOT_CHECKED:
webmaster@1 270 $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status');
webmaster@1 271 $requirement['severity'] = REQUIREMENT_WARNING;
webmaster@1 272 break;
webmaster@1 273 default:
webmaster@1 274 $requirement_label = t('Up to date');
webmaster@1 275 }
webmaster@1 276 if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) {
webmaster@1 277 $requirement_label .= ' '. t('(version @version available)', array('@version' => $project['recommended']));
webmaster@1 278 }
webmaster@1 279 $requirement['value'] = l($requirement_label, 'admin/reports/updates');
webmaster@1 280 return $requirement;
webmaster@1 281 }
webmaster@1 282
webmaster@1 283 /**
webmaster@1 284 * Implementation of hook_cron().
webmaster@1 285 */
webmaster@1 286 function update_cron() {
webmaster@1 287 $frequency = variable_get('update_check_frequency', 1);
webmaster@1 288 $interval = 60 * 60 * 24 * $frequency;
webmaster@11 289 // Cron should check for updates if there is no update data cached or if the configured
webmaster@11 290 // update interval has elapsed.
webmaster@11 291 if (!cache_get('update_info', 'cache_update') || ((time() - variable_get('update_last_check', 0)) > $interval)) {
webmaster@1 292 update_refresh();
webmaster@1 293 _update_cron_notify();
webmaster@1 294 }
webmaster@1 295 }
webmaster@1 296
webmaster@1 297 /**
webmaster@1 298 * Implementation of hook_form_alter().
webmaster@1 299 *
webmaster@1 300 * Adds a submit handler to the system modules and themes forms, so that if a
webmaster@1 301 * site admin saves either form, we invalidate the cache of available updates.
webmaster@1 302 *
webmaster@1 303 * @see update_invalidate_cache()
webmaster@1 304 */
webmaster@1 305 function update_form_alter(&$form, $form_state, $form_id) {
webmaster@1 306 if ($form_id == 'system_modules' || $form_id == 'system_themes' ) {
webmaster@1 307 $form['#submit'][] = 'update_invalidate_cache';
webmaster@1 308 }
webmaster@1 309 }
webmaster@1 310
webmaster@1 311 /**
webmaster@1 312 * Prints a warning message when there is no data about available updates.
webmaster@1 313 */
webmaster@1 314 function _update_no_data() {
webmaster@1 315 $destination = drupal_get_destination();
webmaster@1 316 return t('No information is available about potential new releases for currently installed modules and themes. To check for updates, you may need to <a href="@run_cron">run cron</a> or you can <a href="@check_manually">check manually</a>. Please note that checking for available updates can take a long time, so please be patient.', array(
webmaster@1 317 '@run_cron' => url('admin/reports/status/run-cron', array('query' => $destination)),
webmaster@1 318 '@check_manually' => url('admin/reports/updates/check', array('query' => $destination)),
webmaster@1 319 ));
webmaster@1 320 }
webmaster@1 321
webmaster@1 322 /**
webmaster@1 323 * Internal helper to try to get the update information from the cache
webmaster@1 324 * if possible, and to refresh the cache when necessary.
webmaster@1 325 *
webmaster@1 326 * In addition to checking the cache lifetime, this function also ensures that
webmaster@1 327 * there are no .info files for enabled modules or themes that have a newer
webmaster@1 328 * modification timestamp than the last time we checked for available update
webmaster@1 329 * data. If any .info file was modified, it almost certainly means a new
webmaster@1 330 * version of something was installed. Without fresh available update data,
webmaster@1 331 * the logic in update_calculate_project_data() will be wrong and produce
webmaster@1 332 * confusing, bogus results.
webmaster@1 333 *
webmaster@1 334 * @param $refresh
webmaster@1 335 * Boolean to indicate if this method should refresh the cache automatically
webmaster@1 336 * if there's no data.
webmaster@1 337 *
webmaster@1 338 * @see update_refresh()
webmaster@1 339 * @see update_get_projects()
webmaster@1 340 */
webmaster@1 341 function update_get_available($refresh = FALSE) {
webmaster@1 342 module_load_include('inc', 'update', 'update.compare');
webmaster@1 343 $available = array();
webmaster@1 344
webmaster@1 345 // First, make sure that none of the .info files have a change time
webmaster@1 346 // newer than the last time we checked for available updates.
webmaster@1 347 $needs_refresh = FALSE;
webmaster@1 348 $last_check = variable_get('update_last_check', 0);
webmaster@1 349 $projects = update_get_projects();
webmaster@1 350 foreach ($projects as $key => $project) {
webmaster@1 351 if ($project['info']['_info_file_ctime'] > $last_check) {
webmaster@1 352 $needs_refresh = TRUE;
webmaster@1 353 break;
webmaster@1 354 }
webmaster@1 355 }
webmaster@1 356 if (!$needs_refresh && ($cache = cache_get('update_info', 'cache_update'))
webmaster@1 357 && $cache->expire > time()) {
webmaster@1 358 $available = $cache->data;
webmaster@1 359 }
webmaster@1 360 elseif ($needs_refresh || $refresh) {
webmaster@1 361 // If we need to refresh due to a newer .info file, ignore the argument
webmaster@1 362 // and force the refresh (e.g., even for update_requirements()) to prevent
webmaster@1 363 // bogus results.
webmaster@1 364 $available = update_refresh();
webmaster@1 365 }
webmaster@1 366 return $available;
webmaster@1 367 }
webmaster@1 368
webmaster@1 369 /**
webmaster@1 370 * Implementation of hook_flush_caches().
webmaster@1 371 *
webmaster@1 372 * The function update.php (among others) calls this hook to flush the caches.
webmaster@1 373 * Since we're running update.php, we are likely to install a new version of
webmaster@1 374 * something, in which case, we want to check for available update data again.
webmaster@1 375 */
webmaster@1 376 function update_flush_caches() {
webmaster@1 377 return array('cache_update');
webmaster@1 378 }
webmaster@1 379
webmaster@1 380 /**
webmaster@1 381 * Invalidates any cached data relating to update status.
webmaster@1 382 */
webmaster@1 383 function update_invalidate_cache() {
webmaster@1 384 cache_clear_all('*', 'cache_update', TRUE);
webmaster@1 385 }
webmaster@1 386
webmaster@1 387 /**
webmaster@1 388 * Wrapper to load the include file and then refresh the release data.
webmaster@1 389 */
webmaster@1 390 function update_refresh() {
webmaster@1 391 module_load_include('inc', 'update', 'update.fetch');
webmaster@1 392 return _update_refresh();
webmaster@1 393 }
webmaster@1 394
webmaster@1 395 /**
webmaster@1 396 * Implementation of hook_mail().
webmaster@1 397 *
webmaster@1 398 * Constructs the email notification message when the site is out of date.
webmaster@1 399 *
webmaster@1 400 * @param $key
webmaster@1 401 * Unique key to indicate what message to build, always 'status_notify'.
webmaster@1 402 * @param $message
webmaster@1 403 * Reference to the message array being built.
webmaster@1 404 * @param $params
webmaster@1 405 * Array of parameters to indicate what kind of text to include in the
webmaster@1 406 * message body. This is a keyed array of message type ('core' or 'contrib')
webmaster@1 407 * as the keys, and the status reason constant (UPDATE_NOT_SECURE, etc) for
webmaster@1 408 * the values.
webmaster@1 409 *
webmaster@1 410 * @see drupal_mail()
webmaster@1 411 * @see _update_cron_notify()
webmaster@1 412 * @see _update_message_text()
webmaster@1 413 */
webmaster@1 414 function update_mail($key, &$message, $params) {
webmaster@1 415 $language = $message['language'];
webmaster@1 416 $langcode = $language->language;
webmaster@1 417 $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), $langcode);
webmaster@1 418 foreach ($params as $msg_type => $msg_reason) {
webmaster@1 419 $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language);
webmaster@1 420 }
webmaster@1 421 $message['body'][] = t('See the available updates page for more information:', array(), $langcode) ."\n". url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language));
webmaster@1 422 }
webmaster@1 423
webmaster@1 424 /**
webmaster@1 425 * Helper function to return the appropriate message text when the site is out
webmaster@1 426 * of date or missing a security update.
webmaster@1 427 *
webmaster@1 428 * These error messages are shared by both update_requirements() for the
webmaster@1 429 * site-wide status report at admin/reports/status and in the body of the
webmaster@1 430 * notification emails generated by update_cron().
webmaster@1 431 *
webmaster@1 432 * @param $msg_type
webmaster@1 433 * String to indicate what kind of message to generate. Can be either
webmaster@1 434 * 'core' or 'contrib'.
webmaster@1 435 * @param $msg_reason
webmaster@1 436 * Integer constant specifying why message is generated.
webmaster@1 437 * @param $report_link
webmaster@1 438 * Boolean that controls if a link to the updates report should be added.
webmaster@1 439 * @param $language
webmaster@1 440 * An optional language object to use.
webmaster@1 441 * @return
webmaster@1 442 * The properly translated error message for the given key.
webmaster@1 443 */
webmaster@1 444 function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) {
webmaster@1 445 $langcode = isset($language) ? $language->language : NULL;
webmaster@1 446 $text = '';
webmaster@1 447 switch ($msg_reason) {
webmaster@1 448 case UPDATE_NOT_SECURE:
webmaster@1 449 if ($msg_type == 'core') {
webmaster@1 450 $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), $langcode);
webmaster@1 451 }
webmaster@1 452 else {
webmaster@1 453 $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), $langcode);
webmaster@1 454 }
webmaster@1 455 break;
webmaster@1 456
webmaster@1 457 case UPDATE_REVOKED:
webmaster@1 458 if ($msg_type == 'core') {
webmaster@1 459 $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), $langcode);
webmaster@1 460 }
webmaster@1 461 else {
webmaster@1 462 $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), $langcode);
webmaster@1 463 }
webmaster@1 464 break;
webmaster@1 465
webmaster@1 466 case UPDATE_NOT_SUPPORTED:
webmaster@1 467 if ($msg_type == 'core') {
webmaster@1 468 $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), $langcode);
webmaster@1 469 }
webmaster@1 470 else {
webmaster@1 471 $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended! Please see the project homepage for more details.', array(), $langcode);
webmaster@1 472 }
webmaster@1 473 break;
webmaster@1 474
webmaster@1 475 case UPDATE_NOT_CURRENT:
webmaster@1 476 if ($msg_type == 'core') {
webmaster@1 477 $text = 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.', array(), $langcode);
webmaster@1 478 }
webmaster@1 479 else {
webmaster@1 480 $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode);
webmaster@1 481 }
webmaster@1 482 break;
webmaster@1 483
webmaster@1 484 case UPDATE_UNKNOWN:
webmaster@1 485 case UPDATE_NOT_CHECKED:
webmaster@1 486 if ($msg_type == 'core') {
webmaster@1 487 $text = t('There was a problem determining the status of available updates for your version of Drupal.', array(), $langcode);
webmaster@1 488 }
webmaster@1 489 else {
webmaster@1 490 $text = t('There was a problem determining the status of available updates for one or more of your modules or themes.', array(), $langcode);
webmaster@1 491 }
webmaster@1 492 break;
webmaster@1 493 }
webmaster@1 494
webmaster@1 495 if ($report_link) {
webmaster@1 496 $text .= ' '. t('See the <a href="@available_updates">available updates</a> page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), $langcode);
webmaster@1 497 }
webmaster@1 498
webmaster@1 499 return $text;
webmaster@1 500 }
webmaster@1 501
webmaster@1 502 /**
webmaster@1 503 * Private sort function to order projects based on their status.
webmaster@1 504 *
webmaster@1 505 * @see update_requirements()
webmaster@1 506 * @see uasort()
webmaster@1 507 */
webmaster@1 508 function _update_project_status_sort($a, $b) {
webmaster@1 509 // The status constants are numerically in the right order, so we can
webmaster@1 510 // usually subtract the two to compare in the order we want. However,
webmaster@1 511 // negative status values should be treated as if they are huge, since we
webmaster@1 512 // always want them at the bottom of the list.
webmaster@1 513 $a_status = $a['status'] > 0 ? $a['status'] : (-10 * $a['status']);
webmaster@1 514 $b_status = $b['status'] > 0 ? $b['status'] : (-10 * $b['status']);
webmaster@1 515 return $a_status - $b_status;
webmaster@1 516 }