You are here

function hackedProject::compute_report in Hacked! 8.2

Return a nice report, a simple overview of the status of this project.

1 call to hackedProject::compute_report()
hackedProject::compute_details in src/hackedProject.php
Return a nice detailed report.

File

src/hackedProject.php, line 280

Class

hackedProject
Encapsulates a Hacked! project.

Namespace

Drupal\hacked

Code

function compute_report() {

  // Ensure we know the differences.
  $this
    ->compute_differences();

  // Do some counting
  $report = [
    'project_name' => $this->name,
    'status' => HACKED_STATUS_UNCHECKED,
    'counts' => [
      'same' => count($this->result['same']),
      'different' => count($this->result['different']),
      'missing' => count($this->result['missing']),
      'access_denied' => count($this->result['access_denied']),
    ],
    'title' => $this
      ->title(),
  ];

  // Add more details into the report result (if we can).
  $details = array(
    'link',
    'name',
    'existing_version',
    'install_type',
    'datestamp',
    'project_type',
    'includes',
  );
  foreach ($details as $item) {
    if (isset($this->project_info[$item])) {
      $report[$item] = $this->project_info[$item];
    }
  }
  if ($report['counts']['access_denied'] > 0) {
    $report['status'] = HACKED_STATUS_PERMISSION_DENIED;
  }
  elseif ($report['counts']['missing'] > 0) {
    $report['status'] = HACKED_STATUS_HACKED;
  }
  elseif ($report['counts']['different'] > 0) {
    $report['status'] = HACKED_STATUS_HACKED;
  }
  elseif ($report['counts']['same'] > 0) {
    $report['status'] = HACKED_STATUS_UNHACKED;
  }
  return $report;
}