You are here

function client_delete_confirm_submit in Web Service Clients 7

Same name and namespace in other branches
  1. 6.2 clients.module \client_delete_confirm_submit()
  2. 7.2 clients.connection.admin.inc \client_delete_confirm_submit()

@todo: refactor?

File

./clients.module, line 261
Clients module - handles keys and service connections and provides an API for clients

Code

function client_delete_confirm_submit($form, &$form_state) {
  $cid = (int) $form_state['values']['cid'];
  if ($form_state['values']['type'] == 'connection') {
    if ($result = db_query("DELETE FROM {clients_connections} WHERE cid = %d", $cid)) {
      @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 @name deleted.', array(
        '@name' => $form_state['values']['name'],
      )));
      $form_state['redirect'] = 'admin/settings/clients/connections';
    }
    else {
      drupal_set_message(t('Problem deleting connection: ') . $form_state['values']['name']);
    }
  }
  elseif ($form_state['values']['type'] == 'resource') {
    if ($result = db_query_range("DELETE FROM {clients_resources} WHERE rid = %d", $form_state['values']['cid'])) {
      drupal_set_message(t('Resource @name deleted.', array(
        '@name' => $form_state['values']['name'],
      )));
      $form_state['redirect'] = 'admin/settings/clients/resources';
    }
    else {
      drupal_set_message(t('Problem deleting resource: ') . $form_state['values']['name']);
    }
  }
}