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)
}
$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")) {
// 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
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));
$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);