MDL-23478 backup - adding support for fileareas to blocks
authorEloy Lafuente <stronk7@moodle.org>
Fri, 23 Jul 2010 17:36:38 +0000 (17:36 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Fri, 23 Jul 2010 17:36:38 +0000 (17:36 +0000)
backup/moodle2/backup_block_task.class.php
backup/moodle2/backup_default_block_task.class.php
backup/moodle2/backup_stepslib.php
backup/util/dbops/restore_dbops.class.php
blocks/html/backup/moodle2/backup_html_block_task.class.php
blocks/rss_client/backup/moodle2/backup_rss_client_block_task.class.php

index 8358a5b..d520869 100644 (file)
@@ -195,6 +195,11 @@ abstract class backup_block_task extends backup_task {
      */
     abstract protected function define_my_steps();
 
+    /**
+     * Define one array() of fileareas that each block controls
+     */
+    abstract public function get_fileareas();
+
     /**
      * Define one array() of configdata attributes
      * that need to be processed by the contenttransformer
index 4e99c66..b3f5eae 100644 (file)
@@ -38,6 +38,10 @@ class backup_default_block_task extends backup_block_task {
     protected function define_my_steps() {
     }
 
+    public function get_fileareas() {
+        return array();
+    }
+
     public function get_configdata_encoded_attributes() {
         return array();
     }
index 9ec6969..3248de5 100644 (file)
@@ -1049,6 +1049,11 @@ class backup_block_instance_structure_step extends backup_structure_step {
 
         $positions->set_source_table('block_positions', array('blockinstanceid' => backup::VAR_PARENTID));
 
+        // File anotations (for fileareas specified on each block)
+        foreach ($this->task->get_fileareas() as $filearea) {
+            $block->annotate_files('block_' . $this->task->get_blockname(), $filearea, null);
+        }
+
         // Return the root element (block)
         return $block;
     }
index 977d9a6..da04aeb 100644 (file)
@@ -43,7 +43,7 @@ abstract class restore_dbops {
             $included = false;
             // blocks, based in blocks setting and parent activity/course
             if ($task instanceof restore_block_task) {
-                if (!$task->get_setting('blocks')) { // Blocks not included, continue
+                if (!$task->get_setting_value('blocks')) { // Blocks not included, continue
                     continue;
                 }
                 $parent = basename(dirname(dirname($task->get_taskbasepath())));
index 324877e..8b0e152 100644 (file)
@@ -36,6 +36,10 @@ class backup_html_block_task extends backup_block_task {
     protected function define_my_steps() {
     }
 
+    public function get_fileareas() {
+        return array('content');
+    }
+
     public function get_configdata_encoded_attributes() {
         return array('text'); // We need to encode some attrs in configdata
     }
index 660bd2d..41d1dd6 100644 (file)
@@ -42,6 +42,10 @@ class backup_rss_client_block_task extends backup_block_task {
         $this->add_step(new backup_rss_client_block_structure_step('rss_client_structure', 'rss_client.xml'));
     }
 
+    public function get_fileareas() {
+        return array(); // No associated fileareas
+    }
+
     public function get_configdata_encoded_attributes() {
         return array(); // No special handling of configdata
     }