2 //This php script contains all the stuff to backup/restore
5 //This is the "graphical" structure of the label mod:
10 // Meaning: pk->primary key field of the table
11 // fk->foreign key to link with parent
12 // nt->nested field (recursive data)
13 // CL->course level info
14 // UL->user level info
15 // files->table may have files)
17 //-----------------------------------------------------------
19 //This function executes all the restore procedure about this mod
20 function label_restore_mods($mod,$restore) {
26 //Get record from backup_ids
27 $data = backup_getid($restore->backup_unique_code
,$mod->modtype
,$mod->id
);
30 //Now get completed xmlized object
32 //traverse_xmlize($info); //Debug
33 //print_object ($GLOBALS['traverse_array']); //Debug
34 //$GLOBALS['traverse_array']=""; //Debug
36 //Now, build the LABEL record structure
37 $label->course
= $restore->course_id
;
38 $label->name
= backup_todb($info['MOD']['#']['NAME']['0']['#']);
39 $label->content
= backup_todb($info['MOD']['#']['CONTENT']['0']['#']);
40 $label->timemodified
= $info['MOD']['#']['TIMEMODIFIED']['0']['#'];
42 //The structure is equal to the db, so insert the label
43 $newid = insert_record ("label",$label);
46 if (!defined('RESTORE_SILENTLY')) {
47 echo "<li>".get_string("modulename","label")." \"".format_string(stripslashes($label->name
),true)."\"</li>";
52 //We have the newid, update backup_ids
53 backup_putid($restore->backup_unique_code
,$mod->modtype
,
66 function label_decode_content_links_caller($restore) {
70 if ($labels = get_records_sql ("SELECT l.id, l.content
71 FROM {$CFG->prefix}label l
72 WHERE l.course = $restore->course_id")) {
73 $i = 0; //Counter to send some output to the browser to avoid timeouts
74 foreach ($labels as $label) {
77 $content = $label->content
;
78 $result = restore_decode_content_links_worker($content,$restore);
80 if ($result != $content) {
82 $label->content
= addslashes($result);
83 $status = update_record("label", $label);
85 if (!defined('RESTORE_SILENTLY')) {
86 echo '<br /><hr />'.s($content).'<br />changed to<br />'.s($result).'<hr /><br />';
91 if (($i+
1) %
5 == 0) {
92 if (!defined('RESTORE_SILENTLY')) {
94 if (($i+
1) %
100 == 0) {
105 //This function returns a log record with all the necessay transformations
106 //done. It's used by restore_log_module() to restore modules log.
107 function label_restore_logs($restore,$log) {
111 //Depending of the action, we recode different things
112 switch ($log->action
) {
115 //Get the new_id of the module (to recode the info field)
116 $mod = backup_getid($restore->backup_unique_code
,$log->module
,$log->info
);
118 $log->url
= "view.php?id=".$log->cmid
;
119 $log->info
= $mod->new_id
;
126 //Get the new_id of the module (to recode the info field)
127 $mod = backup_getid($restore->backup_unique_code
,$log->module
,$log->info
);
129 $log->url
= "view.php?id=".$log->cmid
;
130 $log->info
= $mod->new_id
;
136 if (!defined('RESTORE_SILENTLY')) {
137 echo "action (".$log->module
."-".$log->action
.") unknown. Not restored<br />"; //Debug