You are here

function _update_status_requirement_check in Update Status 5.2

Private helper method to fill 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_status_calculate_project_data().

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

Return value

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

See also

hook_requirements()

update_status_requirements()

update_status_calculate_project_data()

1 call to _update_status_requirement_check()
update_status_requirements in ./update_status.module
Implementation of hook_requirements.

File

./update_status.module, line 469

Code

function _update_status_requirement_check($project, $type) {
  $requirement = array();
  if ($type == 'core') {
    $requirement['title'] = t('Drupal core update status');
  }
  else {
    $requirement['title'] = t('Module update status');
  }
  $status = $project['status'];
  if ($status != UPDATE_STATUS_CURRENT) {
    $requirement['reason'] = $status;
    $requirement['description'] = _update_status_message_text($type, $status, TRUE);
    $requirement['severity'] = REQUIREMENT_ERROR;
  }
  switch ($status) {
    case UPDATE_STATUS_NOT_SECURE:
      $requirement_label = t('Not secure!');
      break;
    case UPDATE_STATUS_REVOKED:
      $requirement_label = t('Revoked!');
      break;
    case UPDATE_STATUS_NOT_SUPPORTED:
      $requirement_label = t('Unsupported release');
      break;
    case UPDATE_STATUS_NOT_CURRENT:
      $requirement_label = t('Out of date');
      $requirement['severity'] = REQUIREMENT_WARNING;
      break;
    case UPDATE_STATUS_UNKNOWN:
    case UPDATE_STATUS_NOT_CHECKED:
    case UPDATE_STATUS_NOT_FETCHED:
      $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status');
      $requirement['severity'] = REQUIREMENT_WARNING;
      break;
    default:
      $requirement_label = t('Up to date');
  }
  if ($status != UPDATE_STATUS_CURRENT && $type == 'core' && isset($project['recommended'])) {
    $requirement_label .= ' ' . t('(version @version available)', array(
      '@version' => $project['recommended'],
    ));
  }
  $requirement['value'] = l($requirement_label, 'admin/logs/updates');
  return $requirement;
}