mirror of
https://github.com/moodle/moodle.git
synced 2025-03-15 05:00:06 +01:00
enrol/ldap: MDL-23412 Do not use any PHP LDAP constants unless the module is loaded and enabled.
Guard all the configuration settings with a proper check, don't display any setting and notify the user about the missing extension.
This commit is contained in:
parent
01c37ef1b5
commit
1331264bdf
@ -28,14 +28,17 @@ defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
//--- heading ---
|
||||
$settings->add(new admin_setting_heading('enrol_ldap_settings', '', get_string('pluginname_desc', 'enrol_ldap')));
|
||||
|
||||
if (!function_exists('ldap_connect')) {
|
||||
$settings->add(new admin_setting_heading('enrol_phpldap_noextension', '', get_string('phpldap_noextension', 'enrol_ldap')));
|
||||
} else {
|
||||
require_once($CFG->dirroot.'/enrol/ldap/settingslib.php');
|
||||
require_once($CFG->libdir.'/ldaplib.php');
|
||||
|
||||
$yesno = array(get_string('no'), get_string('yes'));
|
||||
|
||||
//--- heading ---
|
||||
$settings->add(new admin_setting_heading('enrol_ldap_settings', '', get_string('pluginname_desc', 'enrol_ldap')));
|
||||
|
||||
//--- connection settings ---
|
||||
$settings->add(new admin_setting_heading('enrol_ldap_server_settings', get_string('server_settings', 'enrol_ldap'), ''));
|
||||
$settings->add(new admin_setting_configtext_trim_lower('enrol_ldap/host_url', get_string('host_url_key', 'enrol_ldap'), get_string('host_url', 'enrol_ldap'), ''));
|
||||
@ -63,9 +66,6 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configselect('enrol_ldap/user_search_sub', get_string('user_search_sub_key', 'enrol_ldap'), get_string('user_search_sub', 'enrol_ldap'), 0, $options));
|
||||
$options = ldap_supported_usertypes();
|
||||
$settings->add(new admin_setting_configselect('enrol_ldap/user_type', get_string('user_type_key', 'enrol_ldap'), get_string('user_type', 'enrol_ldap'), 'default', $options));
|
||||
|
||||
if (!defined('LDAP_DEREF_NEVER')) define ('LDAP_DEREF_NEVER', 0);
|
||||
if (!defined('LDAP_DEREF_ALWAYS')) define ('LDAP_DEREF_ALWAYS', 3);
|
||||
$options = array();
|
||||
$options[LDAP_DEREF_NEVER] = get_string('no');
|
||||
$options[LDAP_DEREF_ALWAYS] = get_string('yes');
|
||||
@ -104,3 +104,4 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configselect('enrol_ldap/nested_groups', get_string('nested_groups_key', 'enrol_ldap'), get_string('nested_groups', 'enrol_ldap'), 0, $options));
|
||||
$settings->add(new admin_setting_configtext_trim_lower('enrol_ldap/group_memberofattribute', get_string('group_memberofattribute_key', 'enrol_ldap'), get_string('group_memberofattribute', 'enrol_ldap'), '', true, true));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user