You are here

function update_init in Drupal 7

Implements hook_init().

File

modules/update/update.module, line 111
Handles updates of Drupal core and contributed projects.

Code

function update_init() {
  if (arg(0) == 'admin' && user_access('administer site configuration')) {
    switch ($_GET['q']) {

      // These pages don't need additional nagging.
      case 'admin/appearance/update':
      case 'admin/appearance/install':
      case 'admin/modules/update':
      case 'admin/modules/install':
      case 'admin/reports/updates':
      case 'admin/reports/updates/update':
      case 'admin/reports/updates/install':
      case 'admin/reports/updates/settings':
      case 'admin/reports/status':
      case 'admin/update/ready':
        return;

      // If we are on the appearance or modules list, display a detailed report
      // of the update status.
      case 'admin/appearance':
      case 'admin/modules':
        $verbose = TRUE;
        break;
    }
    module_load_install('update');
    $status = update_requirements('runtime');
    foreach (array(
      'core',
      'contrib',
    ) as $report_type) {
      $type = 'update_' . $report_type;
      if (!empty($verbose)) {
        if (isset($status[$type]['severity'])) {
          if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
            drupal_set_message($status[$type]['description'], 'error', FALSE);
          }
          elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
            drupal_set_message($status[$type]['description'], 'warning', FALSE);
          }
        }
      }
      else {
        if (isset($status[$type]) && isset($status[$type]['reason']) && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
          drupal_set_message($status[$type]['description'], 'error', FALSE);
        }
      }
    }
  }
}