You are here

function acquia_agent_automatic_setup_form_validate in Acquia Connector 7.2

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

File

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

Code

function acquia_agent_automatic_setup_form_validate($form, &$form_state) {
  if (!isset($form_state['choose'])) {

    // Validate e-mail address and get account hash settings.
    $body = array(
      'email' => $form_state['values']['email'],
    );
    $authenticator = _acquia_agent_create_authenticator($body);
    $data = array(
      'body' => $body,
      'authenticator' => $authenticator,
    );

    // Does not use acquia_agent_call() because Network identifier and key are not available.
    $server = variable_get('acquia_network_address', 'https://rpc.acquia.com');
    $result = _acquia_agent_request(acquia_agent_network_address($server), 'acquia.agent.communication.settings', $data);
    if ($errno = xmlrpc_errno() !== NULL) {
      acquia_agent_report_xmlrpc_error();

      // Set form error to prevent switching to the next page.
      form_set_error('');
    }
    elseif (!$result) {

      // Email doesn't exist.
      form_set_error('email', t("We didn't find an Acquia account with that email address."));
    }
    else {

      // Build hashed password from account password settings for further
      // XML-RPC communications with acquia.com.
      $pass = _acquia_agent_hash_password_crypt($result['algorithm'], $form_state['values']['pass'], $result['hash_setting'], $result['extra_md5']);
      $form_state['pass'] = $pass;
    }
  }
}