Permalink
Browse files

Calculate NEXT course->sortorder in restore to avoid

sortorder grown always (by fix_course_sortorder()).
  • Loading branch information...
stronk7
stronk7 committed Nov 27, 2004
1 parent 3fa6dd5 commit 54669cd37685f4428150b10b50ae9f7a196ab7ce
Showing with 10 additions and 0 deletions.
  1. +10 −0 backup/restorelib.php
View
@@ -543,6 +543,16 @@ function restore_create_new_course($restore,&$course_header) {
$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;
+ }
//Adjust blockinfo field.
//If the info doesn't exist in backup, we create defaults, else we recode it
//to current site blocks.

0 comments on commit 54669cd

Please sign in to comment.