You are here

function acquia_agent_automatic_setup_form_submit in Acquia Connector 6.2

Same name and namespace in other branches
  1. 7.3 acquia_agent/acquia_agent.pages.inc \acquia_agent_automatic_setup_form_submit()
  2. 7.2 acquia_agent/acquia_agent.pages.inc \acquia_agent_automatic_setup_form_submit()

File

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

Code

function acquia_agent_automatic_setup_form_submit($form, &$form_state) {
  if (isset($form_state['storage']['choose']) && isset($form_state['storage']['subscriptions'][$form_state['values']['subscription']])) {
    $sub = $form_state['storage']['subscriptions'][$form_state['values']['subscription']];
    variable_set('acquia_key', $sub['key']);
    variable_set('acquia_identifier', $sub['identifier']);
    variable_set('acquia_subscription_name', $sub['name']);

    // Clear storage to allow continuation.
    $form_state['storage'] = NULL;
  }
  else {
    _acquia_agent_automatic_start_submit($form_state);
  }

  // Don't set message or redirect if multistep.
  if (!form_get_errors() && empty($form_state['storage'])) {

    // Check subscription and send a heartbeat to Acquia via XML-RPC.
    // Our status gets updated locally via the return data.
    $active = acquia_agent_check_subscription();
    cache_clear_all();
    if ($active && count($active) > 1) {
      drupal_set_message(t('<h3>Connection successful!</h3>You are now connected to Acquia.'));
    }

    // Redirect to the path without the suffix.
    drupal_goto('admin/settings/acquia-agent');
  }
}