Skip to content

Commit

Permalink
Restore IMPLEMENTED
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed May 31, 2003
1 parent 58d9f06 commit d6d7461
Showing 1 changed file with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions backup/mod/resource/restorelib.php
Expand Up @@ -17,30 +17,48 @@
//-----------------------------------------------------------

//This function executes all the restore procedure about this mod
function resource_restore_mods($bf,$preferences) {
function resource_restore_mods($mod,$restore) {

global $CFG;

$status = true;
$status = true;

//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);

////Iterate over resource table
$resources = get_records ("resource","course",$preferences->backup_course,"id");
if ($resources) {
foreach ($resources as $resource) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$resource->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"resource"));
fwrite ($bf,full_tag("NAME",4,false,$resource->name));
fwrite ($bf,full_tag("TYPE",4,false,$resource->type));
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("TIMEMODIFIED",4,false,$resource->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
if ($data) {
//We have info, get and unserialize info
//First strip slashes
$temp = stripslashes($data->info);
//Now get completed xmlized object
$info = unserialize($temp);
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug

//Now, build the RESOURCE record structure
$resource->course = $restore->course_id;
$resource->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$resource->type = $info['MOD']['#']['TYPE']['0']['#'];
$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->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#'];

//The structure is equal to the db, so insert the resource
$newid = insert_record ("resource",$resource);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,$mod->id,
$newid,$data->info);

} else {
$status = false;
}
} else {
$status = false;
}

return $status;
}

Expand Down

0 comments on commit d6d7461

Please sign in to comment.