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 backup procedure about this mod
20 function label_backup_mods($bf,$preferences) {
25 ////Iterate over label table
26 if ($labels = get_records ("label","course", $preferences->backup_course
,"id")) {
27 foreach ($labels as $label) {
28 if (backup_mod_selected($preferences,'label',$label->id
)) {
29 $status = label_backup_one_mod($bf,$preferences,$label);
36 function label_backup_one_mod($bf,$preferences,$label) {
40 if (is_numeric($label)) {
41 $label = get_record('label','id',$label);
47 fwrite ($bf,start_tag("MOD",3,true));
48 //Print assignment data
49 fwrite ($bf,full_tag("ID",4,false,$label->id
));
50 fwrite ($bf,full_tag("MODTYPE",4,false,"label"));
51 fwrite ($bf,full_tag("NAME",4,false,$label->name
));
52 fwrite ($bf,full_tag("CONTENT",4,false,$label->content
));
53 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$label->timemodified
));
55 $status = fwrite ($bf,end_tag("MOD",3,true));
60 ////Return an array of info (name,value)
61 function label_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
62 if (!empty($instances) && is_array($instances) && count($instances)) {
64 foreach ($instances as $id => $instance) {
65 $info +
= label_check_backup_mods_instances($instance,$backup_unique_code);
70 //First the course data
71 $info[0][0] = get_string("modulenameplural","label");
72 $info[0][1] = count_records("label", "course", "$course");
76 ////Return an array of info (name,value)
77 function label_check_backup_mods_instances($instance,$backup_unique_code) {
78 //First the course data
79 $info[$instance->id
.'0'][0] = '<b>'.$instance->name
.'</b>';
80 $info[$instance->id
.'0'][1] = '';