]> git.mjollnir.org Git - moodle.git/commitdiff
Now new resources are included in backup & restore.
authorstronk7 <stronk7>
Tue, 27 Jul 2004 23:05:05 +0000 (23:05 +0000)
committerstronk7 <stronk7>
Tue, 27 Jul 2004 23:05:05 +0000 (23:05 +0000)
1.4--->1.4 and 1.3--->1.4 conversions are working fine.
Tomorrow I'll try the backwards conversion (1.4--->1.3).
Bug 1674
(http://moodle.org/bugs/bug.php?op=show&bugid=1674)

backup/restorelib.php
backup/version.php
mod/resource/backuplib.php
mod/resource/restorelib.php

index 90a932f78005b9e0aeef71b7609ef35195102480..10d236a02870f1dc615e1e935b7d2aa48573546a 100644 (file)
         }
 
         $formatwiki = FORMAT_WIKI;
-        $typewiki = WIKITEXT;
  
         //FORUM: Decode every POST (message) in the course
         //Check we are restoring forums
         //Check we are restoring resources
         if ($restore->mods['resource']->restore == 1) {
             echo "<li>".get_string("from")." ".get_string("modulenameplural","resource");
-            //Get all course resources of type=8 WIKITEXT being restored
+            //Get all course resources of type='text' and options=FORMAT_WIKI being restored
             if ($resources = get_records_sql ("SELECT r.id, r.alltext
                                        FROM {$CFG->prefix}resource r,
                                             {$CFG->prefix}backup_ids b
                                        WHERE r.course = $restore->course_id AND
-                                             r.type = $typewiki AND
+                                             r.type = 'text' AND
+                                             r.options = $formatwiki AND
                                              b.backup_code = $restore->backup_unique_code AND
                                              b.table_name = 'resource' AND
                                              b.new_id = r.id")) {
index 58b967b55c40a9d6ba983e3b2812a4c01541a688..d3cd19421ef89b8cdbaf432a63187c86f4f54d9b 100644 (file)
@@ -5,6 +5,6 @@
 // database (backup_version) to determine whether upgrades should
 // be performed (see db/backup_*.php)
 
-$backup_version = 2004072700;   // The current version is a date (YYYYMMDDXX)
+$backup_version = 2004072701;   // The current version is a date (YYYYMMDDXX)
 
 $backup_release = "1.4 development";  // User-friendly version number
index fb8c8e5dce10b94e80e2072337ac45f49deb7e03..109192d60ddf564010eae87f75166c72b8c273ac 100644 (file)
@@ -36,6 +36,8 @@
                 fwrite ($bf,full_tag("REFERENCE",4,false,$resource->reference));
                 fwrite ($bf,full_tag("SUMMARY",4,false,$resource->summary));
                 fwrite ($bf,full_tag("ALLTEXT",4,false,$resource->alltext));
+                fwrite ($bf,full_tag("POPUP",4,false,$resource->popup));
+                fwrite ($bf,full_tag("OPTIONS",4,false,$resource->options));
                 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified));
                 //End mod
                 $status = fwrite ($bf,end_tag("MOD",3,true));
index f80a6bd60cd502b4f2788d2f80705f5a45ef9f5c..1f8ce293abea10c397b052f0f92c006e0adbdd0d 100644 (file)
             $resource->reference = backup_todb($info['MOD']['#']['REFERENCE']['0']['#']);
             $resource->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
             $resource->alltext = backup_todb($info['MOD']['#']['ALLTEXT']['0']['#']);
+            $resource->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
+            $resource->options = backup_todb($info['MOD']['#']['OPTIONS']['0']['#']);
             $resource->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#'];
+
+            //To mantain compatibility, in 1.4 the type and alltext meaning has changed and
+            //two new fields have arrived (popup and options). We have to modify somethigs
+            //if the popup field isn't present in the backup file to be upwards compatible.
+            if (! isset($info['MOD']['#']['POPUP']['0']['#'])) { //It's a pre-14 backup file
+                //Move alltext to popup in 3 and 5 resource types
+                if ($resource->type == 3 || $resource->type == 5) {
+                    $resource->popup = $resource->alltext;
+                    $resource->alltext = '';
+                }
+                //Reencode the type field to its new values and fill the options field as needed
+                //Array 1-9 of new types
+                $types = array ('','reference','file','file','text','file',
+                                   'html','file','text','directory');
+                //Array 1-9 of corresponding options
+                $options = array ('','','frame','','0','',
+                                     '','','3','');
+                //Make the conversion
+                $oldtype = $resource->type;
+                $resource->type = $types[$oldtype];
+                $resource->options = $options[$oldtype];
+            }
  
             //The structure is equal to the db, so insert the resource
             $newid = insert_record ("resource",$resource);