You are here

function _acquia_spi_send in Acquia Connector 7.2

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \_acquia_spi_send()
  2. 7.3 acquia_spi/acquia_spi.module \_acquia_spi_send()

Callback for sending SPI data.

1 string reference to '_acquia_spi_send'
acquia_spi_menu in acquia_spi/acquia_spi.module
Implements hook_menu().

File

acquia_spi/acquia_spi.module, line 150
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function _acquia_spi_send() {
  $method = ACQUIA_SPI_METHOD_CALLBACK;

  // Insight's set variable feature will pass method insight.
  if (isset($_GET['method']) && $_GET['method'] === ACQUIA_SPI_METHOD_INSIGHT) {
    $method = ACQUIA_SPI_METHOD_INSIGHT;
  }
  $response = acquia_spi_send_full_spi($method);
  if (isset($_GET['destination'])) {
    if (!empty($response)) {
      $message = array();
      if (isset($response['spi_data_received']) && $response['spi_data_received'] === TRUE) {
        $message[] = t('SPI data sent.');
      }
      if (!empty($response['nspi_messages'])) {
        $message[] = t('Acquia Insight returned the following messages. Further information may be in the logs.');
        foreach ($response['nspi_messages'] as $nspi_message) {
          $message[] = check_plain($nspi_message);
        }
      }
      drupal_set_message(implode('<br/>', $message));
    }
    else {
      drupal_set_message(t('Error sending SPI data. Consult the logs for more information.'), 'error');
    }
    drupal_goto();
  }

  // If destination was not sent the call is via cron so close request and exit.
  drupal_exit();
}