You are here

function ldap_servers_admin_delete_submit in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.admin.inc \ldap_servers_admin_delete_submit()
  2. 7.2 ldap_servers/ldap_servers.admin.inc \ldap_servers_admin_delete_submit()

Submit handler for the LDAP server delete page.

File

ldap_servers/ldap_servers.admin.inc, line 163
Defines functions for administrative interface for servers

Code

function ldap_servers_admin_delete_submit($form, &$form_state) {
  $values = $form_state['values'];
  $sid = $values['sid'];
  ldap_server_module_load_include('php', 'ldap_servers', 'LdapServerAdmin.class');
  $ldap_server = new LdapServerAdmin($sid);
  if ($values['confirm'] && $sid) {
    if ($result = $ldap_server
      ->delete($sid)) {
      $tokens = array(
        '%name' => $ldap_server->name,
        '!sid' => $sid,
      );
      drupal_set_message(t('LDAP Server %name (server id = !sid) has been deleted.', $tokens), 'status');
      watchdog('ldap', 'LDAP Server deleted: %name (sid = !sid) ', $tokens);
    }
    else {
      drupal_set_message(t('LDAP Server delete failed.'), 'warning');
    }
  }
  else {
    drupal_set_message(t('LDAP Server delete cancelled.'), 'status');
  }
  ldap_servers_cache_clear();
  drupal_goto(LDAP_SERVERS_MENU_BASE_PATH . '/servers/list');
}