function acquia_spi_requirements in Acquia Connector 7.2
Same name and namespace in other branches
- 6.2 acquia_spi/acquia_spi.install \acquia_spi_requirements()
- 7.3 acquia_spi/acquia_spi.install \acquia_spi_requirements()
Implements hook_requirements().
File
- acquia_spi/
acquia_spi.install, line 36 - Installer file for Acquia SPI module.
Code
function acquia_spi_requirements($phase) {
$requirements = array();
$last_sent = variable_get('acquia_spi_cron_last', 0);
$use_cron = variable_get('acquia_spi_use_cron', 1);
switch ($phase) {
case 'runtime':
$has_credentials = acquia_agent_has_credentials();
if ($has_credentials) {
$key = sha1(drupal_get_private_key());
$config_url = $description = $interval = '';
$ago = REQUEST_TIME - $last_sent;
if ($ago >= 60 * 60 * 36) {
// 1.5 days ago.
$severity = REQUIREMENT_WARNING;
$description = 'SPI data has not been reported to the Acquia Subscription for more than a day.<br/>';
}
else {
$severity = REQUIREMENT_OK;
}
if (!$use_cron) {
$config_url = url('admin/config/system/acquia-agent');
$description .= 'You are not sending SPI data via Drupal\'s cron system. <a href="!config-page">View Acquia Subscription configuration</a> for details.<br/>';
}
else {
$interval = variable_get('acquia_spi_cron_interval', 30);
if (variable_get('acquia_spi_cron_interval_override', FALSE)) {
$interval = variable_get('acquia_spi_cron_interval_override', 30);
}
$description .= 'SPI data will be sent once every !interval minutes once cron is called. ';
}
$description .= 'You can <a href="!spi-send">manually send SPI data</a>.';
if ($last_sent == 0) {
$value = t('SPI data has not been sent');
}
else {
$value = t('Last sent !time ago', array(
'!time' => format_interval($ago),
));
}
$requirements['acquia_spi'] = array(
'title' => t('Acquia SPI'),
'severity' => $severity,
'value' => $value,
'description' => t($description, array(
'!interval' => $interval,
'!config-page' => $config_url,
'!spi-send' => url('system/acquia-spi-send', array(
'query' => array(
'destination' => 'admin/reports/status',
'key' => $key,
),
)),
)),
);
}
// Acquia SPI custom tests status.
$variables = array(
'@help' => url('admin/help/acquia_agent'),
'@validate' => url('system/acquia-spi-custom-test-validate'),
);
$modules = module_implements('acquia_spi_test');
if (empty($modules)) {
$description = 'No custom tests were detected in any module.<br/>';
$value = 'Not implemented (<a href="@help">more information</a>)';
$severity = REQUIREMENT_OK;
}
else {
$result = acquia_spi_test_status();
if (!empty($result)) {
$modules = implode(', ', array_keys($result));
$description = 'Custom tests within the following module(s) have failed validation and will not be sent: %modules. <br/>Please check the error logs for more information regarding how to pass validation or <a href="@validate">perform another validation check</a>. (A validation check can also be performed via the Drush command, "spi-test-validate.")';
$value = 'Failed (<a href="@help">more information</a>)';
$severity = REQUIREMENT_ERROR;
}
else {
$modules = implode(', ', $modules);
$description = 'Custom test data is structured properly and is sending from: %modules';
$value = 'Passed';
$severity = REQUIREMENT_OK;
}
$variables['%modules'] = $modules;
}
$requirements['acquia_spi_test'] = array(
'title' => t('Acquia SPI Custom Tests'),
'description' => t($description, $variables),
'value' => t($value, $variables),
'severity' => $severity,
);
break;
}
return $requirements;
}