Merge branch 'MDL-67650-forced-checkbox-textarea-MOODLE_39_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_39_STABLE
This commit is contained in:
+35
-16
@@ -1761,6 +1761,27 @@ abstract class admin_setting {
|
||||
$this->set_flag_options($enabled, $default, 'required', new lang_string('required', 'core_admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this option forced in config.php?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readonly(): bool {
|
||||
global $CFG;
|
||||
|
||||
if (empty($this->plugin)) {
|
||||
if (array_key_exists($this->name, $CFG->config_php_settings)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (array_key_exists($this->plugin, $CFG->forced_plugin_settings)
|
||||
and array_key_exists($this->name, $CFG->forced_plugin_settings[$this->plugin])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently saved value for a setting flag
|
||||
*
|
||||
@@ -2460,6 +2481,7 @@ class admin_setting_configtext extends admin_setting {
|
||||
'name' => $this->get_full_name(),
|
||||
'value' => $data,
|
||||
'forceltr' => $this->get_force_ltr(),
|
||||
'readonly' => $this->is_readonly(),
|
||||
];
|
||||
$element = $OUTPUT->render_from_template('core_admin/setting_configtext', $context);
|
||||
|
||||
@@ -2568,6 +2590,7 @@ class admin_setting_configtextarea extends admin_setting_configtext {
|
||||
'name' => $this->get_full_name(),
|
||||
'value' => $data,
|
||||
'forceltr' => $this->get_force_ltr(),
|
||||
'readonly' => $this->is_readonly(),
|
||||
];
|
||||
$element = $OUTPUT->render_from_template('core_admin/setting_configtextarea', $context);
|
||||
|
||||
@@ -2664,25 +2687,15 @@ class admin_setting_configpasswordunmask extends admin_setting_configtext {
|
||||
* @return string Rendered HTML
|
||||
*/
|
||||
public function output_html($data, $query='') {
|
||||
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;
|
||||
}
|
||||
}
|
||||
global $OUTPUT;
|
||||
|
||||
$context = (object) [
|
||||
'id' => $this->get_id(),
|
||||
'name' => $this->get_full_name(),
|
||||
'size' => $this->size,
|
||||
'value' => $forced ? null : $data,
|
||||
'value' => $this->is_readonly() ? null : $data,
|
||||
'forceltr' => $this->get_force_ltr(),
|
||||
'forced' => $forced
|
||||
'readonly' => $this->is_readonly(),
|
||||
];
|
||||
$element = $OUTPUT->render_from_template('core_admin/setting_configpasswordunmask', $context);
|
||||
return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', null, $query);
|
||||
@@ -2787,7 +2800,7 @@ class admin_setting_configfile extends admin_setting_configtext {
|
||||
'value' => $data,
|
||||
'showvalidity' => !empty($data),
|
||||
'valid' => $data && file_exists($data),
|
||||
'readonly' => !empty($CFG->preventexecpath),
|
||||
'readonly' => !empty($CFG->preventexecpath) || $this->is_readonly(),
|
||||
'forceltr' => $this->get_force_ltr(),
|
||||
];
|
||||
|
||||
@@ -2972,6 +2985,7 @@ class admin_setting_configcheckbox extends admin_setting {
|
||||
'no' => $this->no,
|
||||
'value' => $this->yes,
|
||||
'checked' => (string) $data === $this->yes,
|
||||
'readonly' => $this->is_readonly(),
|
||||
];
|
||||
|
||||
$default = $this->get_defaultsetting();
|
||||
@@ -3416,6 +3430,7 @@ class admin_setting_configselect extends admin_setting {
|
||||
];
|
||||
}
|
||||
$context->options = $options;
|
||||
$context->readonly = $this->is_readonly();
|
||||
|
||||
$element = $OUTPUT->render_from_template($template, $context);
|
||||
|
||||
@@ -3574,6 +3589,7 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
|
||||
];
|
||||
}
|
||||
$context->options = $options;
|
||||
$context->readonly = $this->is_readonly();
|
||||
|
||||
if (is_null($default)) {
|
||||
$defaultinfo = NULL;
|
||||
@@ -3664,6 +3680,7 @@ class admin_setting_configtime extends admin_setting {
|
||||
$context = (object) [
|
||||
'id' => $this->get_id(),
|
||||
'name' => $this->get_full_name(),
|
||||
'readonly' => $this->is_readonly(),
|
||||
'hours' => array_map(function($i) use ($data) {
|
||||
return [
|
||||
'value' => $i,
|
||||
@@ -3838,6 +3855,7 @@ class admin_setting_configduration extends admin_setting {
|
||||
'id' => $this->get_id(),
|
||||
'name' => $this->get_full_name(),
|
||||
'value' => $data['v'],
|
||||
'readonly' => $this->is_readonly(),
|
||||
'options' => array_map(function($unit) use ($units, $data, $defaultunit) {
|
||||
return [
|
||||
'value' => $unit,
|
||||
@@ -10439,7 +10457,8 @@ class admin_setting_configcolourpicker extends admin_setting {
|
||||
'value' => $data,
|
||||
'icon' => $icon->export_for_template($OUTPUT),
|
||||
'haspreviewconfig' => !empty($this->previewconfig),
|
||||
'forceltr' => $this->get_force_ltr()
|
||||
'forceltr' => $this->get_force_ltr(),
|
||||
'readonly' => $this->is_readonly(),
|
||||
];
|
||||
|
||||
$element = $OUTPUT->render_from_template('core_admin/setting_configcolourpicker', $context);
|
||||
|
||||
Reference in New Issue
Block a user