1 update.install _update_requirement_check($project, $type)

Fills in the requirements array.

This is shared for both core and contrib to generate the right elements in the array for hook_requirements().

Parameters

$project: Array of information about the project we're testing as returned by update_calculate_project_data().

$type: What kind of project this is ('core' or 'contrib').

Return value

An array to be included in the nested $requirements array.

See also

hook_requirements()

update_requirements()

update_calculate_project_data()

File

core/modules/update/update.install, line 106
Install, update, and uninstall functions for the Update Manager module.

Code

function _update_requirement_check($project, $type) {
  $requirement = array();
  if ($type == 'core') {
    $requirement['title'] = t('Backdrop CMS update status');
  }
  else {
    $requirement['title'] = t('Module, theme, and layout updates');
  }
  $status = $project['status'];
  if ($status != UPDATE_CURRENT) {
    $requirement['reason'] = $status;
    $requirement['description'] = _update_message_text($type, $status, TRUE);
    $requirement['severity'] = REQUIREMENT_ERROR;
  }
  switch ($status) {
    case UPDATE_NOT_SECURE:
      $requirement_label = t('Not secure!');
      break;
    case UPDATE_REVOKED:
      $requirement_label = t('Revoked!');
      break;
    case UPDATE_NOT_SUPPORTED:
      $requirement_label = t('Unsupported release');
      break;
    case UPDATE_NOT_CURRENT:
      $requirement_label = t('Out of date');
      $requirement['severity'] = REQUIREMENT_WARNING;
      break;
    case UPDATE_UNKNOWN:
    case UPDATE_NOT_CHECKED:
    case UPDATE_NOT_FETCHED:
    case UPDATE_FETCH_PENDING:
      $requirement_label = isset($project['reason']) ? $project['reason'] : t('Update information not available.');
      $requirement['severity'] = REQUIREMENT_INFO;
      break;
    case UPDATE_NOT_IMPLEMENTED:
      $text = t('Not yet implemented');
      $url = config_get('update.settings', 'update_not_implemented_url');
      $requirement['value'] = $url ? l($text, $url) : $text;
      $requirement['severity'] = REQUIREMENT_INFO;
      break;
    default:
      $requirement_label = t('Up to date');
  }
  if (isset($requirement_label)) {
    if ($status != UPDATE_CURRENT) {
      if ($type == 'core' && isset($project['recommended'])) {
        $version_available = t('version @version available', array('@version' => $project['recommended']));
      }
      else {
        $version_available = t('Updates available');
      }
      if (update_manager_access() && module_exists('installer')) {
        $requirement_label .= ' (' . l($version_available, 'admin/modules/update') . ')';
      }
      else {
        $requirement_label .= ' (' . l($version_available, 'admin/reports/updates') . ')';
      }
    }
    $requirement['value'] = $requirement_label;
  }
  return $requirement;
}