You are here

function acquia_spi_form_acquia_agent_settings_form_alter in Acquia Connector 6.2

Same name and namespace in other branches
  1. 6 acquia_spi/acquia_spi.module \acquia_spi_form_acquia_agent_settings_form_alter()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_form_acquia_agent_settings_form_alter()
  3. 7 acquia_spi/acquia_spi.module \acquia_spi_form_acquia_agent_settings_form_alter()
  4. 7.2 acquia_spi/acquia_spi.module \acquia_spi_form_acquia_agent_settings_form_alter()

Implementation of hook_form_[form_id]_alter().

File

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

Code

function acquia_spi_form_acquia_agent_settings_form_alter(&$form) {
  $identifier = acquia_agent_settings('acquia_identifier');
  $key = acquia_agent_settings('acquia_key');
  if (empty($identifier) && empty($key)) {
    return;
  }

  // Help documentation is local unless the Help module is disabled.
  if (module_exists('help')) {
    $help_url = url('admin/help/acquia_agent');
  }
  else {
    $help_url = url('https://docs.acquia.com/network/install');
  }
  $ssl_available = in_array('ssl', stream_get_transports(), TRUE) && !defined('ACQUIA_DEVELOPMENT_NOSSL');
  $form['connection']['#description'] = t('Allow collection and examination of the following items. <a href="!url">Learn more</a>.', array(
    '!url' => $help_url,
  ));
  $form['connection']['spi'] = array(
    '#prefix' => '<div class="acquia-spi">',
    '#suffix' => '</div>',
    '#weight' => -1,
  );
  $form['connection']['spi']['admin_priv'] = array(
    '#type' => 'checkbox',
    '#title' => t('Admin privileges'),
    '#default_value' => variable_get('acquia_spi_admin_priv', 1),
  );
  $form['connection']['spi']['send_node_user'] = array(
    '#type' => 'checkbox',
    '#title' => t('Nodes and users'),
    '#default_value' => variable_get('acquia_spi_send_node_user', 1),
  );
  $form['connection']['spi']['send_watchdog'] = array(
    '#type' => 'checkbox',
    '#title' => t('Watchdog logs'),
    '#default_value' => variable_get('acquia_spi_send_watchdog', 1),
  );
  $form['connection']['spi']['module_diff_data'] = array(
    '#type' => 'checkbox',
    '#title' => t('Source code'),
    '#default_value' => (int) variable_get('acquia_spi_module_diff_data', 1) && $ssl_available,
    '#description' => t('Source code analysis requires a SSL connection and for your site to be publicly accessible. <a href="!url">Learn more</a>.', array(
      '!url' => $help_url,
    )),
    '#disabled' => !$ssl_available,
  );
  $form['connection']['alter_variables'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow Insight to update list of approved variables.'),
    '#default_value' => (int) variable_get('acquia_spi_set_variables_override', 0),
    '#description' => t('Insight can set variables on your site to recommended values at your approval, but only from a specific list of variables. Check this box to allow Insight to update the list of approved variables. <a href="!url">Learn more</a>.', array(
      '!url' => $help_url,
    )),
  );
  $use_cron = variable_get('acquia_spi_use_cron', 1);
  $form['connection']['spi_use_cron'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send via Drupal cron'),
    '#default_value' => $use_cron,
  );
  if (!$use_cron) {
    $key = sha1(drupal_get_private_key());
    $url = url('system/acquia-spi-send', array(
      'query' => array(
        'key' => $key,
      ),
      'absolute' => TRUE,
    ));
    $form['connection']['spi_use_cron_url'] = array(
      '#value' => t('<p>Enter the following URL in your server\'s crontab to send SPI data:<br/><em>!url</em></p>', array(
        '!url' => $url,
      )),
    );
  }
  $form['submit']['#submit'][] = 'acquia_agent_spi_set_submit';
}