Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Calculate NEXT course->sortorder in restore to avoid

sortorder grown always (by fix_course_sortorder()).

Merged from MOODLE_14_STABLE
  • Loading branch information...
commit 19479ebdfb3a658e1e959f6cc779c6b3166a0d75 1 parent 2b62fed
stronk7 authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 backup/restorelib.php
View
10 backup/restorelib.php
@@ -551,6 +551,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;
+ }
//Now insert the record
$newid = insert_record("course",$course);
if ($newid) {
Please sign in to comment.
Something went wrong with that request. Please try again.