MDL-63734 adminlib: Hide password when defined in config.php

This will hide the password on admin_setting_configpasswordunmask fields when it is already defined in config.php
This commit is contained in:
Alexander
2019-12-23 14:42:53 +13:00
parent 6aacd8d6d1
commit 6ed86eca7a
2 changed files with 31 additions and 3 deletions
+14 -2
View File
@@ -2641,13 +2641,25 @@ class admin_setting_configpasswordunmask extends admin_setting_configtext {
* @return string Rendered HTML
*/
public function output_html($data, $query='') {
global $OUTPUT;
global $OUTPUT, $CFG;
$forced = false;
if (empty($this->plugin)) {
if (array_key_exists($this->name, $CFG->config_php_settings)) {
$forced = true;
}
} else {
if (array_key_exists($this->plugin, $CFG->forced_plugin_settings)
and array_key_exists($this->name, $CFG->forced_plugin_settings[$this->plugin])) {
$forced = true;
}
}
$context = (object) [
'id' => $this->get_id(),
'name' => $this->get_full_name(),
'size' => $this->size,
'value' => $data,
'value' => $forced ? null : $data,
'forceltr' => $this->get_force_ltr(),
'forced' => $forced
];
$element = $OUTPUT->render_from_template('core_admin/setting_configpasswordunmask', $context);
return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', null, $query);