From 936402278ba52529393f304c65bc85b5d6fd003a Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Fri, 15 Jun 2012 02:27:18 +0200 Subject: [PATCH] MDL-33756 backup: converters only available in general course backups. --- backup/moodle2/backup_final_task.class.php | 30 +++++++++++----------- backup/moodle2/backup_root_task.class.php | 15 ++++++----- backup/util/plan/backup_plan.class.php | 4 +++ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/backup/moodle2/backup_final_task.class.php b/backup/moodle2/backup_final_task.class.php index abbecb8be79..45d491af3c0 100644 --- a/backup/moodle2/backup_final_task.class.php +++ b/backup/moodle2/backup_final_task.class.php @@ -113,27 +113,27 @@ class backup_final_task extends backup_task { require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php'); - //Checking if we have some converter involved in the process - $converters = convert_helper::available_converters(false); - //Conversion status + // Look for converter steps only in type course and mode general backup operations. $conversion = false; - foreach ($converters as $value) { - if ($this->get_setting_value($value)) { - //zip class - $zip_contents = "{$value}_zip_contents"; - $store_backup_file = "{$value}_store_backup_file"; - $convert = "{$value}_backup_convert"; + if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) { + $converters = convert_helper::available_converters(false); + foreach ($converters as $value) { + if ($this->get_setting_value($value)) { + // Zip class. + $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 $zip_contents("zip_contents_{$value}")); - $this->add_step(new $store_backup_file("save_backupfile_{$value}")); - if (!$conversion) { - $conversion = true; + $this->add_step(new $convert("package_convert_{$value}")); + $this->add_step(new $zip_contents("zip_contents_{$value}")); + $this->add_step(new $store_backup_file("save_backupfile_{$value}")); + if (!$conversion) { + $conversion = true; + } } } } - // 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) { // Generate the zip file (mbz extension) diff --git a/backup/moodle2/backup_root_task.class.php b/backup/moodle2/backup_root_task.class.php index 3bd46cfd517..cf2561634aa 100644 --- a/backup/moodle2/backup_root_task.class.php +++ b/backup/moodle2/backup_root_task.class.php @@ -70,12 +70,15 @@ class backup_root_task extends backup_task { $filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50)); $this->add_setting($filename); - //Sample custom settings - $converters = convert_helper::available_converters(false); - foreach ($converters as $cnv) { - $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); + // Present converter settings only in type course and mode general backup operations. + $converters = array(); + if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) { + $converters = convert_helper::available_converters(false); + foreach ($converters as $cnv) { + $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) diff --git a/backup/util/plan/backup_plan.class.php b/backup/util/plan/backup_plan.class.php index bf217fd9c10..43782215e35 100644 --- a/backup/util/plan/backup_plan.class.php +++ b/backup/util/plan/backup_plan.class.php @@ -67,6 +67,10 @@ class backup_plan extends base_plan implements loggable { return $this->controller->get_backupid(); } + public function get_type() { + return $this->controller->get_type(); + } + public function get_mode() { return $this->controller->get_mode(); }