// These are internally used constants for this code, do not modify.
/**
* Project is missing security update(s).
*/
define('UPDATE_NOT_SECURE', 1);
/**
* Current release has been unpublished and is no longer available.
*/
define('UPDATE_REVOKED', 2);
/**
* Current release is no longer supported by the project maintainer.
*/
define('UPDATE_NOT_SUPPORTED', 3);
/**
* Project has a new release available, but it is not a security release.
*/
define('UPDATE_NOT_CURRENT', 4);
/**
* Project is up to date.
*/
define('UPDATE_CURRENT', 5);
/**
* Project's status cannot be checked.
*/
define('UPDATE_NOT_CHECKED', -1);
/**
* No available update data was found for project.
*/
define('UPDATE_UNKNOWN', -2);
/**
* Implementation of hook_help().
*/
function update_help($path, $arg) {
switch ($path) {
case 'admin/reports/updates':
$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>';
$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>';
return $output;
case 'admin/build/themes':
case 'admin/build/modules':
include_once './includes/install.inc';
$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) {
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>';
case 'admin/reports/updates/settings':
case 'admin/reports/status':
// These two pages don't need additional nagging.
break;
case 'admin/help#update':
$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>';
$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>';
$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>';
$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>';
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')) {
include_once './includes/install.inc';
$status = update_requirements('runtime');
foreach (array('core', 'contrib') as $report_type) {
if (time() - variable_get('update_last_check', 0) > $interval) {
update_refresh();
_update_cron_notify();
}
}
/**
* Implementation of hook_form_alter().
*
* Adds a submit handler to the system modules and themes forms, so that if a
* site admin saves either form, we invalidate the cache of available updates.
*
* @see update_invalidate_cache()
*/
function update_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'system_modules' || $form_id == 'system_themes' ) {
$form['#submit'][] = 'update_invalidate_cache';
}
}
/**
* Prints a warning message when there is no data about available updates.
*/
function _update_no_data() {
$destination = drupal_get_destination();
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(
$message['body'][] = t('See the available updates page for more information:', array(), $langcode) ."\n". url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language));
}
/**
* Helper function to return the appropriate message text when the site is out
* of date or missing a security update.
*
* These error messages are shared by both update_requirements() for the
* site-wide status report at admin/reports/status and in the body of the
* notification emails generated by update_cron().
*
* @param $msg_type
* String to indicate what kind of message to generate. Can be either
* 'core' or 'contrib'.
* @param $msg_reason
* Integer constant specifying why message is generated.
* @param $report_link
* Boolean that controls if a link to the updates report should be added.
* @param $language
* An optional language object to use.
* @return
* The properly translated error message for the given key.
*/
function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) {
$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);
}
else {
$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);
}
break;
case UPDATE_REVOKED:
if ($msg_type == 'core') {
$text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), $langcode);
}
else {
$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);
}
break;
case UPDATE_NOT_SUPPORTED:
if ($msg_type == 'core') {
$text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), $langcode);
}
else {
$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);
}
break;
case UPDATE_NOT_CURRENT:
if ($msg_type == 'core') {
$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);
}
else {
$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);
}
break;
case UPDATE_UNKNOWN:
case UPDATE_NOT_CHECKED:
if ($msg_type == 'core') {
$text = t('There was a problem determining the status of available updates for your version of Drupal.', array(), $langcode);
}
else {
$text = t('There was a problem determining the status of available updates for one or more of your modules or themes.', array(), $langcode);
}
break;
}
if ($report_link) {
$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);
}
return $text;
}
/**
* Private sort function to order projects based on their status.
*
* @see update_requirements()
* @see uasort()
*/
function _update_project_status_sort($a, $b) {
// The status constants are numerically in the right order, so we can
// usually subtract the two to compare in the order we want. However,
// negative status values should be treated as if they are huge, since we