Merge branch 'MDL-63734-master_hidepassword' of https://github.com/ledship/moodle

This commit is contained in:
Andrew Nicols
2020-01-08 09:39:06 +08:00
2 changed files with 31 additions and 3 deletions
@@ -24,15 +24,30 @@
* size - form element size
* value - form element value
* id - element id
* forced - has value been defined in config.php
Example context (json):
{
"name": "test",
"id": "test0",
"size": "8",
"value": "secret"
"value": "secret",
"forced": false
}
}}
{{#forced}}
<div class="form-password">
<input type="text"
name = "{{ name }}"
id="{{ id }}"
value="********"
size="{{ size }}"
class="form-control"
disabled
>
</div>
{{/forced}}
{{^forced}}
<div class="form-password">
<span data-passwordunmask="wrapper" data-passwordunmaskid="{{ id }}">
<span data-passwordunmask="editor">
@@ -61,3 +76,4 @@ require(['core_form/passwordunmask'], function(PasswordUnmask) {
new PasswordUnmask("{{ id }}");
});
{{/js}}
{{/forced}}
+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);