From: stronk7 Date: Sat, 27 Nov 2004 23:33:39 +0000 (+0000) Subject: Calculate NEXT course->sortorder in restore to avoid X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=19479ebdfb3a658e1e959f6cc779c6b3166a0d75;p=moodle.git Calculate NEXT course->sortorder in restore to avoid sortorder grown always (by fix_course_sortorder()). Merged from MOODLE_14_STABLE --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 8cbb281a7d..2b62887649 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -551,6 +551,16 @@ $course->hiddensections = addslashes($course_header->course_hiddensections); $course->timecreated = addslashes($course_header->course_timecreated); $course->timemodified = addslashes($course_header->course_timemodified); + //Calculate sortorder field + $sortmax = get_record_sql('SELECT MAX(sortorder) AS max + FROM ' . $CFG->prefix . 'course + WHERE category=' . $course->category); + if (!empty($sortmax->max)) { + $course->sortorder = $sortmax->max + 1; + unset($sortmax); + } else { + $course->sortorder = 100; + } //Now insert the record $newid = insert_record("course",$course); if ($newid) {