You are here

function security_review_check_help in Security Review 7

Same name and namespace in other branches
  1. 6 security_review.module \security_review_check_help()

Page callback provides general help and check specific help documentation.

1 string reference to 'security_review_check_help'
security_review_menu in ./security_review.module
Implements hook_menu().

File

./security_review.pages.inc, line 350
security_review.pages.inc

Code

function security_review_check_help($module = NULL, $check_name = NULL) {

  // Include checks and help files.
  module_load_include('inc', 'security_review');
  $checklist = security_review_get_checklist();
  module_load_include('inc', 'security_review', 'security_review.help');
  $output = '';
  $skipped_message = NULL;
  if (!is_null($module) && !is_null($check_name)) {
    $check = $checklist[$module][$check_name];
    if (isset($check['help'])) {
      $output = $check['help'];
    }
    elseif (isset($check['callback'])) {
      if (isset($check['file'])) {
        $check_module = $module;

        // Handle Security Review defining checks for other modules.
        if (isset($check['module'])) {
          $check_module = $check['module'];
        }
        module_load_include('inc', $check_module, $check['file']);
      }
      $function = $check['callback'] . '_help';
      if (function_exists($function)) {
        $last_check = security_review_get_last_check($module, $check_name);

        // Set skipped timestamp and user message.
        if ($last_check['skip'] == '1') {
          $skipped_message = _security_review_check_skipped($last_check);
        }
        elseif ($last_check['result'] == '0') {
          $callback = $check['callback'];
          $check_return = $callback();
          $last_check = array_merge($last_check, $check_return);
        }
        $element = $function($last_check, $skipped_message);
        $output = theme('security_review_check_help', array(
          'element' => $element,
        ));
      }
    }
  }
  else {
    $output = _security_review_help();

    // List all checks as links to specific help.
    $output .= '<h3>' . t('Check-specific help') . '</h3>';
    $output .= '<p>' . t("Details and help on the security review checks. Checks are not always perfectly correct in their procedure and result. Refer to drupal.org handbook documentation if you are unsure how to make the recommended alterations to your configuration or consult the module's README.txt for support.") . '</p>';
    foreach ($checklist as $module => $checks) {
      foreach ($checks as $reviewcheck => $check) {
        $items[] = l($check['title'], 'admin/reports/security-review/help/' . $module . '/' . $reviewcheck);
      }
    }
    if ($items) {
      $output .= theme('item_list', array(
        'items' => $items,
      ));
    }
  }
  if (empty($output)) {
    return drupal_not_found();
  }
  return array(
    '#markup' => $output,
  );
}