MDL-37459 admin: Set the default setting flags on a new install.

Make sure the default flags for all settings are saved on a new install.
This commit is contained in:
Damyon Wiese 2013-06-13 12:46:45 +08:00 committed by Marina Glancy
parent e3b472e82c
commit 7e815a6eac

View File

@ -1624,7 +1624,7 @@ abstract class admin_setting {
/**
* Write the values of the flags for this admin setting.
*
* @param array $data - The data submitted from the form.
* @param array $data - The data submitted from the form or null to set the default value for new installs.
* @return bool - true if successful.
*/
public function write_setting_flags($data) {
@ -1938,13 +1938,17 @@ class admin_setting_flag {
* Save the submitted data for this flag - or set it to the default if $data is null.
*
* @param admin_setting $setting - The admin setting for this flag
* @param array $data - The data submitted from the form.
* @param array $data - The data submitted from the form or null to set the default value for new installs.
* @return bool
*/
public function write_setting_flag(admin_setting $setting, $data) {
$result = true;
if ($this->is_enabled()) {
$value = !empty($data[$setting->get_full_name() . '_' . $this->get_shortname()]);
if (!isset($data)) {
$value = $this->get_default();
} else {
$value = !empty($data[$setting->get_full_name() . '_' . $this->get_shortname()]);
}
$result = $setting->config_write($setting->name . '_' . $this->get_shortname(), $value);
}
@ -6404,6 +6408,7 @@ function admin_apply_default_settings($node=NULL, $unconditional=true) {
continue;
}
$setting->write_setting($defaultsetting);
$setting->write_setting_flags(null);
}
}
}