MDL-33756 backup: converters only available in general course backups.
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 15 Jun 2012 00:27:18 +0000 (02:27 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 15 Jun 2012 00:27:18 +0000 (02:27 +0200)
backup/moodle2/backup_final_task.class.php
backup/moodle2/backup_root_task.class.php
backup/util/plan/backup_plan.class.php

index abbecb8..45d491a 100644 (file)
@@ -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";
-
-                $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;
+        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;
+                    }
                 }
             }
         }
 
-
         // 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)
index 3bd46cf..cf25616 100644 (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));
         $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)
index bf217fd..4378221 100644 (file)
@@ -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();
     }