You are here

function security_review_run_form_submit in Security Review 6

Same name and namespace in other branches
  1. 7 security_review.pages.inc \security_review_run_form_submit()

File

./security_review.module, line 270
Site security review and reporting Drupal module.

Code

function security_review_run_form_submit($form, &$form_state) {
  $checklist = module_invoke_all('security_checks');
  $skipped = security_review_skipped_checks();

  // Remove checks that are being skipped.
  if (!empty($skipped)) {
    foreach ($skipped as $module => $checks) {
      foreach ($checks as $check_name => $check) {
        unset($checklist[$module][$check_name]);
      }
      if (empty($checklist[$module])) {
        unset($checklist[$module]);
      }
    }
  }

  // Use Batch to process the checklist.
  $batch = array(
    'operations' => array(),
    'title' => t('Performing Security Review'),
    'progress_message' => t('Progress @current out of @total.'),
    'error_message' => t('An error occurred. Rerun the process or consult the logs.'),
    'finished' => '_security_review_batch_finished',
  );
  $log = variable_get('security_review_log', TRUE);
  foreach ($checklist as $module => $checks) {
    foreach ($checks as $check_name => $check) {

      // Each check is its own operation. There could be a case where a single
      // check needs to run itself a batch operation, perhaps @todo?
      $batch['operations'][] = array(
        '_security_review_batch_op',
        array(
          $module,
          $check_name,
          $check,
          $log,
        ),
      );
    }
  }
  batch_set($batch);
  return;
}