You are here

function security_review_reviewed in Security Review 7

Same name and namespace in other branches
  1. 6 security_review.module \security_review_reviewed()
1 call to security_review_reviewed()
security_review_page in ./security_review.pages.inc
Page callback for run & review.

File

./security_review.pages.inc, line 37
security_review.pages.inc

Code

function security_review_reviewed($checklist, $checks, $namespace = NULL) {
  $items = array();
  $last_run = variable_get('security_review_last_run', '');
  $date = !empty($last_run) ? format_date($last_run) : '';
  $header = t('Review results from last run !date', array(
    '!date' => $date,
  ));
  $desc = t("Here you can review the results from the last run of the checklist. Checks are not always perfectly correct in their procedure and result. You can keep a check from running by clicking the 'Skip' link beside it. You can run the checklist again by expanding the fieldset above.");
  foreach ($checks as $check) {

    // Skip this iteration if the result has no matching item in the checklist.
    if (!isset($checklist[$check['namespace']][$check['reviewcheck']])) {
      continue;
    }
    $message = $check['result'] ? $checklist[$check['namespace']][$check['reviewcheck']]['success'] : $checklist[$check['namespace']][$check['reviewcheck']]['failure'];
    $title = $check['result'] ? t('OK') : t('Error');
    $class = $check['skip'] ? 'info' : ($check['result'] ? 'ok' : 'error');
    $toggle = $check['skip'] ? t('Enable') : t('Skip');
    $token = drupal_get_token($check['reviewcheck']);
    $link_options = array(
      'query' => array(
        'token' => $token,
      ),
    );
    $items[] = array(
      'title' => $title,
      'value' => $check['result'],
      'class' => $class,
      'message' => $message,
      'help_link' => l(t('Details'), 'admin/reports/security-review/help/' . $check['namespace'] . '/' . $check['reviewcheck']),
      'toggle_link' => l($toggle, 'admin/reports/security-review/toggle/nojs/' . $check['reviewcheck'], $link_options),
    );
  }
  $output = theme('security_review_reviewed', array(
    'items' => $items,
    'header' => $header,
    'description' => $desc,
  ));

  // @todo #markup?
  return array(
    '#markup' => $output,
  );
}