2 //This php script contains all the stuff to backup/restore
5 //This is the "graphical" structure of the attendance mod:
13 // (UL,pk->id, fk->dayid)
15 // Meaning: pk->primary key field of the table
16 // fk->foreign key to link with parent
17 // nt->nested field (recursive data)
18 // CL->course level info
19 // UL->user level info
20 // files->table may have files)
22 //-----------------------------------------------------------
24 //This function executes all the restore procedure about this mod
25 function attendance_restore_mods($mod,$restore) {
31 //Get record from backup_ids
32 $data = backup_getid($restore->backup_unique_code
,$mod->modtype
,$mod->id
);
35 //Now get completed xmlized object
37 //traverse_xmlize($info); //Debug
38 //print_object ($GLOBALS['traverse_array']); //Debug
39 //$GLOBALS['traverse_array']=""; //Debug
41 //Now, build the ATTENDANCE record structure
42 $attendance->course
= $restore->course_id
;
43 $attendance->name
= backup_todb($info['MOD']['#']['NAME']['0']['#']);
44 $attendance->day
= backup_todb($info['MOD']['#']['DAY']['0']['#']);
45 $attendance->hours
= backup_todb($info['MOD']['#']['HOURS']['0']['#']);
46 $attendance->roll
= backup_todb($info['MOD']['#']['ROLL']['0']['#']);
47 $attendance->notes
= backup_todb($info['MOD']['#']['NOTES']['0']['#']);
48 $attendance->timemodified
= backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
49 $attendance->dynsection
= backup_todb($info['MOD']['#']['DYNSECTION']['0']['#']);
50 $attendance->edited
= backup_todb($info['MOD']['#']['EDITED']['0']['#']);
51 $attendance->autoattend
= backup_todb($info['MOD']['#']['AUTOATTEND']['0']['#']);
53 //The structure is equal to the db, so insert the attendance
54 $newid = insert_record ("attendance",$attendance);
57 echo "<li>".get_string("modulename","attendance")." \"".$attendance->name
."\"</li>";
61 //We have the newid, update backup_ids
62 backup_putid($restore->backup_unique_code
,$mod->modtype
,
64 //Now check if want to restore user data and do it.
65 if ($restore->mods
['attendance']->userinfo
) {
66 //Restore attendance_roll
67 $status = attendance_roll_restore_mods ($newid,$info,$restore);
79 //This function restores the attendance_roll
80 function attendance_roll_restore_mods($attendance_id,$info,$restore) {
87 $rolls = $info['MOD']['#']['ROLLS']['0']['#']['ROLL'];
90 for($i = 0; $i < sizeof($rolls); $i++
) {
91 $rol_info = $rolls[$i];
92 //traverse_xmlize($rol_info); //Debug
93 //print_object ($GLOBALS['traverse_array']); //Debug
94 //$GLOBALS['traverse_array']=""; //Debug
96 //We'll need this later!!
97 $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
98 $olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
100 //Now, build the ATTENDANCE_ROLL record structure
101 $roll->dayid
= $attendance_id;
102 $roll->userid
= backup_todb($rol_info['#']['USERID']['0']['#']);
103 $roll->hour
= backup_todb($rol_info['#']['HOUR']['0']['#']);
104 $roll->status
= backup_todb($rol_info['#']['STATUS']['0']['#']);
105 $roll->notes
= backup_todb($rol_info['#']['NOTES']['0']['#']);
107 //We have to recode the userid field
108 $user = backup_getid($restore->backup_unique_code
,"user",$roll->userid
);
110 $roll->userid
= $user->new_id
;
113 //The structure is equal to the db, so insert the attendance_roll
114 $newid = insert_record ("attendance_roll",$roll);
117 if (($i+
1) %
50 == 0) {
119 if (($i+
1) %
1000 == 0) {
126 //We have the newid, update backup_ids
127 backup_putid($restore->backup_unique_code
,"attendance_roll",$oldid,