]> git.mjollnir.org Git - moodle.git/commitdiff
Calculate NEXT course->sortorder in restore to avoid
authorstronk7 <stronk7>
Sat, 27 Nov 2004 23:33:39 +0000 (23:33 +0000)
committerstronk7 <stronk7>
Sat, 27 Nov 2004 23:33:39 +0000 (23:33 +0000)
sortorder grown always (by fix_course_sortorder()).

Merged from MOODLE_14_STABLE

backup/restorelib.php

index 8cbb281a7d25e48fe3a610cc993c36a2e25c1cc2..2b6288764955ebefe26281b162a8f01dfa243961 100644 (file)
             $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) {