Skip to content

Commit

Permalink
backup MDL-22142 Fixed dependency chaining through inspection in rela…
Browse files Browse the repository at this point in the history
…tion to the dependent setting rather than the prominent setting. Also did away with reference dealing with processing dependencies for mforms, new recursive structure returns managed property array instead.
  • Loading branch information
Sam Hemelryk committed May 3, 2010
1 parent 4032415 commit 6ed9a7d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
28 changes: 28 additions & 0 deletions backup/util/settings/base_setting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ public function get_all_dependencies() {
return $dependencies;
}

/**
* Gets an array of properties for all of the dependencies that will affect
* this setting.
*
* This method returns and array rather than the dependencies in order to
* minimise the memory footprint of for the potentially huge recursive
* dependency structure that we may be dealing with.
*
* This method also ensures that all dependencies are transmuted to affect
* the setting in question and that we don't provide any duplicates.
*
* @param string|null $settingname
* @return array
*/
public function get_my_dependency_properties($settingname=null) {
if ($settingname == null) {
$settingname = $this->get_ui_name();
}
$dependencies = array();
foreach ($this->dependenton as $dependenton) {
$properties = $dependenton->get_moodleform_properties();
$properties['setting'] = $settingname;
$dependencies[$properties['setting'].'-'.$properties['dependenton']] = $properties;
$dependencies = array_merge($dependencies, $dependenton->get_setting()->get_my_dependency_properties($settingname));
}
return $dependencies;
}

public function set_ui(backup_setting_ui $ui) {
$this->uisetting = $ui;
}
Expand Down
11 changes: 3 additions & 8 deletions backup/util/ui/backup_moodleform.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ protected function add_html_formatting(backup_setting $setting) {
*/
function add_fixed_setting(backup_setting $setting) {
global $OUTPUT;

$settingui = $setting->get_ui();
if ($setting->get_visibility() == backup_setting::VISIBLE) {
$this->add_html_formatting($setting);
Expand All @@ -209,16 +208,12 @@ function add_fixed_setting(backup_setting $setting) {
* Adds dependencies to the form recursively
*
* @param backup_setting $setting
* @param backup_setting $basesetting
*/
function add_dependencies(backup_setting $setting, $basesetting=null) {
function add_dependencies(backup_setting $setting) {
$mform = $this->_form;
if ($basesetting == null) {
$basesetting = $setting;
}
// Apply all dependencies for backup
foreach ($setting->get_all_dependencies() as $dependency) {
call_user_method_array('disabledIf', $this->_form, $dependency->get_moodleform_properties());
foreach ($setting->get_my_dependency_properties() as $key=>$dependency) {
call_user_method_array('disabledIf', $this->_form, $dependency);
}
}
/**
Expand Down

0 comments on commit 6ed9a7d

Please sign in to comment.