mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-73831 adminpresets: Display current/new value for settings
Before applying a preset, the settings are displayed and, in some cases, the Current/New value columns were empty. This patch fixes it and guarantees this information is updated properly every time the set_value() method is called.
This commit is contained in:
parent
e94167174a
commit
49aef9f9bc
@ -28,6 +28,8 @@ class adminpresets_admin_setting_configcheckbox extends adminpresets_setting {
|
||||
|
||||
protected function set_value($value) {
|
||||
$this->value = clean_param($value, PARAM_BOOL);
|
||||
$this->set_visiblevalue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,10 @@ class adminpresets_admin_setting_configcheckbox_with_advanced extends adminprese
|
||||
*/
|
||||
protected function set_visiblevalue() {
|
||||
parent::set_visiblevalue();
|
||||
$value = $this->attributesvalues[$this->attributes['adv']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'advanced');
|
||||
|
||||
if (!is_null($this->attributesvalues) && array_key_exists($this->attributes['adv'], $this->attributesvalues)) {
|
||||
$value = $this->attributesvalues[$this->attributes['adv']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'advanced');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ class adminpresets_admin_setting_configcheckbox_with_lock extends adminpresets_a
|
||||
*/
|
||||
protected function set_visiblevalue() {
|
||||
parent::set_visiblevalue();
|
||||
$value = $this->attributesvalues[$this->attributes['locked']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'locked');
|
||||
if (!is_null($this->attributesvalues) && array_key_exists($this->attributes['locked'], $this->attributesvalues)) {
|
||||
$value = $this->attributesvalues[$this->attributes['locked']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'locked');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,12 @@ class adminpresets_admin_setting_configiplist extends adminpresets_admin_setting
|
||||
// Check ip format.
|
||||
if ($this->settingdata->validate($value) !== true) {
|
||||
$this->value = false;
|
||||
$this->set_visiblevalue();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
$this->set_visiblevalue();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ class adminpresets_admin_setting_configmultiselect extends adminpresets_setting
|
||||
|
||||
if ($key == $option) {
|
||||
$this->value = $option;
|
||||
$this->set_visiblevalue();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -48,8 +49,10 @@ class adminpresets_admin_setting_configmultiselect extends adminpresets_setting
|
||||
|
||||
$value = implode(',', $options);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
$this->set_visiblevalue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function set_visiblevalue() {
|
||||
|
@ -43,12 +43,13 @@ class adminpresets_admin_setting_configselect extends adminpresets_setting {
|
||||
|
||||
if ($key == $value) {
|
||||
$this->value = $value;
|
||||
$this->set_visiblevalue();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = false;
|
||||
$this->set_visiblevalue();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ class adminpresets_admin_setting_configtext extends adminpresets_setting {
|
||||
} else {
|
||||
$this->value = clean_param($this->value, constant($paramtype));
|
||||
}
|
||||
$this->set_visiblevalue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ class adminpresets_admin_setting_configtext_with_advanced extends adminpresets_a
|
||||
*/
|
||||
protected function set_visiblevalue() {
|
||||
parent::set_visiblevalue();
|
||||
$value = $this->attributesvalues[$this->attributes['fix']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'advanced');
|
||||
if (!is_null($this->attributesvalues) && array_key_exists($this->attributes['fix'], $this->attributesvalues)) {
|
||||
$value = $this->attributesvalues[$this->attributes['fix']];
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($value, 'advanced');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,9 +56,12 @@ class adminpresets_admin_setting_configtime extends adminpresets_setting {
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
$this->set_visiblevalue();
|
||||
}
|
||||
|
||||
protected function set_visiblevalue() {
|
||||
$this->visiblevalue = $this->value . ':' . $this->attributesvalues[$this->settingdata->name2];
|
||||
if (!is_null($this->attributesvalues) && array_key_exists($this->settingdata->name2, $this->attributesvalues)) {
|
||||
$this->visiblevalue = $this->value . ':' . $this->attributesvalues[$this->settingdata->name2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,14 +46,16 @@ class adminpresets_admin_setting_gradecat_combo extends adminpresets_admin_setti
|
||||
protected function set_visiblevalue() {
|
||||
parent::set_visiblevalue();
|
||||
|
||||
$flagvalue = $this->attributesvalues[$this->settingdata->name . '_flag'];
|
||||
if (!is_null($this->attributesvalues) && array_key_exists($this->settingdata->name . '_flag', $this->attributesvalues)) {
|
||||
$flagvalue = $this->attributesvalues[$this->settingdata->name . '_flag'];
|
||||
|
||||
if (isset($flagvalue)) {
|
||||
$forcedvalue = (($flagvalue % 2) == 1);
|
||||
$advancedvalue = ($flagvalue >= 2);
|
||||
if (isset($flagvalue)) {
|
||||
$forcedvalue = (($flagvalue % 2) == 1);
|
||||
$advancedvalue = ($flagvalue >= 2);
|
||||
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($forcedvalue, 'forced');
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($advancedvalue, 'advanced');
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($forcedvalue, 'forced');
|
||||
$this->visiblevalue .= $this->delegation->extra_set_visiblevalue($advancedvalue, 'advanced');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ class adminpresets_admin_setting_special_backupdays extends adminpresets_setting
|
||||
|
||||
protected function set_value($value) {
|
||||
$this->value = clean_param($value, PARAM_SEQUENCE);
|
||||
$this->set_visiblevalue();
|
||||
}
|
||||
|
||||
protected function set_visiblevalue() {
|
||||
|
@ -113,6 +113,11 @@ class adminpresets_setting {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the setting value.
|
||||
*
|
||||
* @return mixed The setting value
|
||||
*/
|
||||
public function get_value() {
|
||||
return $this->value;
|
||||
}
|
||||
@ -127,6 +132,7 @@ class adminpresets_setting {
|
||||
*/
|
||||
protected function set_value($value) {
|
||||
$this->value = $value;
|
||||
$this->set_visiblevalue();
|
||||
}
|
||||
|
||||
public function get_visiblevalue() {
|
||||
|
@ -41,6 +41,8 @@ Feature: I can apply presets
|
||||
And I should see "Calculated multichoice" in the "Setting changes" "table"
|
||||
And I should see "Calculated simple" in the "Setting changes" "table"
|
||||
And I should see "Chat" in the "Setting changes" "table"
|
||||
And "Chat" row "Current value" column of "Setting changes" table should contain "Enabled"
|
||||
And "Chat" row "New value" column of "Setting changes" table should contain "Disabled"
|
||||
And I should see "Cohort sync" in the "Setting changes" "table"
|
||||
And I should see "Comments" in the "Setting changes" "table"
|
||||
And I should see "Course completion status" in the "Setting changes" "table"
|
||||
@ -51,6 +53,8 @@ Feature: I can apply presets
|
||||
And I should see "Drag and drop onto image" in the "Setting changes" "table"
|
||||
And I should see "Embedded answers (Cloze)" in the "Setting changes" "table"
|
||||
And I should see "Enable badges" in the "Setting changes" "table"
|
||||
And "Enable badges" row "Current value" column of "Setting changes" table should contain "Yes"
|
||||
And "Enable badges" row "New value" column of "Setting changes" table should contain "No"
|
||||
And I should see "Enable blogs" in the "Setting changes" "table"
|
||||
And I should see "Enable comments" in the "Setting changes" "table"
|
||||
And I should see "Enable competencies" in the "core_competency" "table_row"
|
||||
@ -70,6 +74,8 @@ Feature: I can apply presets
|
||||
And I should see "Login" in the "Setting changes" "table"
|
||||
And I should see "Main menu" in the "Setting changes" "table"
|
||||
And I should see "Maximum number of attachments" in the "Setting changes" "table"
|
||||
And "Maximum number of attachments" row "Current value" column of "Setting changes" table should contain "9"
|
||||
And "Maximum number of attachments" row "New value" column of "Setting changes" table should contain "3"
|
||||
And I should see "Mentees" in the "Setting changes" "table"
|
||||
And I should see "Network servers" in the "Setting changes" "table"
|
||||
And I should see "Numerical" in the "Setting changes" "table"
|
||||
|
@ -54,6 +54,7 @@ class adminpresets_auth_ldap_admin_setting_special_contexts_configtext extends a
|
||||
} else {
|
||||
$this->value = clean_param($this->value, constant($paramtype));
|
||||
}
|
||||
$this->set_visiblevalue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user