MDL-33756 backup: converters only available in general course backups.

This commit is contained in:
Eloy Lafuente (stronk7) 2012-06-15 02:27:18 +02:00
parent f8dfdb524b
commit 936402278b
3 changed files with 28 additions and 21 deletions

View file

@ -113,27 +113,27 @@ class backup_final_task extends backup_task {
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php'); require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
//Checking if we have some converter involved in the process // Look for converter steps only in type course and mode general backup operations.
$converters = convert_helper::available_converters(false);
//Conversion status
$conversion = false; $conversion = false;
foreach ($converters as $value) { if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) {
if ($this->get_setting_value($value)) { $converters = convert_helper::available_converters(false);
//zip class foreach ($converters as $value) {
$zip_contents = "{$value}_zip_contents"; if ($this->get_setting_value($value)) {
$store_backup_file = "{$value}_store_backup_file"; // Zip class.
$convert = "{$value}_backup_convert"; $zip_contents = "{$value}_zip_contents";
$store_backup_file = "{$value}_store_backup_file";
$convert = "{$value}_backup_convert";
$this->add_step(new $convert("package_convert_{$value}")); $this->add_step(new $convert("package_convert_{$value}"));
$this->add_step(new $zip_contents("zip_contents_{$value}")); $this->add_step(new $zip_contents("zip_contents_{$value}"));
$this->add_step(new $store_backup_file("save_backupfile_{$value}")); $this->add_step(new $store_backup_file("save_backupfile_{$value}"));
if (!$conversion) { if (!$conversion) {
$conversion = true; $conversion = true;
}
} }
} }
} }
// On backup::MODE_IMPORT, we don't have to zip nor store the the file, skip these steps // On backup::MODE_IMPORT, we don't have to zip nor store the the file, skip these steps
if (($this->plan->get_mode() != backup::MODE_IMPORT) && !$conversion) { if (($this->plan->get_mode() != backup::MODE_IMPORT) && !$conversion) {
// Generate the zip file (mbz extension) // Generate the zip file (mbz extension)

View file

@ -70,12 +70,15 @@ class backup_root_task extends backup_task {
$filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50)); $filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
$this->add_setting($filename); $this->add_setting($filename);
//Sample custom settings // Present converter settings only in type course and mode general backup operations.
$converters = convert_helper::available_converters(false); $converters = array();
foreach ($converters as $cnv) { if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) {
$formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false); $converters = convert_helper::available_converters(false);
$formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat'.$cnv, 'backup'))); foreach ($converters as $cnv) {
$this->add_setting($formatcnv); $formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false);
$formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat'.$cnv, 'backup')));
$this->add_setting($formatcnv);
}
} }
// Define users setting (keeping it on hand to define dependencies) // Define users setting (keeping it on hand to define dependencies)

View file

@ -67,6 +67,10 @@ class backup_plan extends base_plan implements loggable {
return $this->controller->get_backupid(); return $this->controller->get_backupid();
} }
public function get_type() {
return $this->controller->get_type();
}
public function get_mode() { public function get_mode() {
return $this->controller->get_mode(); return $this->controller->get_mode();
} }