From: dongsheng Date: Thu, 11 Dec 2008 04:39:33 +0000 (+0000) Subject: "MDL-17469, fix assignment date when restore course, merged from 1.9" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0dfd9e97ead0c59c1bc941e2c695a9860bf0a36a;p=moodle.git "MDL-17469, fix assignment date when restore course, merged from 1.9" --- diff --git a/backup/restore.php b/backup/restore.php index 18663c7091..602bdd4264 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -23,6 +23,18 @@ $method = optional_param( 'method' ); $backup_unique_code = optional_param('backup_unique_code',0,PARAM_INT); + //Get and check course + if (! $course = get_record("course", "id", $id)) { + error("Course ID was incorrect (can't find it)"); + } + // To some reasons, course_startdateoffset value was lost during restoring + // See MDL-17469 + if (!empty($course->startdate) && !empty($SESSION->course_header->course_startdate)) { + $SESSION->restore->course_startdateoffset = $course->startdate - $SESSION->course_header->course_startdate; + } else { + $SESSION->restore->course_startdateoffset = 0; + } + //Check login require_login(); @@ -116,11 +128,6 @@ //We are here, so me have a file. - //Get and check course - if (! $course = $DB->get_record("course", array("id"=>$id))) { - print_error('invalidcourseid', '', '', $id); - } - //Print header if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { $navlinks[] = array('name' => basename($file), 'link' => null, 'type' => 'misc'); diff --git a/mod/assignment/restorelib.php b/mod/assignment/restorelib.php index e065ad2e94..3939800778 100644 --- a/mod/assignment/restorelib.php +++ b/mod/assignment/restorelib.php @@ -57,8 +57,8 @@ $assignment->type = isset($info['MOD']['#']['TYPE']['0']['#'])?backup_todb($info['MOD']['#']['TYPE']['0']['#']):''; $assignment->assignmenttype = backup_todb($info['MOD']['#']['ASSIGNMENTTYPE']['0']['#']); $assignment->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); - $assignment->timedue = backup_todb($data->info['MOD']['#']['TIMEDUE']['0']['#']); - $assignment->timeavailable = backup_todb($data->info['MOD']['#']['TIMEAVAILABLE']['0']['#']); + $assignment->timedue = backup_todb($info['MOD']['#']['TIMEDUE']['0']['#']); + $assignment->timeavailable = backup_todb($info['MOD']['#']['TIMEAVAILABLE']['0']['#']); $assignment->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']); $assignment->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);