mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Apply modularity to the creation of the log file during restore to a new course.
Remove the responsibility for loging the application of the course start date offset, from activity modules to the backup module. Merged from stable branch
This commit is contained in:
parent
352b8da86a
commit
cf0b1faded
17 changed files with 150 additions and 293 deletions
|
@ -108,9 +108,9 @@ function hotpot_restore_mods($mod, $restore) {
|
|||
}
|
||||
|
||||
// if necessary, adjust HotPot date/time fields and write to restorelog
|
||||
hotpot_restore_dates(
|
||||
'Hotpot', $restore, $xml, array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED')
|
||||
);
|
||||
if ($restore->course_startdateoffset) {
|
||||
restore_log_date_changes('Hotpot', $restore, $xml, array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED'));
|
||||
}
|
||||
|
||||
$status = hotpot_restore_records(
|
||||
$restore, $status, $xml, $table, $foreign_keys, $more_restore
|
||||
|
@ -479,39 +479,4 @@ function hotpot_restore_logs($restore, $log) {
|
|||
} // end switch
|
||||
return $status ? $log : false;
|
||||
}
|
||||
function hotpot_restore_dates($recordtype, &$restore, &$xml, $TAGS, $NAMETAG='NAME') {
|
||||
global $CFG;
|
||||
if (!empty($restore->course_startdateoffset)) {
|
||||
|
||||
// check course backup data directory exists
|
||||
$course_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
|
||||
check_dir_exists($course_dir, true);
|
||||
|
||||
// open $restorelog and start output for this HotPot
|
||||
$restorelog = fopen("$course_dir/restorelog.html", "a");
|
||||
fwrite ($restorelog, "<br>Hotpot - ".$xml['NAME'][0]['#']." <br>");
|
||||
|
||||
// loop through time fields
|
||||
$TAGS = array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED');
|
||||
foreach ($TAGS as $TAG) {
|
||||
|
||||
// check $TAG has a sensible value
|
||||
if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#'])) {
|
||||
|
||||
// write old date to $restorelog
|
||||
$value = $xml[$TAG][0]['#'];
|
||||
$date = usergetdate($value);
|
||||
fwrite ($restorelog, "$TAG was ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']);
|
||||
|
||||
// write new date to $restorelog
|
||||
$value += $restore->course_startdateoffset;
|
||||
$date = usergetdate($value);
|
||||
fwrite ($restorelog, " $TAG is now ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
|
||||
|
||||
// update $value in $xml tree (as a string)
|
||||
$xml[$TAG][0]['#'] = "$value";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue