You are here

function clients_flickr_add_validate in Web Service Clients 6

Same name and namespace in other branches
  1. 7 backends/clients_flickr/clients_flickr.module \clients_flickr_add_validate()

Implementation of hook_validate()

File

backends/clients_flickr/clients_flickr.module, line 164
Flickr plugin for Clients module @author Django Beatty - adub

Code

function clients_flickr_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->api_key = $form['configuration']['api_key']['#value'];
  $connection->secret = $form['configuration']['secret']['#value'];
  $testconnect = ClientsServicesFlickr::connect($connection);
  if (!is_array($testconnect) || !isset($testconnect['sessid'])) {
    form_set_error('endpoint', "Couldn't connect");
  }
  else {

    // test auth
  }
}