You are here

function support_client_form_submit in Support Ticketing System 7

Add/update client information.

File

./support.admin.inc, line 310
support.admin.inc

Code

function support_client_form_submit($form, &$form_state) {
  if ($form_state['triggering_element']['#value'] == t('Delete')) {

    // Rebuild the form to confirm support client deletion.
    $form_state['rebuild'] = TRUE;
    $form_state['confirm_delete'] = TRUE;
    return;
  }
  $client = entity_ui_form_submit_build_entity($form, $form_state);

  // For the form, we were using 'client_path' as the element for 'path' to prevent
  // conflict with pathauto. We change it back here so it gets saved properly.
  $client->path = $client->client_path;
  unset($client->client_path);
  switch ($client
    ->save()) {
    case SAVED_NEW:
      drupal_set_message(t('Client %client created.', array(
        '%client' => $client->name,
      )));
      break;
    case SAVED_UPDATED:
      drupal_set_message(t('Client %client updated.', array(
        '%client' => $client->name,
      )));
      break;
    case SAVED_DELETED:
      drupal_set_message(t('Client %client deleted.', array(
        '%client' => $client->name,
      )));
      break;
  }

  // clean page cache and block cache
  cache_clear_all();

  // rebuild the menu
  menu_rebuild();
  $form_state['redirect'] = 'admin/support/clients';
}