From: stronk7 Date: Tue, 27 Jul 2004 23:05:05 +0000 (+0000) Subject: Now new resources are included in backup & restore. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d735b7ba9c3223620767c71d6aef85299f1086a5;p=moodle.git Now new resources are included in backup & restore. 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) --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 90a932f780..10d236a028 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -125,7 +125,6 @@ } $formatwiki = FORMAT_WIKI; - $typewiki = WIKITEXT; //FORUM: Decode every POST (message) in the course //Check we are restoring forums @@ -176,12 +175,13 @@ //Check we are restoring resources if ($restore->mods['resource']->restore == 1) { echo "
  • ".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")) { diff --git a/backup/version.php b/backup/version.php index 58b967b55c..d3cd19421e 100644 --- a/backup/version.php +++ b/backup/version.php @@ -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 diff --git a/mod/resource/backuplib.php b/mod/resource/backuplib.php index fb8c8e5dce..109192d60d 100644 --- a/mod/resource/backuplib.php +++ b/mod/resource/backuplib.php @@ -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)); diff --git a/mod/resource/restorelib.php b/mod/resource/restorelib.php index f80a6bd60c..1f8ce293ab 100644 --- a/mod/resource/restorelib.php +++ b/mod/resource/restorelib.php @@ -40,7 +40,31 @@ $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);