function _acquia_agent_automatic_start_submit in Acquia Connector 7.3
Same name and namespace in other branches
- 6.2 acquia_agent/acquia_agent.pages.inc \_acquia_agent_automatic_start_submit()
- 7.2 acquia_agent/acquia_agent.pages.inc \_acquia_agent_automatic_start_submit()
Needs comment.
1 call to _acquia_agent_automatic_start_submit()
- acquia_agent_automatic_setup_form_submit in acquia_agent/
acquia_agent.pages.inc - Needs comment.
File
- acquia_agent/
acquia_agent.pages.inc, line 218 - Acquia Agent configuration page.
Code
function _acquia_agent_automatic_start_submit(&$form_state) {
// Make hashed password signed request to Acquia for subscriptions.
$body = array(
'email' => $form_state['values']['email'],
);
// acquia.com authenticator uses hash of client-supplied password hashed with
// remote settings so that the hash can match. pass was hashed in
// _acquia_agent_setup_form_validate().
$authenticator = _acquia_agent_create_authenticator($body, $form_state['pass']);
$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.subscription.credentials', $data);
if ($errno = xmlrpc_errno()) {
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('Server error, please submit again.'));
}
elseif (!empty($result['is_error'])) {
form_set_error('email', t('Server error, please submit again.'));
}
elseif (empty($result['body']['subscription'])) {
form_set_error('email', t('No subscriptions were found for your account.'));
}
elseif (count($result['body']['subscription']) > 1) {
// Multistep form for choosing from available subscriptions.
$form_state['choose'] = TRUE;
$form_state['subscriptions'] = $result['body']['subscription'];
// Force rebuild with next step.
$form_state['rebuild'] = TRUE;
}
else {
// One subscription so set id/key pair.
$sub = $result['body']['subscription'][0];
variable_set('acquia_key', $sub['key']);
variable_set('acquia_identifier', $sub['identifier']);
variable_set('acquia_subscription_name', $sub['name']);
}
}