function acquia_agent_settings_credentials_validate in Acquia Connector 6.2
Same name and namespace in other branches
- 7.3 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_credentials_validate()
- 7.2 acquia_agent/acquia_agent.pages.inc \acquia_agent_settings_credentials_validate()
Validate credentials form submit.
File
- acquia_agent/
acquia_agent.pages.inc, line 426 - Acquia Agent configuration page.
Code
function acquia_agent_settings_credentials_validate($form, &$form_state) {
// Trim all input to get rid of possible whitespace pasted from the website.
foreach ($form_state['values'] as $key => $value) {
$form_state['values'][$key] = trim($value);
}
$identifier = $form_state['values']['acquia_identifier'];
$key = $form_state['values']['acquia_key'];
// Validate credentials and get subscription name.
$body = array(
'identifier' => $identifier,
);
$data = acquia_agent_call('acquia.agent.subscription.name', $body, $identifier, $key, variable_get('acquia_network_address', 'https://rpc.acquia.com'));
$error = NULL;
if ($errno = xmlrpc_errno()) {
acquia_agent_report_xmlrpc_error();
// Set form error to prevent switching to the next page.
form_set_error('');
}
elseif (!$data || !isset($data['result'])) {
form_set_error('', t('Server error, please submit again.'));
}
$result = $data['result'];
if (!empty($result['is_error'])) {
form_set_error('', t('Server error, please submit again.'));
}
elseif (isset($result['body']['error'])) {
form_set_error('', $result['body']['error']);
}
elseif (empty($result['body']['subscription'])) {
form_set_error('acquia_identifier', t('No subscriptions were found.'));
}
else {
// Store subscription.
$form_state['storage']['sub'] = $result['body']['subscription'];
}
}