You are here

function clients_delete_form_submit in Web Service Clients 6

@todo: refactor?

File

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

Code

function clients_delete_form_submit($form_id, $form_values) {
  $cid = (int) $form_values['values']['cid'];
  if ($form_values['values']['type'] == 'connections') {
    if ($result = db_query_range("DELETE FROM {clients_connections} WHERE cid = %d", $cid, 0, 1)) {
      @db_query("DELETE FROM {clients_resources} WHERE cid = %d", $cid);

      // error suppression is less expensive than a query to check if there are any resources
      drupal_set_message(t('Connection deleted: ') . $form_values['values']['name']);
      drupal_goto('admin/settings/clients/connections');
    }
    else {
      drupal_set_message(t('Problem deleting connection: ') . $form_values['values']['name']);
    }
  }
  elseif ($form_values['values']['type'] == 'resources') {
    if ($result = db_query_range("DELETE FROM {clients_resources} WHERE rid = %d", $form_values['values']['cid'])) {
      drupal_set_message(t('Resource deleted: ') . $form_values['values']['name']);
      drupal_goto('admin/settings/clients/resources');

      // @todo move this to form
    }
    else {
      drupal_set_message(t('Problem deleting resource: ') . $form_values['values']['name']);
    }
  }
}