diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php index f58145f8b72..5a3773867cd 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php @@ -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; } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php index dcf0ef64461..971d985ed57 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php @@ -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'); + } } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php index f387ca4f60a..8bec3bac896 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php @@ -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'); + } } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configiplist.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configiplist.php index 8bdd571d1e3..c2ffe471cf2 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configiplist.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configiplist.php @@ -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; } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php index 2052ac5c054..7ae72675a32 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php @@ -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() { diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php index 17a4ed7c698..2d3396833ae 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configselect.php @@ -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; } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext.php index fbac4c15a8c..858c84ad44f 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext.php @@ -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; } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php index c7538b64d49..d85785ed6ad 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php @@ -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'); + } } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php index da45019b714..67e56d5f376 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_configtime.php @@ -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]; + } } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php index e31a590ec51..b32f8144bdd 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php @@ -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'); + } } } } diff --git a/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php b/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php index a40df998bc5..70739a82caf 100644 --- a/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php +++ b/admin/presets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php @@ -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() { diff --git a/admin/presets/classes/local/setting/adminpresets_setting.php b/admin/presets/classes/local/setting/adminpresets_setting.php index 3d748c2f502..aca5bb8b118 100644 --- a/admin/presets/classes/local/setting/adminpresets_setting.php +++ b/admin/presets/classes/local/setting/adminpresets_setting.php @@ -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() { diff --git a/admin/tool/admin_presets/tests/behat/apply_presets.feature b/admin/tool/admin_presets/tests/behat/apply_presets.feature index 49746a75cf0..251fbbab3c3 100644 --- a/admin/tool/admin_presets/tests/behat/apply_presets.feature +++ b/admin/tool/admin_presets/tests/behat/apply_presets.feature @@ -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" diff --git a/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php b/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php index 2391b3c2b2c..b3920693a98 100644 --- a/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php +++ b/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php @@ -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; }