You are here

function acquia_agent_settings_form in Acquia Connector 7.2

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_form()
  2. 6 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_form()
  3. 7.3 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_form()
  4. 7 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_form()

Settings form builder function.

1 string reference to 'acquia_agent_settings_form'
acquia_agent_settings_page in acquia_agent/acquia_agent.pages.inc
Main page function

File

acquia_agent/acquia_agent.pages.inc, line 492
Acquia Agent configuration page.

Code

function acquia_agent_settings_form($form, &$form_state, $banner) {
  $identifier = acquia_agent_settings('acquia_identifier');
  $key = acquia_agent_settings('acquia_key');
  $subscription = acquia_agent_settings('acquia_subscription_name');

  // 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');
  }
  if (empty($_POST)) {

    // Check our connection to Acquia and validity of the credentials.
    $acquia_network_address = acquia_agent_settings('acquia_network_address');
    if (!acquia_agent_valid_credentials($identifier, $key, $acquia_network_address)) {
      $error_message = acquia_agent_connection_error_message();
      $ssl_available = in_array('ssl', stream_get_transports(), TRUE) && !defined('ACQUIA_DEVELOPMENT_NOSSL') && variable_get('acquia_agent_verify_peer', 0);
      if (empty($error_message) && $ssl_available) {
        $error_message = 'There was an error in validating your subscription credentials. You may want to try disabling SSL peer verification by setting the variable acquia_agent_verify_peer to false.';
      }
      drupal_set_message(t($error_message), 'error', FALSE);
    }
  }
  $form['connected'] = array(
    '#markup' => t('<h3>Connected to Acquia Insight</h3>'),
  );
  if (!empty($subscription)) {
    $form['subscription'] = array(
      '#markup' => t('Subscription: @sub <a href="!url">change</a>', array(
        '@sub' => $subscription,
        '!url' => url('admin/config/system/acquia-agent/setup'),
      )),
    );
  }
  $form['connection'] = array(
    '#type' => 'fieldset',
    '#title' => t('Acquia Subscription Settings'),
    '#collapsible' => FALSE,
  );
  $form['connection']['acquia_dynamic_banner'] = array(
    '#type' => 'checkbox',
    '#title' => t('Receive updates from Acquia Insight'),
    '#default_value' => variable_get('acquia_dynamic_banner', FALSE),
  );
  $collapsed = FALSE;
  if (isset($_SERVER['AH_SITE_GROUP'])) {

    // Collapse migrate if Acquia hosting.
    $collapsed = TRUE;
  }
  $form['migrate'] = array(
    '#type' => 'fieldset',
    '#title' => t('Acquia Cloud Migrate'),
    '#description' => t('Transfer a fully-functional copy of your site to Acquia Cloud. <a href="!url">Learn more</a>.', array(
      '!url' => url('https://docs.acquia.com/cloud/site/import/connector'),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => $collapsed,
  );
  $form['migrate']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Migrate'),
    '#submit' => array(
      'acquia_agent_migrate_go_submit',
    ),
  );
  $last_migration = variable_get('acquia_agent_cloud_migration', array());
  if (!empty($last_migration['db_file']) || !empty($last_migration['tar_file']) || !empty($last_migration['dir'])) {

    // Replace Upload button with Cleanup.
    unset($form['migrate']['#description']);
    $form['migrate']['#prefix'] = '<div class="messages error">' . t('Temporary files were leftover from last migration attempt.') . '</div>';
    $form['migrate']['submit']['#value'] = t('Cleanup files');
    $form['migrate']['submit']['#submit'] = array(
      'acquia_agent_migrate_cleanup_submit',
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
    '#submit' => array(
      'acquia_agent_settings_submit',
    ),
  );
  $form['banner'] = array(
    '#markup' => $banner,
  );
  $form['#theme'] = 'acquia_agent_banner_form';
  return $form;
}