You are here

function acquia_spi_set_variables in Acquia Connector 6.2

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

Set variables from NSPI response.

Parameters

array $set_variables Variables to be set.:

Return value

NULL

1 call to acquia_spi_set_variables()
acquia_spi_handle_server_response in acquia_spi/acquia_spi.module
Act on SPI update server response.

File

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

Code

function acquia_spi_set_variables($set_variables) {
  if (empty($set_variables)) {
    return;
  }
  $saved = array();
  $ignored = variable_get('acquia_spi_ignored_set_variables', array());
  if (!variable_get('acquia_spi_set_variables_override', 0)) {
    $ignored[] = 'acquia_spi_set_variables_automatic';
  }

  // Some variables can never be set.
  $ignored = array_merge($ignored, array(
    'drupal_private_key',
    'site_mail',
    'site_name',
    'maintenance_mode',
    'user_register',
  ));

  // Variables that can be automatically set.
  $whitelist = acquia_spi_approved_set_variables();
  foreach ($set_variables as $key => $value) {

    // Approved variables get set immediately unless ignored.
    if (in_array($key, $whitelist) && !in_array($key, $ignored)) {
      $saved[] = $key;
      variable_set($key, $value);
    }
  }
  if (!empty($saved)) {
    variable_set('acquia_spi_saved_variables', array(
      'variables' => $saved,
      'time' => time(),
    ));
    watchdog('acquia spi', 'Saved variables from Acquia Insight: @variables', array(
      '@variables' => implode(', ', $saved),
    ), WATCHDOG_INFO);
  }
  else {
    watchdog('acquia spi', 'Did not save any variables from Acquia Insight.', array(), WATCHDOG_INFO);
  }
}