You are here

function clients_resources_form_submit in Web Service Clients 6

Same name and namespace in other branches
  1. 7 clients.module \clients_resources_form_submit()

File

./clients.module, line 347
Clients module - handles keys and service connections and provides an API for clients @author Django Beatty - adub

Code

function clients_resources_form_submit($form, &$form_state) {
  $values = array();
  $values['name'] = $form_state['values']['name'];
  $values['cid'] = $form_state['values']['clients-resource']['connection'];

  // was backend in case this breaks
  $values['configuration'] = $form_state['values']['clients-resource'];

  // needs try catch?
  if (isset($form['#rid'])) {

    // edit
    $values['rid'] = $form['#rid'];
    if ($result = drupal_write_record('clients_resources', $values, 'rid')) {
      drupal_set_message('Resource edited');
    }
  }
  elseif ($result = drupal_write_record('clients_resources', $values)) {
    drupal_set_message('Resource added');
  }
  drupal_goto('admin/settings/clients/resources');
}