MDL-23479 backup - various fixes in feedback backup & restore + delete old code ...
[moodle.git] / mod / feedback / restorelib.php
CommitLineData
1adbd2c3 1<?php
c70ad9f7 2 //This php script contains all the stuff to backup/restore
3 //feedback mods
4
5 //This is the "graphical" structure of the feedback mod:
6 //
7 // feedback---------------------------------feedback_tracking
8 // (CL,pk->id) (UL, pk->id, fk->feedback,completed)
9 // | |
10 // | |
11 // | |
12 // feedback_template feedback_completed
13 // (CL,pk->id) (UL, pk->id, fk->feedback)
14 // | |
15 // | |
16 // | |
17 // feedback_item---------------------------------feedback_value
18 // (ML,pk->id, fk->feedback, fk->template) (UL, pk->id, fk->item, fk->completed)
19 //
20 // Meaning: pk->primary key field of the table
21 // fk->foreign key to link with parent
22 // CL->course level info
23 // ML->modul level info
24 // UL->userid level info
25 // message->text of each feedback_posting
26 //
27 //-----------------------------------------------------------
1adbd2c3 28
c70ad9f7 29
30 //This function returns a log record with all the necessay transformations
31 //done. It's used by restore_log_module() to restore modules log.
32 function feedback_restore_logs($restore,$log) {
33
34 $status = false;
1adbd2c3 35
c70ad9f7 36 //Depending of the action, we recode different things
37 switch ($log->action) {
38 case "add":
39 if ($log->cmid) {
40 //Get the new_id of the module (to recode the info field)
41 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
42 if ($mod) {
43 $log->url = "view.php?id=".$log->cmid;
44 $log->info = $mod->new_id;
45 $status = true;
46 }
47 }
48 break;
49 case "update":
50 if ($log->cmid) {
51 //Get the new_id of the module (to recode the info field)
52 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
53 if ($mod) {
54 $log->url = "view.php?id=".$log->cmid;
55 $log->info = $mod->new_id;
56 $status = true;
57 }
58 }
59 break;
60 case "view":
61 if ($log->cmid) {
62 //Get the new_id of the module (to recode the info field)
63 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
64 if ($mod) {
65 $log->url = "view.php?id=".$log->cmid;
66 $log->info = $mod->new_id;
67 $status = true;
68 }
69 }
70 break;
71 case "add entry":
72 if ($log->cmid) {
73 //Get the new_id of the module (to recode the info field)
74 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
75 if ($mod) {
76 $log->url = "view.php?id=".$log->cmid;
77 $log->info = $mod->new_id;
78 $status = true;
79 }
80 }
81 break;
82 case "update entry":
83 if ($log->cmid) {
84 //Get the new_id of the module (to recode the info field)
85 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
86 if ($mod) {
87 $log->url = "view.php?id=".$log->cmid;
88 $log->info = $mod->new_id;
89 $status = true;
90 }
91 }
92 break;
93 case "view responses":
94 if ($log->cmid) {
95 //Get the new_id of the module (to recode the info field)
96 $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
97 if ($mod) {
98 $log->url = "report.php?id=".$log->cmid;
99 $log->info = $mod->new_id;
100 $status = true;
101 }
102 }
103 break;
104 case "update feedback":
105 if ($log->cmid) {
106 $log->url = "report.php?id=".$log->cmid;
107 $status = true;
108 }
109 break;
110 case "view all":
111 $log->url = "index.php?id=".$log->course;
112 $status = true;
113 break;
114 default:
115 if (!defined('RESTORE_SILENTLY')) {
116 echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />"; //Debug
117 }
118 break;
119 }
120
121 if ($status) {
122 $status = $log;
123 }
124 return $status;
125 }
126
1adbd2c3 127