From ec1aa434488d0310bebeda0f33db6e2a21d850f7 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Tue, 5 Dec 2017 15:01:19 +0800 Subject: [PATCH] MDL-60969 auth_ldap: replace hardcoded strings in config settings --- auth/ldap/lang/en/auth_ldap.php | 2 +- auth/ldap/settings.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/auth/ldap/lang/en/auth_ldap.php b/auth/ldap/lang/en/auth_ldap.php index e74b63792c5..2f0fbd019de 100644 --- a/auth/ldap/lang/en/auth_ldap.php +++ b/auth/ldap/lang/en/auth_ldap.php @@ -43,7 +43,7 @@ $string['auth_ldapdescription'] = 'This method provides authentication against a entry in its database. This module can read user attributes from LDAP and prefill wanted fields in Moodle. For following logins only the username and password are checked.'; -$string['auth_ldap_expiration_desc'] = 'Select No to disable expired password checking or LDAP to read passwordexpiration time directly from LDAP'; +$string['auth_ldap_expiration_desc'] = 'Select \'{$a->no}\' to disable expired password checking or \'{$a->ldapserver}\' to read the password expiration time directly from the LDAP server'; $string['auth_ldap_expiration_key'] = 'Expiration'; $string['auth_ldap_expiration_warning_desc'] = 'Number of days before password expiration warning is issued.'; $string['auth_ldap_expiration_warning_key'] = 'Expiration warning'; diff --git a/auth/ldap/settings.php b/auth/ldap/settings.php index 5f6256923b0..7f26c00fb5e 100644 --- a/auth/ldap/settings.php +++ b/auth/ldap/settings.php @@ -185,12 +185,24 @@ if ($ADMIN->fulltree) { new lang_string('auth_ldap_passwdexpire_settings', 'auth_ldap'), '')); // Password Expiration. + + // Create the description lang_string object. + $strno = get_string('no'); + $strldapserver = get_string('pluginname', 'auth_ldap'); + $langobject = new stdClass(); + $langobject->no = $strno; + $langobject->ldapserver = $strldapserver; + $description = new lang_string('auth_ldap_expiration_desc', 'auth_ldap', $langobject); + + // Now create the options. $expiration = array(); - $expiration['0'] = 'no'; - $expiration['1'] = 'LDAP'; + $expiration['0'] = $strno; + $expiration['1'] = $strldapserver; + + // Add the setting. $settings->add(new admin_setting_configselect('auth_ldap/expiration', new lang_string('auth_ldap_expiration_key', 'auth_ldap'), - new lang_string('auth_ldap_expiration_desc', 'auth_ldap'), 0 , $expiration)); + $description, 0 , $expiration)); // Password Expiration warning. $settings->add(new admin_setting_configtext('auth_ldap/expiration_warning',