Permalink
Browse files

Now resource module backups from a 1.4 version can be restored in a 1.3.

Only two combinations aren't 100% compatible:
    - Program resources.
    - Text without format in 1.4 is changed to type 4 (plain text)
So resource restore is 99% backwards compatible in 1.3
Bug 1674
(http://moodle.org/bugs/bug.php?op=show&bugid=1674)
  • Loading branch information...
1 parent 19ca7ac commit 3ce0b094979b322c69d986b55f0351fa0da6dff6 stronk7 committed Jul 29, 2004
Showing with 31 additions and 0 deletions.
  1. +31 −0 mod/resource/restorelib.php
@@ -40,7 +40,38 @@ function resource_restore_mods($mod,$restore) {
$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']['#'];
+
+ //We are going to mantain here backwards compatibity with 1.4 resorces (exception!!)
+ //so we have to make some conversions...
+ //If the type field isn't numeric we are restoring a newer (1.4) resource
+ if (!is_numeric($resource->type)) {
+ //Harcode the conversions
+ if ($resource->type == 'reference') {
+ $resource->type = '1';
+ } else if ($resource->type == 'file' && $resource->options == 'frame') {
+ $resource->type = '2';
+ } else if ($resource->type == 'file') {
+ if (strtoupper(substr($resource->reference,0,5)) == 'HTTP:') {
+ $resource->type = '5';
+ $resource->alltext = $resource->popup;
+ } else {
+ $resource->type = '3';
+ $resource->alltext = $resource->popup;
+ }
+ } else if ($resource->type == 'text' && ($resource->options == '0' || $resource->options == '2')) {
+ $resource->type = '4';
+ } else if ($resource->type == 'html') {
+ $resource->type = '6';
+ } else if ($resource->type == 'text' && $resource->options == '3') {
+ $resource->type = '8';
+ } else if ($resource->type == 'directory') {
+ $resource->type = '9';
+ }
+
+ }
//The structure is equal to the db, so insert the resource
$newid = insert_record ("resource",$resource);

0 comments on commit 3ce0b09

Please sign in to comment.