You are here

function security_review_requirements in Security Review 7

Same name and namespace in other branches
  1. 8 security_review.install \security_review_requirements()

Implements hook_requirements().

File

./security_review.install, line 85
Install, update and uninstall functions for the security_review module.

Code

function security_review_requirements($phase) {
  $requirements = array();
  switch ($phase) {
    case 'runtime':
      $failed_checks = FALSE;
      $checks = security_review_get_stored_results();
      foreach ($checks as $check) {
        if ($check['result'] === FALSE && !$check['skip']) {
          $failed_checks = TRUE;
          break;
        }
      }
      $url = url('admin/reports/security-review');
      if (empty($checks)) {
        $severity = REQUIREMENT_WARNING;
        $value = t('The Security Review checklist has not been run. <a href="!url">Run the checklist</a>', array(
          '!url' => $url,
        ));
      }
      elseif ($failed_checks) {
        $severity = REQUIREMENT_WARNING;
        $value = t('There are failed Security Review checks. <a href="!url">Review the checklist</a>', array(
          '!url' => $url,
        ));
      }
      else {
        $severity = REQUIREMENT_OK;
        $value = t('Passing all non-ignored Security Review checks. <a href="!url">Review the checklist</a>', array(
          '!url' => $url,
        ));
      }
      $requirements['security_review'] = array(
        'title' => t('Security Review'),
        'severity' => $severity,
        'value' => $value,
      );
      break;
  }
  return $requirements;
}