1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Administrative page callbacks for the ldap_authentication module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* form for adding, updating, and deleting a single ldap authorization mapping
|
11 |
|
|
*
|
12 |
|
|
* @param <type> $form
|
13 |
|
|
* @param <type> $form_state
|
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 |
|
|
/**
|
24 |
|
|
* validate handler for the ldap_authentication_admin_form
|
25 |
|
|
*/
|
26 |
|
|
function ldap_authentication_admin_form_validate($form, &$form_state) {
|
27 |
|
|
|
28 |
|
|
ldap_servers_module_load_include('php', 'ldap_authentication', 'LdapAuthenticationConfAdmin.class');
|
29 |
|
|
$auth_conf = new LdapAuthenticationConfAdmin();
|
30 |
|
|
$errors = $auth_conf->drupalFormValidate($form_state['values']);
|
31 |
|
|
foreach ($errors as $error_name => $error_text) {
|
32 |
|
|
form_set_error($error_name, t($error_text));
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
/**
|
39 |
|
|
* submit handler function for ldap_authentication_admin_form
|
40 |
|
|
*/
|
41 |
|
|
|
42 |
|
|
function ldap_authentication_admin_form_submit($form, &$form_state) {
|
43 |
|
|
|
44 |
|
|
ldap_servers_module_load_include('php', 'ldap_authentication', 'LdapAuthenticationConfAdmin.class');
|
45 |
|
|
$auth_conf = new LdapAuthenticationConfAdmin();
|
46 |
|
|
$auth_conf->drupalFormSubmit($form_state['values']); // add form data to object and save or create
|
47 |
|
|
if (!$auth_conf->hasEnabledAuthenticationServers()) {
|
48 |
|
|
drupal_set_message(t('No LDAP servers are enabled for authentication,
|
49 |
|
|
so no LDAP Authentication can take place. This essentially disables
|
50 |
|
|
LDAP Authentication.'), 'warning');
|
51 |
|
|
}
|
52 |
|
|
if ($auth_conf->hasError == FALSE) {
|
53 |
|
|
drupal_set_message(t('LDAP Authentication configuration saved'), 'status');
|
54 |
|
|
drupal_goto(LDAP_SERVERS_MENU_BASE_PATH . '/authentication');
|
55 |
|
|
}
|
56 |
|
|
else {
|
57 |
|
|
form_set_error($auth_conf->errorName, $auth_conf->errorMsg);
|
58 |
|
|
$auth_conf->clearError();
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
} |