function clients_drupal_add_validate in Web Service Clients 6
Implementation of hook_validate()
File
- backends/
clients_drupal/ clients_drupal.module, line 235 - Drupal Services plugin for Clients module @author Django Beatty - adub
Code
function clients_drupal_add_validate($form, &$form_state) {
if (clients_connection_load($form['name']['#value'])) {
form_set_error('name', 'A service by this name already exists!');
}
$connection = new stdClass();
$connection->name = $form['name']['#value'];
$connection->endpoint = $form['endpoint']['#value'];
$connection->domain = $form['configuration']['domain']['#value'];
$connection->servicekey = $form['configuration']['servicekey']['#value'];
$connection->username = $form['configuration']['username']['#value'];
$connection->password = $form['configuration']['password']['#value'];
$testconnect = ClientsServicesDrupal::connect($connection);
if (!is_array($testconnect) || !isset($testconnect['sessid'])) {
form_set_error('endpoint', "Couldn't connect");
}
else {
$testuser = ClientsServicesDrupal::getUser($connection);
if (!is_array($testuser) || !isset($testuser['sessid'])) {
form_set_error('username', isset($testuser->message) ? $testuser->message : "Couldn't log in");
}
}
}