forked from ulsdevteam/simple_ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_ldap.install
72 lines (65 loc) · 1.95 KB
/
simple_ldap.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @file
* simple_ldap module installation.
*/
/**
* Implements hook_uninstall().
*/
function simple_ldap_uninstall() {
variable_del('simple_ldap_host');
variable_del('simple_ldap_port');
variable_del('simple_ldap_starttls');
variable_del('simple_ldap_binddn');
variable_del('simple_ldap_bindpw');
variable_del('simple_ldap_basedn');
variable_del('simple_ldap_readonly');
variable_del('simple_ldap_pagesize');
variable_del('simple_ldap_debug');
variable_del('simple_ldap_opt_referrals');
}
/**
* Implements hook_requirements().
*/
function simple_ldap_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
// Make sure the PHP LDAP extension is loaded.
$requirements['php.ldap'] = array(
'title' => $t('PHP LDAP extension'),
'value' => extension_loaded('ldap') ? $t('Enabled') : $t('Disabled'),
'severity' => extension_loaded('ldap') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
);
// Make sure an LDAP server is configured, and Drupal can connect to it.
if ($phase == 'runtime') {
if (simple_ldap_configured()) {
$server = SimpleLdapServer::singleton();
$bind = $server->bind();
if ($bind) {
$value = $t('Successfully bound to @host', array('@host' => $server->host));
$severity = REQUIREMENT_OK;
}
else {
$value = $t('Failed to bind to @host', array('@host' => $server->host));
$severity = REQUIREMENT_ERROR;
}
}
else {
$value = $t('Simple LDAP Server is not configured');
$severity = REQUIREMENT_WARNING;
}
$requirements['ldap.server'] = array(
'title' => $t('Simple LDAP Server'),
'value' => $value,
'severity' => $severity,
);
}
return $requirements;
}
/**
* Update configuration variables.
*/
function simple_ldap_update_7100(&$sandbox) {
variable_set('simple_ldap_opt_referrals', variable_get('simple_ldap_opt_referrals', TRUE));
}