MDL-21432 backup - root task, inforef and users handling completed, various fixes

This commit is contained in:
Eloy Lafuente
2010-07-14 23:59:19 +00:00
parent 2087babba1
commit 482aac657a
20 changed files with 1013 additions and 23 deletions
@@ -89,6 +89,46 @@ class backup_section_task extends backup_task {
$this->built = true;
}
/**
* Exceptionally override the execute method, so, based in the section_included setting, we are able
* to skip the execution of one task completely
*/
public function execute() {
// Find section_included_setting
if (!$this->get_setting_value('included')) {
$this->log('section skipped by _included setting', backup::LOG_DEBUG, $this->name);
} else { // Setting tells us it's ok to execute
parent::execute();
}
}
/**
* Specialisation that, first of all, looks for the setting within
* the task with the the prefix added and later, delegates to parent
* without adding anything
*/
public function get_setting($name) {
$namewithprefix = 'section_' . $this->sectionid . '_' . $name;
$result = null;
foreach ($this->settings as $key => $setting) {
if ($setting->get_name() == $namewithprefix) {
if ($result != null) {
throw new base_task_exception('multiple_settings_by_name_found', $namewithprefix);
} else {
$result = $setting;
}
}
}
if ($result) {
return $result;
} else {
// Fallback to parent
return parent::get_setting($name);
}
}
// Protected API starts here
/**