function simple_ldap_requirements in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap.install \simple_ldap_requirements()
Implements hook_requirements().
File
- ./
simple_ldap.install, line 26 - simple_ldap module installation.
Code
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.
if (extension_loaded('ldap')) {
$requirements['php.ldap'] = array(
'title' => $t('PHP LDAP extension'),
'severity' => extension_loaded('ldap') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'value' => $t('Enabled'),
'severity' => REQUIREMENT_OK,
'description' => NULL,
);
}
else {
$requirements['php.ldap'] = array(
'title' => $t('PHP LDAP extension'),
'severity' => extension_loaded('ldap') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'value' => NULL,
'severity' => REQUIREMENT_ERROR,
'description' => $t('No PHP LDAP extension found. Please install the extension and try enabling the module again.'),
);
}
// 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,
'description' => NULL,
);
}
return $requirements;
}