Remove the responsibility for loging the application of the course start date offset, from activity modules to the backup module.
Merged from stable branch
//Get admin->id for later use
$admin = get_admin();
$adminid = $admin->id;
- //First, we check the course_id backup data folder exists
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Now, if we have anything in events, we have to restore that
//events
if ($events) {
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Events', $restore, $info['EVENT']['#'], array('TIMESTART'));
+ }
+
//Now build the EVENT record structure
$eve->name = backup_todb($info['EVENT']['#']['NAME']['0']['#']);
$eve->description = backup_todb($info['EVENT']['#']['DESCRIPTION']['0']['#']);
$eve->instance = 0;
$eve->eventtype = backup_todb($info['EVENT']['#']['EVENTTYPE']['0']['#']);
$eve->timestart = backup_todb($info['EVENT']['#']['TIMESTART']['0']['#']);
- $date = usergetdate($eve->timestart);
- fwrite ($restorelog_file,"The Event - ".$eve->name. " - TIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $eve->timestart += $restore->course_startdateoffset;
- $date = usergetdate($eve->timestart);
- fwrite ($restorelog_file," the Event TIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
$eve->visible = backup_todb($info['EVENT']['#']['VISIBLE']['0']['#']);
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
insert_record('role_capabilities', $override);
}
}
- }
+ }
+ //write activity date changes to the html log file, and update date values in the the xml array
+ function restore_log_date_changes($recordtype, &$restore, &$xml, $TAGS, $NAMETAG='NAME') {
+
+ global $CFG;
+ $openlog = false;
+
+ // loop through time fields in $TAGS
+ foreach ($TAGS as $TAG) {
+
+ // check $TAG has a sensible value
+ if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#']) && is_numeric($xml[$TAG][0]['#'])) {
+
+ if ($openlog==false) {
+ $openlog = true; // only come through here once
+
+ // open file for writing
+ $course_dir = "$CFG->dataroot/$restore->course_id/backupdata";
+ check_dir_exists($course_dir, true);
+ $restorelog = fopen("$course_dir/restorelog.html", "a");
+
+ // start output for this record
+ $msg = new stdClass();
+ $msg->recordtype = $recordtype;
+ $msg->recordname = $xml[$NAMETAG][0]['#'];
+ fwrite ($restorelog, get_string("backupdaterecordtype", "moodle", $msg));
+ }
+
+ // write old date to $restorelog
+ $value = $xml[$TAG][0]['#'];
+ $date = usergetdate($value);
+
+ $msg = new stdClass();
+ $msg->TAG = $TAG;
+ $msg->weekday = $date['weekday'];
+ $msg->mday = $date['mday'];
+ $msg->month = $date['month'];
+ $msg->year = $date['year'];
+ fwrite ($restorelog, get_string("backupdateold", "moodle", $msg));
+
+ // write new date to $restorelog
+ $value += $restore->course_startdateoffset;
+ $date = usergetdate($value);
+
+ $msg = new stdClass();
+ $msg->TAG = $TAG;
+ $msg->weekday = $date['weekday'];
+ $msg->mday = $date['mday'];
+ $msg->month = $date['month'];
+ $msg->year = $date['year'];
+ fwrite ($restorelog, get_string("backupdatenew", "moodle", $msg));
+
+ // update $value in $xml tree for calling module
+ $xml[$TAG][0]['#'] = "$value";
+ }
+ }
+ // close the restore log, if it was opened
+ if ($openlog) {
+ fclose($restorelog);
+ }
+ }
?>
\ No newline at end of file
$string['backupcancelled'] = 'Backup Cancelled';
$string['backupcoursefileshelp'] = 'If enabled then course files will be included in automated backups';
$string['backupdate'] = 'Backup Date';
+$string['backupdatenew'] = ' $a->TAG is now $a->weekday, $a->mday $a->month $a->year<br>\n';
+$string['backupdateold'] = '$a->TAG was $a->weekday, $a->mday $a->month $a->year\n';
+$string['backupdaterecordtype'] = '<br>$a->recordtype - $a->recordname<br>\n';
$string['backupdetails'] = 'Backup Details';
$string['backupexecuteathelp'] = 'Choose what time automated backups should run at.';
$string['backupfailed'] = 'Some of your courses weren\'t saved!!';
$string['yourteacher'] = 'your $a';
$string['zippingbackup'] = 'Zipping backup';
-?>
+?>
\ No newline at end of file
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
- //Now get completed xmlized object
- $info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //Now get completed xmlized object
+ $info = $data->info;
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Assignment', $restore, $info['MOD']['#'], array('TIMEDUE', 'TIMEAVAILABLE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$assignment->assignmenttype = backup_todb($info['MOD']['#']['ASSIGNMENTTYPE']['0']['#']);
$assignment->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
$assignment->timedue = backup_todb($info['MOD']['#']['TIMEDUE']['0']['#']);
- $date = usergetdate($assignment->timedue);
- fwrite ($restorelog_file,"<br>The Assignment - ".$assignment->name." <br>");
- fwrite ($restorelog_file,"The TIMEDUE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $assignment->timedue += $restore->course_startdateoffset;
- $date = usergetdate($assignment->timedue);
- fwrite ($restorelog_file," the TIMEDUE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$assignment->timeavailable = backup_todb($info['MOD']['#']['TIMEAVAILABLE']['0']['#']);
- $date = usergetdate($assignment->timeavailable);
- fwrite ($restorelog_file,"The TIMEAVAILABLE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $assignment->timeavailable += $restore->course_startdateoffset;
- $date = usergetdate($assignment->timeavailable);
- fwrite ($restorelog_file," the TIMEAVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$assignment->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$assignment->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Chat', $restore, $info['MOD']['#'], array('CHATTIME'));
+ }
//Now, build the CHAT record structure
$chat->course = $restore->course_id;
$chat->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$chat->studentlogs = backup_todb($info['MOD']['#']['STUDENTLOGS']['0']['#']);
$chat->schedule = backup_todb($info['MOD']['#']['SCHEDULE']['0']['#']);
$chat->chattime = backup_todb($info['MOD']['#']['CHATTIME']['0']['#']);
- $date = usergetdate($chat->chattime);
- fwrite ($restorelog_file,"The Chat - ".$chat->name." <br>");
- fwrite ($restorelog_file,"The CHATTIME was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $chat->chattime += $restore->course_startdateoffset;
- $date = usergetdate($chat->chattime);
- fwrite ($restorelog_file," the CHATTIME is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$chat->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the chat
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Choice', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']);
$choice->limitanswers = backup_todb($info['MOD']['#']['LIMITANSWERS']['0']['#']);
$choice->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
- $date = usergetdate($choice->timeopen);
- fwrite ($restorelog_file,"<br>The Choice - ".$choice->name." <br>");
- fwrite ($restorelog_file,"The TIMEOPEN was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $choice->timeopen += $restore->course_startdateoffset;
- $date = usergetdate($choice->timeopen);
- fwrite ($restorelog_file," The TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$choice->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
- $date = usergetdate($choice->timeclose);
- fwrite ($restorelog_file,"The TIMECLOSE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $choice->timeclose += $restore->course_startdateoffset;
- $date = usergetdate($choice->timeclose);
- fwrite ($restorelog_file," the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//To mantain compatibilty, in 1.4 the publish setting meaning has changed. We
if ($data) {
//Now get completed xmlized object
- $info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ $info = $data->info;
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Database', $restore, $info['MOD']['#'], array('TIMEAVAILABLEFROM', 'TIMEAVAILABLETO','TIMEVIEWFROM', 'TIMEVIEWTO'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
}
$database->comments = backup_todb($info['MOD']['#']['COMMENTS']['0']['#']);
$database->timeavailablefrom = backup_todb($info['MOD']['#']['TIMEAVAILABLEFROM']['0']['#']);
- $date = usergetdate($database->timeavailablefrom);
- fwrite ($restorelog_file,"<br>The Database - ".$database->name." <br>");
- fwrite ($restorelog_file,"The TIMEAVAILABLEFROM was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $database->timeavailablefrom += $restore->course_startdateoffset;
- $date = usergetdate($database->timeavailablefrom);
- fwrite ($restorelog_file," the TTIMEAVAILABLEFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$database->timeavailableto = backup_todb($info['MOD']['#']['TIMEAVAILABLETO']['0']['#']);
- $date = usergetdate($database->timeavailableto);
- fwrite ($restorelog_file,"The TIMEAVAILABLETO was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $database->timeavailableto += $restore->course_startdateoffset;
- $date = usergetdate($database->timeavailableto);
- fwrite ($restorelog_file," the TIMEAVAILABLETO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$database->timeviewfrom = backup_todb($info['MOD']['#']['TIMEVIEWFROM']['0']['#']);
- $date = usergetdate($database->timeviewfrom);
- fwrite ($restorelog_file,"The TIMEVIEWFROM was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $database->timeviewfrom += $restore->course_startdateoffset;
- $date = usergetdate($database->timeviewfrom);
- fwrite ($restorelog_file," the TIMEVIEWFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$database->timeviewto = backup_todb($info['MOD']['#']['TIMEVIEWTO']['0']['#']);
- $date = usergetdate($database->timeviewto);
- fwrite ($restorelog_file,"The TIMEVIEWTO was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $database->timeviewto += $restore->course_startdateoffset;
- $date = usergetdate($database->timeviewto);
- fwrite ($restorelog_file," the TIMEVIEWTO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
// Only relevant for restoring backups from 1.6 in a 1.7 install.
if (isset($info['MOD']['#']['PARTICIPANTS']['0']['#'])) {
$database->participants = backup_todb($info['MOD']['#']['PARTICIPANTS']['0']['#']);
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
- //Now get completed xmlized object
- $info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //Now get completed xmlized object
+ $info = $data->info;
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Exercise', $restore, $info['MOD']['#'], array('DEADLINE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Forum', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
- $date = usergetdate($forum->assesstimestart);
- fwrite ($restorelog_file,"<br>The Forum - ".$forum->name." <br>");
- fwrite ($restorelog_file,"The ASSESSTIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $forum->assesstimestart += $restore->course_startdateoffset;
- $date = usergetdate($forum->assesstimestart);
- fwrite ($restorelog_file," the ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
- $date = usergetdate($forum->assesstimefinish);
- fwrite ($restorelog_file,"The ASSESSTIMEFINISH was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $forum->assesstimefinish += $restore->course_startdateoffset;
- $date = usergetdate($forum->assesstimefinish);
- fwrite ($restorelog_file," the ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
$forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
$forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']);
if (!empty($info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'])) {
$discussions = $info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'];
}
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Iterate over discussions
for($i = 0; $i < sizeof($discussions); $i++) {
$dis_info = $discussions[$i];
$discussion->groupid = backup_todb($dis_info['#']['GROUPID']['0']['#']);
$discussion->assessed = backup_todb($dis_info['#']['ASSESSED']['0']['#']);
$discussion->timemodified = backup_todb($dis_info['#']['TIMEMODIFIED']['0']['#']);
- $date = usergetdate($discussion->timemodified);
- fwrite ($restorelog_file,"<br>The Discussion - ".$discussion->name." <br>");
- fwrite ($restorelog_file,"The Discussion TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$discussion->timemodified += $restore->course_startdateoffset;
- $date = usergetdate($discussion->timemodified);
- fwrite ($restorelog_file," the Discussion TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']);
$discussion->timestart = backup_todb($dis_info['#']['TIMESTART']['0']['#']);
$discussion->timestart += $restore->course_startdateoffset;
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Glossary', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$glossary->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$glossary->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
- $date = usergetdate($glossary->assesstimestart);
- fwrite ($restorelog_file,"<br>The Glossary - ".$glossary->name." <br>");
- fwrite ($restorelog_file,"The Glossary ASSESSTIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $glossary->assesstimestart += $restore->course_startdateoffset;
- $date = usergetdate($glossary->assesstimestart);
- fwrite ($restorelog_file," the Glossary ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$glossary->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
- $date = usergetdate($glossary->assesstimefinish);
- fwrite ($restorelog_file,"The Glossary ASSESSTIMEFINISH was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $glossary->assesstimefinish += $restore->course_startdateoffset;
- $date = usergetdate($glossary->assesstimefinish);
- fwrite ($restorelog_file," the Glossary ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$glossary->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
//We have to recode the scale field if it's <0 (positive is a grade, not a scale)
}
// 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
} // 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";
- }
- }
- }
-}
?>
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Journal', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$journal->days = backup_todb($info['MOD']['#']['DAYS']['0']['#']);
$journal->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$journal->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
- $date = usergetdate($journal->timemodified);
- fwrite ($restorelog_file,"<br>The Journal - ".$journal->name." <br>");
- fwrite ($restorelog_file,"The Journal TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $journal->timemodified += $restore->course_startdateoffset;
- $date = usergetdate($journal->timemodified);
- fwrite ($restorelog_file," the Journal TTIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
//We have to recode the assessed field if it is <0 (scale)
if ($journal->assessed < 0) {
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$entry_info = $entries[$i];
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
- //We'll need this later!!
- $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
- $olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
+ //We'll need this later!! $sub_info changed to $entry_info
+ $oldid = backup_todb($entry_info['#']['ID']['0']['#']);
+ $olduserid = backup_todb($entry_info['#']['USERID']['0']['#']);
//Now, build the JOURNAL_ENTRIES record structure
$entry->journal = $new_journal_id;
- $entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']);
+ $entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']);
$entry->modified = backup_todb($entry_info['#']['MODIFIED']['0']['#']);
- $date = usergetdate($entry->modified);
- fwrite ($restorelog_file,"The Entry -".$entry->journal."- MODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$entry->modified += $restore->course_startdateoffset;
- $date = usergetdate($entry->modified);
- fwrite ($restorelog_file," the Entry MODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$entry->text = backup_todb($entry_info['#']['TEXT']['0']['#']);
$entry->format = backup_todb($entry_info['#']['FORMAT']['0']['#']);
$entry->rating = backup_todb($entry_info['#']['RATING']['0']['#']);
}
$entry->teacher = backup_todb($entry_info['#']['TEACHER']['0']['#']);
$entry->timemarked = backup_todb($entry_info['#']['TIMEMARKED']['0']['#']);
- $date = usergetdate($entry->timemarked);
- fwrite ($restorelog_file,"The Entry -".$entry->journal."- TIMEMARKED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$entry->timemarked += $restore->course_startdateoffset;
- $date = usergetdate($entry->timemarked);
- fwrite ($restorelog_file," the Entry TIMEMARKED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$entry->mailed = backup_todb($entry_info['#']['MAILED']['0']['#']);
//We have to recode the userid field
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Lesson', $restore, $info['MOD']['#'], array('AVAILABLE', 'DEADLINE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$lesson->displayleftif = isset($info['MOD']['#']['DISPLAYLEFTIF']['0']['#'])?backup_todb($info['MOD']['#']['DISPLAYLEFTIF']['0']['#']):'';
$lesson->progressbar = isset($info['MOD']['#']['PROGRESSBAR']['0']['#'])?backup_todb($info['MOD']['#']['PROGRESSBAR']['0']['#']):'';
$lesson->highscores = backup_todb($info['MOD']['#']['SHOWHIGHSCORES']['0']['#']);
- $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']);
+ $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']);
$lesson->available = backup_todb($info['MOD']['#']['AVAILABLE']['0']['#']);
- $date = usergetdate($lesson->available);
- fwrite ($restorelog_file,"<br>The Lesson - ".$lesson->name." <br>");
- fwrite ($restorelog_file,"The Time AVAILABLE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $lesson->available += $restore->course_startdateoffset;
- $date = usergetdate($lesson->available);
- fwrite ($restorelog_file," the Time AVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$lesson->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']);
- $date = usergetdate($lesson->deadline);
- fwrite ($restorelog_file,"The DEADLINE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $lesson->deadline += $restore->course_startdateoffset;
- $date = usergetdate($lesson->deadline);
- fwrite ($restorelog_file," the DEADLINE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$lesson->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the lesson
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
- $date = usergetdate($quiz->timeopen);
- fwrite ($restorelog_file,"<br>The Quiz - ".$quiz->name." <br>");
- fwrite ($restorelog_file,"The TIMEOPEN was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $quiz->timeopen += $restore->course_startdateoffset;
- $date = usergetdate($quiz->timeopen);
- fwrite ($restorelog_file," the TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
- $date = usergetdate($quiz->timeclose);
- fwrite ($restorelog_file,"The TIMECLOSE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $quiz->timeclose += $restore->course_startdateoffset;
- $date = usergetdate($quiz->timeclose);
- fwrite ($restorelog_file," the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$quiz->optionflags = backup_todb($info['MOD']['#']['OPTIONFLAGS']['0']['#']);
$quiz->penaltyscheme = backup_todb($info['MOD']['#']['PENALTYSCHEME']['0']['#']);
$quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
- $date = usergetdate($quiz->timeopen);
- fwrite ($restorelog_file,"The Quiz Named - ".$quiz->name." <br>");
- fwrite ($restorelog_file,"The Original Time Open was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $quiz->timeopen += $restore->course_startdateoffset;
- $date = usergetdate($quiz->timeopen);
- fwrite ($restorelog_file," Time Open is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
- $date = usergetdate($quiz->timeclose);
- fwrite ($restorelog_file,"The Original Time Close was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $quiz->timeclose += $restore->course_startdateoffset;
- $date = usergetdate($quiz->timeclose);
- fwrite ($restorelog_file," Time Close is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']);
$quiz->attemptonlast = backup_todb($info['MOD']['#']['ATTEMPTONLAST']['0']['#']);
$quiz->feedback = backup_todb($info['MOD']['#']['FEEDBACK']['0']['#']);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Wiki', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$wiki->revertchanges = backup_todb($info['MOD']['#']['REVERTCHANGES']['0']['#']);
$wiki->initialcontent = backup_todb($info['MOD']['#']['INITIALCONTENT']['0']['#']);
$wiki->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
- $date = usergetdate($wiki->timemodified);
- fwrite ($restorelog_file,"The Wiki - ".$wiki->name." <br>");
- $status = fwrite ($restorelog_file,"The Wiki TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $wiki->timemodified += $restore->course_startdateoffset;
- $date = usergetdate($wiki->timemodified);
- fwrite ($restorelog_file," the Wiki TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
//The structure is equal to the db, so insert the wiki
$newid = insert_record ("wiki",$wiki);
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$ent_info = $entries[$i];
$entry->groupid = backup_todb($ent_info['#']['GROUPID']['0']['#']);
$entry->pagename = backup_todb($ent_info['#']['PAGENAME']['0']['#']);
$entry->timemodified = backup_todb($ent_info['#']['TIMEMODIFIED']['0']['#']);
- $date = usergetdate($entry->timemodified);
- fwrite ($restorelog_file,"The Entry TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$entry->timemodified += $restore->course_startdateoffset;
- $date = usergetdate($entry->timemodified);
- fwrite ($restorelog_file," The Entry TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
if ($user) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Workshop', $restore, $info['MOD']['#'], array('SUBMISSIONSTART','ASSESSMENTSTART', 'SUBMISSIONEND', 'ASSESSMENTEND', 'RELEASEGRADES'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
$workshop->includeself = backup_todb($info['MOD']['#']['INCLUDESELF']['0']['#']);
$workshop->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
$workshop->submissionstart = backup_todb($info['MOD']['#']['SUBMISSIONSTART']['0']['#']);
- $date = usergetdate($workshop->submissionstart);
- fwrite ($restorelog_file,"<br>The Workshop - ".$workshop->name." <br>");
- fwrite ($restorelog_file,"The SUBMISSIONSTART time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $workshop->submissionstart += $restore->course_startdateoffset;
- $date = usergetdate($workshop->submissionstart);
- fwrite ($restorelog_file," the SUBMISSIONSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->assessmentstart = backup_todb($info['MOD']['#']['ASSESSMENTSTART']['0']['#']);
- $date = usergetdate($workshop->assessmentstart);
- fwrite ($restorelog_file,"The ASSESSMENTSTART time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $workshop->assessmentstart += $restore->course_startdateoffset;
- $date = usergetdate($workshop->assessmentstart);
- fwrite ($restorelog_file," the ASSESSMENTSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']);
$workshop->submissionend = backup_todb($info['MOD']['#']['SUBMISSIONEND']['0']['#']);
- $date = usergetdate($workshop->submissionend);
- fwrite ($restorelog_file,"The SUBMISSIONEND time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $workshop->submissionend += $restore->course_startdateoffset;
- $date = usergetdate($workshop->submissionend);
- fwrite ($restorelog_file," the SUBMISSIONEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->assessmentend = backup_todb($info['MOD']['#']['ASSESSMENTEND']['0']['#']);
- $date = usergetdate($workshop->assessmentend);
- fwrite ($restorelog_file,"The ASSESSMENTEND time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $workshop->assessmentend += $restore->course_startdateoffset;
- $date = usergetdate($workshop->assessmentend);
- fwrite ($restorelog_file," the ASSESSMENTEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->releasegrades = backup_todb($info['MOD']['#']['RELEASEGRADES']['0']['#']);
- $date = usergetdate($workshop->releasegrades);
- fwrite ($restorelog_file,"The RELEASEGRADES time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $workshop->releasegrades += $restore->course_startdateoffset;
- $date = usergetdate($workshop->releasegrades);
- fwrite ($restorelog_file," the RELEASEGRADES time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$workshop->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']);
$workshop->ntassessments = backup_todb($info['MOD']['#']['NTASSESSMENTS']['0']['#']);
//Get the submissions array
$submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
- //First, we check the course_id backup folder exists in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Iterate over submissions
for($i = 0; $i < sizeof($submissions); $i++) {
$sub_info = $submissions[$i];
$submission->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
$submission->title = backup_todb($sub_info['#']['TITLE']['0']['#']);
$submission->timecreated = backup_todb($sub_info['#']['TIMECREATED']['0']['#']);
- $date = usergetdate($submission->timecreated);
- fwrite ($restorelog_file,"The Submission - ".$submission->title. " - TIMECREATED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$submission->timecreated += $restore->course_startdateoffset;
- $date = usergetdate($submission->timecreated);
- fwrite ($restorelog_file," the Submission TIMECREATED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']);
$submission->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']);
$submission->gradinggrade = backup_todb($sub_info['#']['GRADINGGRADE']['0']['#']);
body {
font-size: 100%;
color: #333333;
- font-family: georgia, times, serif;
+ font-family: 'Bitstream Vera Serif', georgia, times, serif;
margin: 0;
- padding: 5px 10px 10px;
+ padding: 0;
+}
+div#page {
+ margin: 0 10px;
+ padding-top: 5px;
border-top-width: 10px;
border-top-style: solid;
border-top-color: #55CC00;
border-style: solid;
border-color: #FFFFFF #DDDDDD #DDDDDD #FFFFFF;
}
+form.mform div.textarea textarea {
+ width: 35em;
+}