Projet

Général

Profil

Paste
Télécharger (1,9 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_authentication / ldap_authentication.admin.inc @ 91af538d

1
<?php
2

    
3
/**
4
 * @file
5
 * Administrative page callbacks for the ldap_authentication module.
6
 */
7

    
8
/**
9
 * Form for adding, updating, and deleting a single ldap authorization mapping.
10
 *
11
 * @param mixed $form
12
 * @param mixed $form_state
13
 *
14
 * @return array drupal form array
15
 */
16
function ldap_authentication_admin_form($form, &$form_state) {
17
  ldap_servers_module_load_include('php', 'ldap_authentication', 'LdapAuthenticationConfAdmin.class');
18
  $auth_conf = new LdapAuthenticationConfAdmin();
19
  return $auth_conf->drupalForm();
20
}
21

    
22
/**
23
 * Validate handler for the ldap_authentication_admin_form.
24
 */
25
function ldap_authentication_admin_form_validate($form, &$form_state) {
26

    
27
  ldap_servers_module_load_include('php', 'ldap_authentication', 'LdapAuthenticationConfAdmin.class');
28
  $auth_conf = new LdapAuthenticationConfAdmin();
29
  $errors = $auth_conf->drupalFormValidate($form_state['values']);
30
  foreach ($errors as $error_name => $error_text) {
31
    form_set_error($error_name, t($error_text));
32
  }
33

    
34
}
35

    
36
/**
37
 * Submit handler function for ldap_authentication_admin_form.
38
 */
39
function ldap_authentication_admin_form_submit($form, &$form_state) {
40

    
41
  ldap_servers_module_load_include('php', 'ldap_authentication', 'LdapAuthenticationConfAdmin.class');
42
  $auth_conf = new LdapAuthenticationConfAdmin();
43
  // Add form data to object and save or create.
44
  $auth_conf->drupalFormSubmit($form_state['values']);
45
  if (!$auth_conf->hasEnabledAuthenticationServers()) {
46
    drupal_set_message(t('No LDAP servers are enabled for authentication,
47
      so no LDAP Authentication can take place.  This essentially disables
48
      LDAP Authentication.'), 'warning');
49
  }
50
  if ($auth_conf->hasError == FALSE) {
51
    drupal_set_message(t('LDAP Authentication configuration saved'), 'status');
52
    drupal_goto(LDAP_SERVERS_MENU_BASE_PATH . '/authentication');
53
  }
54
  else {
55
    form_set_error($auth_conf->errorName, $auth_conf->errorMsg);
56
    $auth_conf->clearError();
57
  }
58

    
59
}