1 update.module update_init()

Implements hook_init().

File

core/modules/update/update.module, line 72
Handles update checking for Backdrop 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':
      case 'admin/structure/layouts':
        $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) {
            backdrop_set_message($status[$type]['description'], 'error', FALSE);
          }
          elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
            backdrop_set_message($status[$type]['description'], 'warning', FALSE);
          }
        }
      }
      // Otherwise, if we're on *any* admin page and there's a security
      // update missing, print an error message about it.
      else {
        if (isset($status[$type])
         && isset($status[$type]['reason'])
           && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
          backdrop_set_message($status[$type]['description'], 'error', FALSE);
        }
      }
    }
  }
}