You are here

public function AdminConfigureForm::ipGeoLocDiagnose in IP Geolocation Views & Maps 8

Report on the configuration status.

Reports in particular to the system access log, which is required for visitor views and maps.

Return value

int Value -1, if there's a problem, otherwise a count of IP addresses not stored

1 call to AdminConfigureForm::ipGeoLocDiagnose()
AdminConfigureForm::buildForm in src/Form/AdminConfigureForm.php
Form constructor.

File

src/Form/AdminConfigureForm.php, line 368

Class

AdminConfigureForm
Pending doc.

Namespace

Drupal\ip_geoloc\Form

Code

public function ipGeoLocDiagnose() {

  // $this->messenger->addMessage($message, $type)
  $geoloc_count = $this->connection
    ->query('SELECT COUNT(DISTINCT ip_address) FROM ip_geoloc')
    ->fetchField();
  $this->messenger
    ->addMessage($this
    ->t("The IP geolocation database currently contains information for %geoloc_count visited IP addresses.", [
    '%geoloc_count' => $geoloc_count,
  ]), 'status', FALSE);

  // Access log table doesn't exists anymore

  /*if (!$this->connection->schema()->tableExists($table)('accesslog')) {
    $this->messenger->addMessage($this->t("The <strong>accesslog</strong> database table does not exist, probably because core's <strong>Statistics</strong> module is not enabled. Views and maps of visitors will not be available until you enable the <strong>Statistics</strong> module and its <strong>access log</strong>. The visitor location map blocks are not affected and should still display."), 'warning');
    }
    elseif (!\Drupal::moduleHandler()->moduleExists('statistics')) {
    $this->messenger->addMessage($this->t('The <strong>Statistics</strong> module is not enabled. Views and maps of visitors will not be available or display errors until you enable the <strong>Statistics</strong> module and its <strong>access log</strong>. The visitor location map blocks are not affected and should still display.'), 'warning');
    }
    else {
    $ip_address_count = $this->connection->query('SELECT COUNT(DISTINCT hostname) FROM {accesslog}')->fetchField();
    $this->messenger->addMessage($this->t("The system access log currently contains entries from %ip_address_count IP addresses.", ['%ip_address_count' => $ip_address_count]), 'status', FALSE);
    if (!\Drupal::state()->get('statistics_enable_access_log', FALSE)) {
    $this->messenger->addMessage($this->t('The <strong>Statistics</strong> module is enabled, but its system <strong>access log</strong> is not. Therefore all visitor Views are frozen and will not grow. The visitor location map blocks are not affected and should still display. You can enable the <strong>access log</strong> at <a href="!url">Configuration >> Statistics</a>.',
    ['!url' => 'admin/config/system/statistics']), 'warning');
    }
    else {
    $non_synched_ips = ip_geoloc_ips_to_be_synched();
    $count = count($non_synched_ips);
    if ($count > 0) {
    $t = $this->t("%count IP addresses in the system access log currently have no associated lat/long or address information on the IP geolocation database. These are the most recent ones: %ips",
    [
    '%count' => $count,
    '%ips' => implode(', ', array_slice($non_synched_ips, 0, 10, TRUE)),
    ]);
    $this->messenger->addMessage($t, 'status', FALSE);
    }
    else {
    $this->messenger->addMessage($this->t("The IP geolocation database is up to date and in sync with the system access log."), 'status', FALSE);
    }
    return $count;
    }
    }*/
  return -1;
}